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.
object-rewrite
Advanced tools
Rewrite an Object by defining exactly what gets excluded, injected and retained.
npm i --save object-rewrite
Modifies the data object in place. If you need to create a copy consider using _.deepClone().
const objectRewrite = require("object-rewrite");
const data = [{
guid: "aad8b948-a3de-4bff-a50f-3d59e9510aa9",
count: 3,
active: true,
tags: [{ id: 1 }, { id: 2 }, { id: 3 }]
}, {
guid: "4409fb72-36e3-4385-b3da-b4944d028dcb",
count: 4,
active: true,
tags: [{ id: 2 }, { id: 3 }, { id: 4 }]
}, {
guid: "96067a3c-caa2-4018-bcec-6969a874dad9",
count: 5,
active: false,
tags: [{ id: 3 }, { id: 4 }, { id: 5 }]
}];
const rewriter = objectRewrite({
exclude: {
"": (key, value, parents) => value.active !== true,
tags: (key, value, parents) => value.id !== 4
},
inject: {
"": (key, value, parents) => ({ count: value.count + 100 })
},
retain: ["count", "active", "tags.id"]
});
rewriter(data);
// => data is now modified
/*
[{
"count": 103,
"active": true,
"tags": []
}, {
"count": 104,
"active": true,
"tags": [{"id": 4}]
}]
*/
The empty needle ""
matches top level object(s).
Needles are specified according to object-scan.
Internally the option useArraySelector
is set to false.
Functions have signature Fn(key, value, parents)
as specified by object-scan. Keys are split (joined
is false),
Takes object where keys are needles and values are functions. The matches for a needle are removed from the object iff the corresponding function execution returns true.
Takes object where keys are needles and values are functions. For every match the corresponding function is executed and the result merged into the match. The match and the function response are expected to be objects.
Array of needles. Matches are kept if not excluded previously. All entries not matched are excluded. Defaults to ["**"]
which matches all entries.
FAQs
Rewrite Object(s) in place using plugins.
The npm package object-rewrite receives a total of 117 weekly downloads. As such, object-rewrite popularity was classified as not popular.
We found that object-rewrite 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.