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.
simple-query-mutator
Advanced tools
$ npm install simple-query-mutator --save
formatQuery direct formats the query, can delete a property and change the value of another property at the same time or can be left null.
formatQuery(rawQuery,propToBeRemoved,propToBeChange,ChangeValue);
import { formatQuery } from 'simple-query-mutator';
// ...
const searchStr = '?language=eng&sort=price&type=product';
const result = formatQuery(searchStr, 'language');
// "?sort=price&type=product"
const result = formatQuery(searchStr, null, 'sort', 'date');
// "?language=eng&sort=date&type=product"
const result = formatQuery(searchStr, 'type', 'language', 'alien');
// "?language=alien&sort=date"
checkAndFormatQuery checks whether or not the prop exist then continue formatting.
checkAndFormatQuery(rawQuery,method,prop,ChangeValue);
import { checkAndFormatQuery } from 'simple-query-mutator';
// ...
const searchStr = '?language=eng&sort=price&type=product';
const result = checkAndFormatQuery(searchStr, 'get', 'type');
// "product"
const result = checkAndFormatQuery(searchStr, 'has', 'type');
// true
const result = checkAndFormatQuery(searchStr, 'change', 'language', 'alien');
// "?language=alien&sort=date"
const result = checkAndFormatQuery(searchStr, 'delete', 'language');
// "?sort=date"
changeQueryProp change the query's property key to a new property key, can change value too.
changeQueryProp(searchQuery,oldProp,newProp,newValue); accept string or object. newValue can be null
import { changeQueryProp } from 'simple-query-mutator';
// ...
const searchObj = { language: 'eng', sort: 'date', type: 'product' };
const searchStr = '?language=eng&sort=date&type=product';
const resultObjWithNewKey = changeQueryProp(searchObj, 'type', 'category');
// { language: 'eng', sort: 'date', category: 'product' }
const resultObjWithNewKeyAndValue = changeQueryProp(
searchObj,
'type',
'category',
'notproduct'
);
// { language: 'eng', sort: 'date', category: 'notproduct' }
const resultStrWithNewKey = changeQueryProp(searchStr, 'type', 'category');
// { language: 'eng', sort: 'date', category: 'product' }
const resultStrWithNewKeyAndValue = changeQueryProp(
searchStr,
'type',
'category',
'notproduct'
);
// { language: 'eng', sort: 'date', category: 'notproduct' }
Can be combined with queryObjToString method.
queryObjToString turns a search object into string;
queryObjToString(searchObj);
import { queryObjToString } from 'simple-query-mutator';
// ...
const searchObj = { language: 'eng', sort: 'date', type: 'product' };
const result = queryObjToString(searchObj);
// '?language=eng&sort=date&type=product';
FAQs
for mutating a search query,delete,change prop.
The npm package simple-query-mutator receives a total of 0 weekly downloads. As such, simple-query-mutator popularity was classified as not popular.
We found that simple-query-mutator 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.