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.
json-version-control
Advanced tools
{ Version Control } Small library for node (beta version).
const { createHistoryObject } = require('json-version-control')
const firstVersion = {
name: 'Ashley',
age: 31,
hobbie: 'Painting',
address: {
state: 'Michigan',
zip: '0000',
},
some: {
other: {
things: []
}
}
}
const secondVersion = {
name: 'Ashley',
age: 32,
birthday: '1 Jan',
address: {
city: 'Detroit',
zip: '0001'
},
some: {
other: {
info: {
about: 'Ashley'
}
}
}
}
const historyObject = createHistoryObject(0, firstVersion, secondVersion)
/**
* historyObject = {
* VERSION_NUMBER: 0,
* CREATED_PROPERTIES: {
* birthday: '1 Jan',
* '%$/$7EXISTED#!ZZv-address': { city: 'Detroit' },
* '%$/$7EXISTED#!ZZv-some': { '%$/$7EXISTED#!ZZv-other': { info: { about: 'Ashley' } } }
* },
* DELETED_PROPERTIES: {
* '%$/$7DELETED#!ZZv-hobbie': 'Painting',
* address: { '%$/$7DELETED#!ZZv-state': 'Michigan' },
* some: { other: { '%$/$7DELETED#!ZZv-things': [] } }
* },
* MODIFIED_VALUES: {
* age: 31, address: { zip: '0000' }
* }
* }
*/
npm i json-version-control
This package is for tracking the versions of the JSON objects. You can import the package in your app with the following statement:
const jsonVersionControl = require('json-version-control')
Imported object consists of two functions createHistoryObject & restoreHistoryObject. Alternatively you can import these two functions with destructuring assignment:
const { createHistoryObject, restoreHistoryObject } = require('json-version-control')
createHistoryObject arguments:
Returns: historyObject (Object) - Which consists of four properties:
restoreHistoryObject arguments:
Returns: mergedObject (Object) - Which is the oldest version of historyObjects, in the restored state.
Purpose of this small library. Given the collection of JSON objects, which is stored in the database. After some period of time, the new set of objects are given, which represents the updated versions of existing ones. Tasks: 1) Store updated information 2) Catch differences (propertie creation, deletion & value modificataions). First of all if a dataset is large, intuitivley it will quickly run out of the memory, if already stored non modified data is stored again. Second task: how to catch deep differences of two JSON objects. This two functions, which this library provides, gives the solutions of the above tasks. If you have already overviewed the above example and the description of createHistoryObject, you probably have an idea what that function does, so based on that let's overview how we can restore previous versions of JSON objects, which are stored in the database, in the format that createHistoryObject function provides.
const { createHistoryObject, restoreHistoryObject } = require('json-version-control')
const firstVersion = {
name: 'Ashley',
age: 31,
hobbie: 'Painting',
address: {
state: 'Michigan',
zip: '0000',
},
some: {
other: {
things: []
}
}
}
const secondVersion = {
name: 'Ashley',
age: 32,
birthday: '1 Jan',
address: {
city: 'Detroit',
zip: '0001'
},
some: {
other: {
info: {
about: 'Ashley'
}
}
}
}
const thirdVersion = {
name: 'Ashley',
education: 'MIT'
}
const historyObject0 = createHistoryObject(0, firstVersion, secondVersion)
const historyObject1 = createHistoryObject(1, secondVersion, thirdVersion)
const historyObjects = [historyObject0, historyObject1]
const options = { considerVersionNumbers: true }
const restoredPredecessor = restoreHistoryObject(historyObjects, thirdVersion, options)
/**
* restoredPredecessor = {
* name: 'Ashley',
* age: 31,
* hobbie: 'Painting',
* address: {
* state: 'Michigan',
* zip: '0000',
* },
* some: {
* other: {
* things: []
* }
* }
* }
*/
When it is needed to restore predecessor version of the current object, predecessor historyObject and current version is merged. Thats say you have 0, 1, 2, 3, versions. Current version is 3. It is needed to restore 0 version. Than following procedure goes on: merge(2, 3) => 2(resotred); merge(1, 2(restored)) => 1(restored); merge(0, 1(restored)) => 0(restored).
MIT
FAQs
A lightweight and easy-to-use package that provides version control functionality for JSON files.
The npm package json-version-control receives a total of 5 weekly downloads. As such, json-version-control popularity was classified as not popular.
We found that json-version-control 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.