Skip to content

Commit 52878ad

Browse files
committed
chore: upgrade js-x-ray
1 parent 51f5b06 commit 52878ad

10 files changed

Lines changed: 49 additions & 37 deletions

File tree

.changeset/tricky-tools-reply.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@nodesecure/tree-walker": minor
3+
"@nodesecure/scanner": minor
4+
"@nodesecure/tarball": minor
5+
"@nodesecure/rc": minor
6+
---
7+
8+
chore: upgrade js-x-ray

workspaces/rc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"ajv": "6.12.6"
4646
},
4747
"dependencies": {
48-
"@nodesecure/js-x-ray": "11.5.0",
48+
"@nodesecure/js-x-ray": "12.0.0",
4949
"@nodesecure/npm-types": "^1.2.0",
5050
"@nodesecure/vulnera": "^2.0.1",
5151
"@openally/config": "^1.0.1",

workspaces/scanner/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"@nodesecure/contact": "^3.0.0",
6969
"@nodesecure/flags": "^3.0.3",
7070
"@nodesecure/i18n": "^4.1.0",
71-
"@nodesecure/js-x-ray": "11.5.0",
71+
"@nodesecure/js-x-ray": "12.0.0",
7272
"@nodesecure/mama": "^2.1.1",
7373
"@nodesecure/npm-registry-sdk": "^4.4.0",
7474
"@nodesecure/npm-types": "^1.3.0",

workspaces/scanner/src/depWalker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
scanDirOrArchive,
1212
type PacoteProvider
1313
} from "@nodesecure/tarball";
14-
import { CollectableSet } from "@nodesecure/js-x-ray";
14+
import { DefaultCollectableSet, type CollectableSet } from "@nodesecure/js-x-ray";
1515
import * as Vulnera from "@nodesecure/vulnera";
1616
import { npm } from "@nodesecure/tree-walker";
1717
import { parseAuthor } from "@nodesecure/utils";
@@ -126,7 +126,7 @@ export async function depWalker(
126126

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

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

131131
const pacoteProvider: PacoteProvider = {
132132
async extract(spec, dest, opts): Promise<void> {
@@ -412,7 +412,7 @@ export async function depWalker(
412412
}
413413
}
414414

415-
function extractHighlightedIdentifiers(collectables: CollectableSet<Metadata>[], identifiersToHighlight: Set<string>) {
415+
function extractHighlightedIdentifiers(collectables: DefaultCollectableSet<Metadata>[], identifiersToHighlight: Set<string>) {
416416
if (identifiersToHighlight.size === 0) {
417417
return [];
418418
}

workspaces/tarball/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"dependencies": {
4848
"@nodesecure/conformance": "^1.2.1",
4949
"@nodesecure/fs-walk": "^2.0.0",
50-
"@nodesecure/js-x-ray": "11.5.0",
50+
"@nodesecure/js-x-ray": "12.0.0",
5151
"@nodesecure/mama": "^2.1.1",
5252
"@nodesecure/npm-types": "^1.2.0",
5353
"@nodesecure/utils": "^2.3.0",

workspaces/tarball/src/class/NpmTarball.class.ts

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import {
99
} from "@nodesecure/mama";
1010
import {
1111
AstAnalyser,
12-
CollectableSet,
12+
DefaultCollectableSet,
1313
warnings,
14-
type AstAnalyserOptions
14+
type AstAnalyserOptions,
1515
} from "@nodesecure/js-x-ray";
1616

1717
// Import Internal Dependencies
@@ -87,25 +87,29 @@ export class NpmTarball {
8787
.flatMap(filterJavaScriptFiles())
8888
});
8989

90-
const operationQueue =
91-
Array.from(hostNameSet)
92-
.map(({ value, locations }) => this.#resolver.isPrivateHost(value)
93-
.then((isPrivate) => {
94-
if (isPrivate) {
95-
locations.forEach(({ file, location }) => {
96-
code.warnings.push({
97-
kind: "shady-link",
98-
...warnings["shady-link"],
99-
file: file ?? undefined,
100-
location,
101-
value,
102-
source: "Scanner"
90+
if (hostNameSet instanceof DefaultCollectableSet) {
91+
const operationQueue =
92+
Array.from(hostNameSet)
93+
.map(({ value, locations }) => this.#resolver.isPrivateHost(value)
94+
.then((isPrivate) => {
95+
if (isPrivate) {
96+
locations.forEach(({ file, location }) => {
97+
code.warnings.push({
98+
kind: "shady-link",
99+
...warnings["shady-link"],
100+
file: file ?? undefined,
101+
location,
102+
value,
103+
source: "Scanner"
104+
});
103105
});
104-
});
105-
}
106-
})
107-
);
108-
await Promise.allSettled(operationQueue);
106+
}
107+
})
108+
);
109+
await Promise.allSettled(operationQueue);
110+
}
111+
112+
109113
}
110114

111115
return {
@@ -121,7 +125,7 @@ export class NpmTarball {
121125
return options;
122126
}
123127

124-
return { ...options, collectables: [...options.collectables ?? [], new CollectableSet("hostname")] };
128+
return { ...options, collectables: [...options.collectables ?? [], new DefaultCollectableSet("hostname")] };
125129
}
126130
}
127131

workspaces/tarball/test/NpmTarball.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { describe, test } from "node:test";
55
import assert from "node:assert";
66

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

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

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

103103
const result = await npmTarball.scanFiles({
104-
collectables: [new CollectableSet("url"), new CollectableSet("ip")]
104+
collectables: [new DefaultCollectableSet("url"), new DefaultCollectableSet("ip")]
105105
});
106106

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

141141
await npmTarball.scanFiles({
142142
collectables: [hostnameSet]
@@ -146,7 +146,7 @@ describe("NpmTarball", () => {
146146
});
147147
});
148148

149-
function extractSpecs(collectableSet: CollectableSet<Metadata>) {
149+
function extractSpecs(collectableSet: DefaultCollectableSet<Metadata>) {
150150
return Array.from(collectableSet)
151151
.flatMap(({ locations }) => locations.flatMap(({ metadata }) => metadata?.spec ?? []));
152152
}

workspaces/tarball/test/SourceCodeReport.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { test } from "node:test";
55
import assert from "node:assert";
66

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

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

143143
test("should add spec to collectables", async() => {
144-
const emailSet = new CollectableSet<{ spec: string; }>("email");
144+
const emailSet = new DefaultCollectableSet<{ spec: string; }>("email");
145145
const mama = createFakeManifestManager();
146146
const scanner = new SourceCodeScanner(mama, {
147147
astAnalyser: new AstAnalyser({ collectables: [emailSet] })

workspaces/tarball/test/SourceCodeScanner.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { describe, test } from "node:test";
88
import {
99
ManifestManager
1010
} from "@nodesecure/mama";
11-
import { type ReportOnFile, AstAnalyser, CollectableSet } from "@nodesecure/js-x-ray";
11+
import { type ReportOnFile, AstAnalyser, DefaultCollectableSet } from "@nodesecure/js-x-ray";
1212

1313
// Import Internal Dependencies
1414
import {
@@ -139,7 +139,7 @@ describe("SourceCodeScanner", () => {
139139

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

144144
const scanner = new SourceCodeScanner(mama, {
145145
astAnalyser: new AstAnalyser({

workspaces/tree-walker/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
},
3838
"homepage": "https://github.com/NodeSecure/tree/master/workspaces/tree-walker#readme",
3939
"dependencies": {
40-
"@nodesecure/js-x-ray": "11.5.0",
40+
"@nodesecure/js-x-ray": "12.0.0",
4141
"@nodesecure/npm-registry-sdk": "^4.0.0",
4242
"@nodesecure/npm-types": "^1.1.0",
4343
"@npmcli/arborist": "9.1.10",

0 commit comments

Comments
 (0)