Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Storage library for node. An unique api to use all databases (SQL and NOSQL)
I don't want to design it, I want to use it.
Ok, ok... I know that the goal is very ambitious. But wait, my idea is that for many projects the requirements are not so complex, we just need for a storage of
So, starting from this point of view, we can write some simple API that can work with all databases. I already wrote the driver for couchdb, and mysql (slow, I'm working on), but I'm pretty sure I can write the same API for mongodb, oracle, MsSql, Cassandra, orientdb etc.
The first concept is that all the data (you know entities?!?) are encapsulated into data objects. Any data object contains a structured part:
and an unstructured one:
Your data are into obj, whereas the structured part is to manage some non functional aspect of your application.
A data object is managed by DataObject
class.
A data object is uniquely identified by id, type, partition
.
The partition
is the way to manage mutitenancy or, if you want, to implements more that one application into a unique database.
The acl
is the Access Control List and mantains informations of who can read and who can write the data object.
An example of data object is:
var dobj = {
type: 'sample.test',
id: 'sampleid1',
partition: 'samplepartition',
acl: {
readers: { 'admin': 'admin', 'public': 'public' },
writers: { 'admin': 'admin' }
},
obj: {
firstname: 'Jon',
lastname: 'Snow',
age: 25,
status: 'live',
characteristics: [
'you don\'t know nothing Jon Snow',
'really, he\'s still alive'
]
}
};
If we want to retrieve data objects we need summaries. A summary is like an index of a collection of data objects. So any summary are defined by:
So, the following summary:
var summary = {
name: 'samplesummary',
types: ['sample.test'],
select: {
type: 'compare',
key: 'status',
value: 'live',
operator: 'EQ'
},
columns: [
{key: 'lastname', ordered: true },
{key: 'firstname', ordered: true },
{key: 'status', orderd: false }
]
};
is named samplesummary
and list all data objects with type sample.test
and where status
field is equal to the string 'live'
and then the summary report the columns lastname
,firstname
,status
.
This view has two ordered columns so, as you can expect, you can lookup for data objects using values that match only the fist column or both.
To create a connection to the store, or create a new one
With couchdb
var unstore = require('unodestore');
var store = new unstore.UnStore();
store.setDriver('couchdb');
store.openConnection({
host: 'localhost',
port: '5984',
ssl: false,
cache: false,
user: 'admin',
password: 'yourpassswordhere',
database: 'dbname'
}, function (err, obj) {
if (err) {
console.log(err.message);
}
// do something with store
});
With mysql
var unstore = require('unodestore');
var store = new unstore.UnStore();
store.setDriver('mysql');
store.openConnection({
host: 'localhost',
port: '3306',
user: 'username',
password: 'yourpassswordhere',
db: 'dbname'
}, function (err, obj) {
if (err) {
console.log(err.message);
}
// do something with store
});
Then you can use the store. To save a data object:
var dobj = {
type: 'sample.test',
id: 'sampleid1',
partition: 'samplepartition',
acl: {
readers: { 'admin': 'admin', 'public': 'public' },
writers: { 'admin': 'admin' }
},
obj: {
firstname: 'Jon',
lastname: 'Snow',
age: 25,
status: 'live',
characteristics: [
'you don\'t know nothing Jon Snow',
'really, he\'s still alive'
]
}
};
store.dataObjectSave( dobj, {'admin': 'admin'}, function (err, obj) {
if (err) {
console.log(err.message);
} else {
// do something with obj
}
});
To retrieve a data object:
store.fetchByTypeId('sample.test', 'sampleid1', 'samplepartition', {'admin': 'admin'}, function (err, obj) {
if (err) {
console.log(err.message);
} else {
// do something with obj (the required dataobject)
}
});
To create a summary:
var summary = {
name: 'samplesummary',
types: ['sample.test'],
select: {
type: 'compare',
key: 'status',
value: 'live',
operator: 'EQ'
},
columns: [
{key: 'lastname', ordered: true },
{key: 'firstname', ordered: true },
{key: 'status', orderd: false }
]
};
store.summarySave( summary, function (err, obj) {
if (err) {
console.log(err.message);
} else {
// do something with obj
}
}):
To fetch from a summary:
store.summaryFetch(
'samplesummary',
{
values: ['Snow'],
count: 25
},
'samplepartition',
['public':'public'],
function (err, obj) {
if (err) {
console.log(err.message);
} else {
obj.rows.forEach(function(row){
console.dir(row);
});
}
}
);
To install:
$ npm install unodestore
To test:
$ npm test unodestore
testing require nodeunit
You have to create the user/password/database for mysql and the user/password for couchdb. Then put the right values
into test.complete.js
FAQs
Unique storage library
The npm package unodestore receives a total of 1 weekly downloads. As such, unodestore popularity was classified as not popular.
We found that unodestore demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.