Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/new-steaks-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@nodesecure/tarball": major
"@nodesecure/scanner": minor
"@nodesecure/rc": minor
"@nodesecure/tree-walker": minor
---

Implement Node.js worker_threads with a custom Pool to scan packages tarball with JS-X-Ray
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ typings/
*.tsbuildinfo

nsecure-result.json
temp/
dist/
temp/
temp.ts
temp.js
temp.mjs
.claude
2 changes: 1 addition & 1 deletion workspaces/conformance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"scripts": {
"build": "tsc -b",
"prepublishOnly": "npm run build",
"test-only": "node --test ./test/**/*.spec.ts",
"test-only": "node --test \"./test/**/*.spec.ts\"",
"test-types": "attw --pack . --profile esm-only",
"test": "c8 -r html npm run test-only && npm run test-types",
"spdx:refresh": "node ./scripts/fetchSpdxLicenses.js"
Expand Down
2 changes: 1 addition & 1 deletion workspaces/contact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"scripts": {
"build": "tsc -b",
"prepublishOnly": "npm run build",
"test-only": "node --test ./test/**/*.spec.ts",
"test-only": "node --test \"./test/**/*.spec.ts\"",
"test-types": "npm run build && tsd && attw --pack . --profile esm-only",
"test": "c8 -r html npm run test-only && npm run test-types"
},
Expand Down
43 changes: 40 additions & 3 deletions workspaces/contact/test/ContactExtractor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Import Node.js Dependencies
import assert from "node:assert";
import { describe, test } from "node:test";
import { describe, test, mock } from "node:test";
import { join } from "node:path";
import { readFileSync } from "node:fs";

Expand All @@ -13,6 +13,7 @@ import {
ContactExtractor,
type ContactExtractorPackageMetadata
} from "../src/index.ts";
import { NsResolver } from "../src/NsResolver.class.ts";

// CONSTANTS
const kManifestFixturePath = join(import.meta.dirname, "fixtures", "manifest");
Expand Down Expand Up @@ -110,10 +111,14 @@ describe("ContactExtractor", () => {
});

test("Given a Contact with a non-existing email domain, it must be identified as expired", async() => {
const mockedGetExpired = mock.method(NsResolver.prototype, "getExpired");
const extractor = new ContactExtractor({
highlight: []
});
const expiredEmail = "john.doe+test@somenonexistentdomainongoogle9991254874x54x54.com";
mockedGetExpired.mock.mockImplementation(
() => Promise.resolve([expiredEmail])
);

const dependencies: Record<string, ContactExtractorPackageMetadata> = {
kleur: {
Expand All @@ -127,6 +132,7 @@ describe("ContactExtractor", () => {

const { expired } = await extractor.fromDependencies(dependencies);
assert.deepEqual(expired, [expiredEmail]);
mockedGetExpired.mock.restore();
});
});

Expand Down Expand Up @@ -185,22 +191,37 @@ describe("ContactExtractor", () => {
});

test("Given a manifest with only active emails it shouldn't have any expired email", async() => {
const mockedGetExpired = mock.method(
NsResolver.prototype,
"getExpired",
() => Promise.resolve([])
);
const extractor = new ContactExtractor({
highlight: []
});

const { expired } = await extractor.fromManifest(kManifest);
assert.deepEqual(expired, []);
mockedGetExpired.mock.restore();
});

test("Given a Contact with a non-existing email domain, it must be identified as expired", async() => {
const extractor = new ContactExtractor({
highlight: []
});
const expiredEmail = "john.doe+test@somenonexistentdomainongoogle9991254874x54x54.com";
const mockedGetExpired = mock.method(
NsResolver.prototype,
"getExpired",
() => Promise.resolve([expiredEmail])
);

const { expired } = await extractor.fromManifest({ ...kManifest, author: { ...kManifest.author!, email: expiredEmail } });
const { expired } = await extractor.fromManifest({
...kManifest,
author: { ...kManifest.author!, email: expiredEmail }
});
assert.deepEqual(expired, [expiredEmail]);
mockedGetExpired.mock.restore();
});
});

Expand Down Expand Up @@ -270,19 +291,31 @@ describe("ContactExtractor", () => {
});

test("Given a packument with only active emails it shouldn't have any expired email", async() => {
const mockedGetExpired = mock.method(
NsResolver.prototype,
"getExpired",
() => Promise.resolve([])
);

const extractor = new ContactExtractor({
highlight: []
});

const { expired } = await extractor.fromPackument(kPackument);
assert.deepEqual(expired, []);
mockedGetExpired.mock.restore();
});

test("Given a Contact with a non-existing email domain, it must be identified as expired", async() => {
const extractor = new ContactExtractor({
highlight: []
});
const expiredEmail = "john.doe+test@somenonexistentdomainongoogle9991254874x54x54.com";
const mockedGetExpired = mock.method(
NsResolver.prototype,
"getExpired",
() => Promise.resolve([expiredEmail])
);
const versions = Object.entries(kPackument.versions)
.reduce((acc: Record<string, PackumentVersion>, [version, value]) => {
return {
Expand All @@ -294,8 +327,12 @@ describe("ContactExtractor", () => {
};
}, {});

const { expired } = await extractor.fromPackument({ ...kPackument, versions });
const { expired } = await extractor.fromPackument({
...kPackument,
versions
});
assert.deepEqual(expired, [expiredEmail]);
mockedGetExpired.mock.restore();
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion workspaces/flags/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"build": "tsc -b & cp -R ./src/flags ./dist/flags",
"prepublishOnly": "npm run build",
"test-only": "node --test ./test/**/*.spec.ts",
"test-only": "node --test \"./test/**/*.spec.ts\"",
"test-types": "attw --pack . --profile esm-only",
"test": "c8 -r html npm run test-only && npm run test-types",
"generateFlags": "node scripts/generateFlags.ts"
Expand Down
2 changes: 1 addition & 1 deletion workspaces/fs-walk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"scripts": {
"build": "tsc -b",
"prepublishOnly": "npm run build",
"test-only": "node --test ./test/**/*.spec.ts",
"test-only": "node --test \"./test/**/*.spec.ts\"",
"test-types": "attw --pack . --profile esm-only",
"test": "c8 -r html npm run test-only && npm run test-types"
},
Expand Down
2 changes: 1 addition & 1 deletion workspaces/github/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"build": "tsc -b",
"prepublishOnly": "npm run build",
"test-only": "node --test ./test/**/*.spec.ts",
"test-only": "node --test \"./test/**/*.spec.ts\"",
"test-types": "attw --pack . --profile esm-only",
"test": "c8 -r html npm run test-only && npm run test-types"
},
Expand Down
2 changes: 1 addition & 1 deletion workspaces/gitlab/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"build": "tsc -b",
"prepublishOnly": "npm run build",
"test-only": "node --test ./test/**/*.spec.ts",
"test-only": "node --test \"./test/**/*.spec.ts\"",
"test-types": "attw --pack . --profile esm-only",
"test": "c8 -r html npm run test-only && npm run test-types"
},
Expand Down
2 changes: 1 addition & 1 deletion workspaces/i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"build": "tsc -b",
"prepublishOnly": "npm run build",
"test-only": "node --test ./test/**/*.spec.ts",
"test-only": "node --test \"./test/**/*.spec.ts\"",
"test-types": "attw --pack . --profile esm-only",
"test": "c8 -r html npm run test-only && npm run test-types",
"build:documentation": "node ./scripts/buildDocumentation.ts"
Expand Down
2 changes: 1 addition & 1 deletion workspaces/mama/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"build": "tsc -b",
"prepublishOnly": "npm run build",
"test-only": "node --test ./test/**/*.spec.ts",
"test-only": "node --test \"./test/**/*.spec.ts\"",
"test-types": "npm run build && tsd && attw --pack . --profile esm-only",
"test": "c8 -r html npm run test-only && npm run test-types"
},
Expand Down
4 changes: 2 additions & 2 deletions workspaces/rc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"scripts": {
"build": "tsc -b",
"prepublishOnly": "npm run build",
"test-only": "node --test ./test/**/*.spec.ts",
"test-only": "node --test \"./test/**/*.spec.ts\"",
"test-types": "npm run build && tsd && attw --pack . --profile esm-only",
"test": "c8 -r html npm run test-only && npm run test-types"
},
Expand Down Expand Up @@ -45,7 +45,7 @@
"ajv": "8.18.0"
},
"dependencies": {
"@nodesecure/js-x-ray": "14.3.0",
"@nodesecure/js-x-ray": "15.0.0",
"@nodesecure/npm-types": "^1.2.0",
"@nodesecure/vulnera": "3.1.0",
"@openally/config": "^1.0.1",
Expand Down
4 changes: 2 additions & 2 deletions workspaces/scanner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"lint": "eslint src test",
"prepublishOnly": "npm run build && pkg-ok",
"test": "c8 -r html npm run test-only && npm run test-types",
"test-only": "node --test ./test/**/*.spec.ts",
"test-only": "node --test \"./test/**/*.spec.ts\"",
"test-types": "attw --pack . --profile esm-only"
},
"publishConfig": {
Expand Down Expand Up @@ -68,7 +68,7 @@
"@nodesecure/contact": "^3.0.0",
"@nodesecure/flags": "^3.0.3",
"@nodesecure/i18n": "^4.1.0",
"@nodesecure/js-x-ray": "14.3.0",
"@nodesecure/js-x-ray": "15.0.0",
"@nodesecure/mama": "^2.2.0",
"@nodesecure/npm-registry-sdk": "4.5.2",
"@nodesecure/npm-types": "^1.3.0",
Expand Down
Loading
Loading