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.
A naive diff algorithm based on the unique key path of each value in an Object / JSON
A naive diff algorithm based on the unique key path of each value in an Object / JSON
$ npm install flat-diff --save
Given:
import diff from 'flat-diff';
const base = {
a: [1, 2, { b: 1 }, 4, 5, 6],
b: 'test',
c: 'prev'
};
const target = {
a: [1, 2, { b: 2 }, 4, 6],
b: 'test 2',
d: 'new'
};
const metadata = diff(base, target);
will give a result of:
const metadata = [
{ path: 'a.0', type: 'same', value: 1 },
{ path: 'a.1', type: 'same', value: 2 },
{ path: 'a.2.b', type: 'put', prev: 1, value: 2 },
{ path: 'a.3', type: 'same', value: 4 },
{ path: 'a.4', type: 'put', prev: 5, value: 6 },
{ path: 'a.5', type: 'del', value: 6 },
{ path: 'b', type: 'put', prev: 'test', value: 'test 2' },
{ path: 'c', type: 'del', value: 'prev' },
{ path: 'd', type: 'post', value: 'new' }
];
// Note: path keys will be sorted.
Due to how keys are generated, if you have an array and object with number keys in the same path, there will be a conflict.
i.e.
// object
{
a: {
'0': 'b',
'1': 'c'
}
}
// array
{
a: ['b', 'c']
}
// both formats above will result in similar paths:
[
{path: 'a.0', value: 'b'},
{path: 'a.1', value: 'c'}
]
flat-diff
is MIT licensed
FAQs
A naive diff algorithm based on the unique key path of each value in an Object / JSON
The npm package flat-diff receives a total of 0 weekly downloads. As such, flat-diff popularity was classified as not popular.
We found that flat-diff 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.