
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@repositive/query-parser
Advanced tools
[](https://choosealicense.com/licenses/lgpl-3.0/) [](https://badge.fury.io/js/%40repositive%2Fquery-pars
The purpose of this library is to transform a search string to a tokenized data structure that can be used to perform analysis on the search input or as an intermediate structure to translate the query into other DSLs or query structures.
Features:
AND
, OR
, NOT
)
AND
) on non quoted spaces.(white or blue) flower not thistle
flower "white daisy"
family:Asteraceae population:>100000 england
With npm:
$ npm i @repositive/query-parser
The library exposes the following functions:
Tree construction
(str: string) => Token
({key: string, value: string}) => Predicate
<L extends Node, R extends Node>({left: L, right: R}) => AND<L, R>
<L extends Node, R extends Node>({left: L, right: R}) => OR<L, R>
<N extends Node>(negated: N) => NOT<N>
Tools
<R>(node: Node, f: (node: Node, l: R, r: R) => R, R) => R
<R> (node: Node, f: (node: Node) => node is R) => R[]
(node: Node, target: Node) => Node[]
(node: Node, target: Node) => Node
({on: Node, target: Node, replacement: Node}) => Node
Parsing natural language string
(str: string) => Node
Serialization
(tree: Node) => string
(tree: Node) => any
import QP from 'npm:@repositive/query-parser';
// var QP = require(`@repositive/query-parser`); non ES6
/**
* "fromNatural" will generate the following tree from "is:user Istar NOT profession:developer":
* {
* "_id": "6bd6c61f-eab6-43bc-81d2-97f96c7c5f0a",
* "_type": "AND",
* "left": {
* "_id": "081c058a-e8cc-4ede-9637-6fd6593d5388",
* "_type": "predicate",
* "key": "is",
* "relation": "=",
* "value": "user"
* },
* "right": {
* "_id": "4719c7d4-965a-45cc-8132-87ed3acdc560",
* "_type": "AND",
* "left": {
* "_id": "8c8fae87-3aeb-4298-8f29-baf4c761ca12",
* "_type": "token",
* "value": "Istar"
* },
* "right": {
* "_id": "b0b49e4a-c2cc-4954-bc1d-b68bad17f441",
* "_type": "NOT",
* "negated": {
* "_id": "323596ca-24fa-4ec5-a7a5-0d4d1ed45645",
* "_type": "predicate",
* "key": "profession",
* "relation": "=",
* "value": "developer"
* }
* }
* }
* }
*/
const tree = QP.fromNatural('is:user Istar NOT profession:developer')
/*
* We can find the profession predicate using the filter function
*
*/
const profession = QP.filter(tree, (n) => n.key === 'profession')[0];
/**
* If we remove the profession filter with "remove" we expect to end with the following tree:
* {
* value: 'AND',
* right: { text: 'Istar' },
* left: {predicate: 'is', text: 'user'}
* }
*/
const professional = QP.remove(tree, profession);
/**
* Adding a new filter (attribute:awesome) to the three will return a new tree with the attribute inserted in the leftmost position
* {
* value: 'AND',
* left: { predicate: 'attribute', text: 'awesome'},
* right: {
* value: 'AND',
* right: { text: 'Istar' },
* left: { predicate: 'is', text: 'user'}
* }
* }
*/
const awesome = QP.and({left: professional, right: QP.predicate({key: 'attribute', value: 'awesome'}));
/**
* The serialization value of the new tree using "toBoolString" resembles the text as a human would write it:
* "is:user Istar attribute: awesome"
*/
const newQueryString = QP.toNatural(awesome);
FAQs
[](https://choosealicense.com/licenses/lgpl-3.0/) [](https://badge.fury.io/js/%40repositive%2Fquery-pars
We found that @repositive/query-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.