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/tricky-tools-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@nodesecure/tree-walker": minor
"@nodesecure/scanner": minor
"@nodesecure/tarball": minor
"@nodesecure/rc": minor
---

chore: upgrade js-x-ray
2 changes: 1 addition & 1 deletion workspaces/rc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"ajv": "6.12.6"
},
"dependencies": {
"@nodesecure/js-x-ray": "11.5.0",
"@nodesecure/js-x-ray": "12.0.0",
"@nodesecure/npm-types": "^1.2.0",
"@nodesecure/vulnera": "^2.0.1",
"@openally/config": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion workspaces/scanner/package.json
Original file line number Diff line number Diff line change
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": "11.5.0",
"@nodesecure/js-x-ray": "12.0.0",
"@nodesecure/mama": "^2.1.1",
"@nodesecure/npm-registry-sdk": "^4.4.0",
"@nodesecure/npm-types": "^1.3.0",
Expand Down
6 changes: 3 additions & 3 deletions workspaces/scanner/src/depWalker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
scanDirOrArchive,
type PacoteProvider
} from "@nodesecure/tarball";
import { CollectableSet } from "@nodesecure/js-x-ray";
import { DefaultCollectableSet, type CollectableSet } from "@nodesecure/js-x-ray";
import * as Vulnera from "@nodesecure/vulnera";
import { npm } from "@nodesecure/tree-walker";
import { parseAuthor } from "@nodesecure/utils";
Expand Down Expand Up @@ -126,7 +126,7 @@ export async function depWalker(

const statsCollector = new StatsCollector({ logger }, { isVerbose });

const collectables = kCollectableTypes.map((type) => new CollectableSet<Metadata>(type));
const collectables = kCollectableTypes.map((type) => new DefaultCollectableSet<Metadata>(type));

const pacoteProvider: PacoteProvider = {
async extract(spec, dest, opts): Promise<void> {
Expand Down Expand Up @@ -412,7 +412,7 @@ export async function depWalker(
}
}

function extractHighlightedIdentifiers(collectables: CollectableSet<Metadata>[], identifiersToHighlight: Set<string>) {
function extractHighlightedIdentifiers(collectables: DefaultCollectableSet<Metadata>[], identifiersToHighlight: Set<string>) {
if (identifiersToHighlight.size === 0) {
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion workspaces/tarball/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"dependencies": {
"@nodesecure/conformance": "^1.2.1",
"@nodesecure/fs-walk": "^2.0.0",
"@nodesecure/js-x-ray": "11.5.0",
"@nodesecure/js-x-ray": "12.0.0",
"@nodesecure/mama": "^2.1.1",
"@nodesecure/npm-types": "^1.2.0",
"@nodesecure/utils": "^2.3.0",
Expand Down
42 changes: 22 additions & 20 deletions workspaces/tarball/src/class/NpmTarball.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "@nodesecure/mama";
import {
AstAnalyser,
CollectableSet,
DefaultCollectableSet,
warnings,
type AstAnalyserOptions
} from "@nodesecure/js-x-ray";
Expand Down Expand Up @@ -87,25 +87,27 @@ export class NpmTarball {
.flatMap(filterJavaScriptFiles())
});

const operationQueue =
Array.from(hostNameSet)
.map(({ value, locations }) => this.#resolver.isPrivateHost(value)
.then((isPrivate) => {
if (isPrivate) {
locations.forEach(({ file, location }) => {
code.warnings.push({
kind: "shady-link",
...warnings["shady-link"],
file: file ?? undefined,
location,
value,
source: "Scanner"
if (hostNameSet instanceof DefaultCollectableSet) {
const operationQueue =
Array.from(hostNameSet)
.map(({ value, locations }) => this.#resolver.isPrivateHost(value)
.then((isPrivate) => {
if (isPrivate) {
locations.forEach(({ file, location }) => {
code.warnings.push({
kind: "shady-link",
...warnings["shady-link"],
file: file ?? undefined,
location,
value,
source: "Scanner"
});
});
});
}
})
);
await Promise.allSettled(operationQueue);
}
})
);
await Promise.allSettled(operationQueue);
}
}

return {
Expand All @@ -121,7 +123,7 @@ export class NpmTarball {
return options;
}

return { ...options, collectables: [...options.collectables ?? [], new CollectableSet("hostname")] };
return { ...options, collectables: [...options.collectables ?? [], new DefaultCollectableSet("hostname")] };
}
}

Expand Down
10 changes: 5 additions & 5 deletions workspaces/tarball/test/NpmTarball.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { describe, test } from "node:test";
import assert from "node:assert";

// Import Third-party Dependencies
import { CollectableSet, warnings, type Warning } from "@nodesecure/js-x-ray";
import { DefaultCollectableSet, warnings, type Warning } from "@nodesecure/js-x-ray";
import { ManifestManager } from "@nodesecure/mama";

type SourceArrayLocation = [[number, number], [number, number]];
Expand All @@ -26,7 +26,7 @@ describe("NpmTarball", () => {
test("it should have a shady-link warning when a hostname resolve a private ip address with collectables", async() => {
const mama = await ManifestManager.fromPackageJSON(path.join(kFixturePath, "shady-link", "package.json"));
const npmTarball = new NpmTarball(mama);
const hostnameSet = new CollectableSet("hostname");
const hostnameSet = new DefaultCollectableSet("hostname");

const result = await npmTarball.scanFiles({
collectables: [hostnameSet]
Expand Down Expand Up @@ -101,7 +101,7 @@ describe("NpmTarball", () => {
const npmTarball = new NpmTarball(mama);

const result = await npmTarball.scanFiles({
collectables: [new CollectableSet("url"), new CollectableSet("ip")]
collectables: [new DefaultCollectableSet("url"), new DefaultCollectableSet("ip")]
});

assert.deepEqual(
Expand Down Expand Up @@ -136,7 +136,7 @@ describe("NpmTarball", () => {
test("it should add the spec to collectables", async() => {
const mama = await ManifestManager.fromPackageJSON(path.join(kFixturePath, "shady-link", "package.json"));
const npmTarball = new NpmTarball(mama);
const hostnameSet = new CollectableSet<Metadata>("hostname");
const hostnameSet = new DefaultCollectableSet<Metadata>("hostname");

await npmTarball.scanFiles({
collectables: [hostnameSet]
Expand All @@ -146,7 +146,7 @@ describe("NpmTarball", () => {
});
});

function extractSpecs(collectableSet: CollectableSet<Metadata>) {
function extractSpecs(collectableSet: DefaultCollectableSet<Metadata>) {
return Array.from(collectableSet)
.flatMap(({ locations }) => locations.flatMap(({ metadata }) => metadata?.spec ?? []));
}
Expand Down
4 changes: 2 additions & 2 deletions workspaces/tarball/test/SourceCodeReport.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { test } from "node:test";
import assert from "node:assert";

// Import Third-party Dependencies
import { AstAnalyser, CollectableSet } from "@nodesecure/js-x-ray";
import { AstAnalyser, DefaultCollectableSet } from "@nodesecure/js-x-ray";

// Import Internal Dependencies
import { SourceCodeScanner } from "../src/class/SourceCodeScanner.class.ts";
Expand Down Expand Up @@ -141,7 +141,7 @@ test("should detect the usage of global fetch and update hasExternalCapacity fla
});

test("should add spec to collectables", async() => {
const emailSet = new CollectableSet<{ spec: string; }>("email");
const emailSet = new DefaultCollectableSet<{ spec: string; }>("email");
const mama = createFakeManifestManager();
const scanner = new SourceCodeScanner(mama, {
astAnalyser: new AstAnalyser({ collectables: [emailSet] })
Expand Down
4 changes: 2 additions & 2 deletions workspaces/tarball/test/SourceCodeScanner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { describe, test } from "node:test";
import {
ManifestManager
} from "@nodesecure/mama";
import { type ReportOnFile, AstAnalyser, CollectableSet } from "@nodesecure/js-x-ray";
import { type ReportOnFile, AstAnalyser, DefaultCollectableSet } from "@nodesecure/js-x-ray";

// Import Internal Dependencies
import {
Expand Down Expand Up @@ -139,7 +139,7 @@ describe("SourceCodeScanner", () => {

test("it should add spec to collectables", async() => {
const mama = loadFixtureManifest("entryfiles");
const emailSet = new CollectableSet<{ spec?: string; }>("email");
const emailSet = new DefaultCollectableSet<{ spec?: string; }>("email");

const scanner = new SourceCodeScanner(mama, {
astAnalyser: new AstAnalyser({
Expand Down
2 changes: 1 addition & 1 deletion workspaces/tree-walker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"homepage": "https://github.com/NodeSecure/tree/master/workspaces/tree-walker#readme",
"dependencies": {
"@nodesecure/js-x-ray": "11.5.0",
"@nodesecure/js-x-ray": "12.0.0",
"@nodesecure/npm-registry-sdk": "^4.0.0",
"@nodesecure/npm-types": "^1.1.0",
"@npmcli/arborist": "9.1.10",
Expand Down