
Research
Malicious fezbox npm Package Steals Browser Passwords from Cookies via Innovative QR Code Steganographic Technique
A malicious package uses a QR code as steganography in an innovative technique.
json-compare-engine
Advanced tools
npm install compare-engine
yarn add compare-engine
npm test
yarn test
Compares 2 json, considering array object movement :
import {CompareEngine} from 'compare-engine';
const jsonLeft = {
objectArray: [
{
id: "movedIndex",
property: "old property",
otherObjectArray: [
{id: "1"},
{id: "2"},
],
otherArray: [
0, 1, 2
]
},
{
id: "removedObject",
},
{
id: "equal"
}
]
};
const jsonright = {
objectArray: [
{
id: "newObject",
},
{
id: "movedIndex",
property: "updated property",
otherObjectArray: [
{id: "2"},
{id: "1"},
],
otherArray: [
2, 1, 3
]
},
{
id: "equal"
}
]
};
const compareEngine = new CompareEngine((paths: string[]) => {
return "id";
});
compareEngine.updateLeft(jsonLeft);
compareEngine.updateRight(jsonRight);
compareEngine.updateCompareIndex();
compareEngine.getLeftState("") // return UPDATED CompareState
compareEngine.getLeftState("objectArray") // return UPDATED CompareState
compareEngine.getLeftState("objectArray/0") // return UPDATED CompareState
compareEngine.getLeftState("objectArray/0/id") // return EQUAL CompareState
compareEngine.getLeftState("objectArray/0/property") // return UPDATED CompareState
compareEngine.getLeftState("objectArray/0/otherObjectArray") // return UPDATED CompareState
compareEngine.getLeftState("objectArray/0/otherObjectArray/0") // return UPDATED CompareState
compareEngine.getLeftState("objectArray/0/otherObjectArray/0/id") // return EQUAL CompareState
compareEngine.getLeftState("objectArray/0/otherObjectArray/1") // return UPDATED CompareState
compareEngine.getLeftState("objectArray/0/otherObjectArray/1/id") // return EQUAL CompareState
compareEngine.getLeftState("objectArray/0/otherArray") // return UPDATED CompareState
compareEngine.getLeftState("objectArray/0/otherArray/0") // return REMOVED CompareState
compareEngine.getLeftState("objectArray/0/otherArray/1") // return EQUAL CompareState
compareEngine.getLeftState("objectArray/0/otherArray/2") // return UPDATED CompareState
compareEngine.getLeftState("objectArray/1") // return REMOVED CompareState
compareEngine.getLeftState("objectArray/1/id") // return NONE CompareState
compareEngine.getLeftState("objectArray/2") // return EQUAL CompareState
compareEngine.getLeftState("objectArray/2/id") // return NONE CompareState
compareEngine.getLeftState("") // return UPDATED CompareState
compareEngine.getLeftState("objectArray") // return UPDATED CompareState
compareEngine.getLeftState("objectArray/0") // return ADDED CompareState
compareEngine.getLeftState("objectArray/0/id") // return NONE CompareState
compareEngine.getLeftState("objectArray/1") // return UPDATED CompareState
compareEngine.getLeftState("objectArray/1/id") // return EQUAL CompareState
compareEngine.getLeftState("objectArray/1/property") // return UPDATED CompareState
compareEngine.getLeftState("objectArray/1/otherObjectArray") // return UPDATED CompareState
compareEngine.getLeftState("objectArray/1/otherObjectArray/0") // return UPDATED CompareState
compareEngine.getLeftState("objectArray/1/otherObjectArray/0/id") // return EQUAL CompareState
compareEngine.getLeftState("objectArray/1/otherObjectArray/1") // return UPDATED CompareState
compareEngine.getLeftState("objectArray/1/otherObjectArray/1/id") // return EQUAL CompareState
compareEngine.getLeftState("objectArray/1/otherArray") // return UPDATED CompareState
compareEngine.getLeftState("objectArray/1/otherArray/0") // return UPDATED CompareState
compareEngine.getLeftState("objectArray/1/otherArray/1") // return EQUAL CompareState
compareEngine.getLeftState("objectArray/1/otherArray/2") // return ADDED CompareState
compareEngine.getLeftState("objectArray/2") // return EQUAL CompareState
compareEngine.getLeftState("objectArray/2/id") // return NONE CompareState
class CompareEngine {
constructor(protected determineArrayIndexFn?: (paths: string[]) => string)
updateLeft(json: any): void
updateRight(json: any): void
updateCompareIndex(): void
hasChange(): boolean
getLeftState(paths: string[] | string): CompareState
getRightState(paths: string[] | string): CompareState
}
class CompareState {
value: CompareStateEnum
isNone(): boolean
isAdded(): boolean
isUpdated(): boolean
isRemoved(): boolean
isEqual(): boolean
isChanged(): boolean
toString(): string
}
enum CompareStateEnum {
NONE = "",
ADDED = "added",
UPDATED = "updated",
REMOVED = "removed",
EQUAL = "equal",
}
abstract class CompareUtils {
static isNumber(num: JsonPrimitive): num is number
static isArray<T>(arr: unknown): arr is T[]
static isString(str: unknown): obj is string
static isObject(obj: unknown): obj is JsonObject
static isEqual(sideValue: unknown, otherSideValue: unknown): boolean
static deepClone<T, I>(source: T): T
}
FAQs
Json comparison engine
We found that json-compare-engine 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
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.
Application Security
/Research
/Security News
Socket detected multiple compromised CrowdStrike npm packages, continuing the "Shai-Hulud" supply chain attack that has now impacted nearly 500 packages.