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.
mongodb-language-model
Advanced tools
Parses MongoDB query language and creates hierarchical Ampersand.js models
Parses a MongoDB query and creates hierarchical Ampersand.js models for each of the language components, which can then be interacted with programmatically.
This is the hierarchical model that is created when a query is parsed:
var Query = require('mongodb-language-model').Query;
var assert = require('assert');
// you need to specify `{parse: true}` if a raw javascript object is provided
var query = new Query(
{"foo": 12345, "$and": [ {bar: false}, {baz: "hello"} ] },
{parse: true}
);
// two top-level clauses
assert.equal(query.clauses.length, 2);
// access leaf clause
var leafClause = query.clauses.get('foo');
assert.equal(leafClause.className, 'LeafClause');
// LeafClause provides access to key and value objects. To access the their
// native values, they need to be serialized.
assert.equal(leafClause.key.serialize(), 'foo');
assert.equal(leafClause.value.serialize(), 12345);
// access the $and expression tree
var exprTree = query.clauses.get('$and');
assert.equal(exprTree.className, 'ExpressionTree');
// get the list of clause keys
var keys = exprTree.expressions.map(function (expr) {
return expr.clauses.at(0).key.serialize();
});
assert.deepEqual(keys, ['bar', 'baz']);
// get the list of clause values
var values = exprTree.expressions.map(function (expr) {
return expr.clauses.at(0).value.serialize();
})
assert.deepEqual(values, [false, 'hello']);
// @todo
npm install --save mongodb-language-model
npm test
Apache 2.0
FAQs
Parses MongoDB query language and returns an abstract syntax tree
The npm package mongodb-language-model receives a total of 6,308 weekly downloads. As such, mongodb-language-model popularity was classified as popular.
We found that mongodb-language-model demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 28 open source maintainers 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.