Skip to content

Commit 3b653ee

Browse files
authored
feat(depWalker): do not add integrity to payload in cwd for workspace (#560)
1 parent 9e18d21 commit 3b653ee

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

.changeset/calm-dingos-hunt.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
"@nodesecure/tree-walker": major
3-
"@nodesecure/scanner": major
2+
"@nodesecure/tree-walker": minor
3+
"@nodesecure/scanner": minor
44
---
55

66
feat(scanner): add manifest integrity of root dependency in payload

.changeset/warm-jars-draw.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@nodesecure/scanner": minor
3+
---
4+
5+
feat(depWalker): do not add integrity to payload in cwd for workspace

workspaces/scanner/src/depWalker.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,14 @@ export async function depWalker(
179179
dependencies.set(name, dependency);
180180
}
181181

182-
if (current.id === kRootDependencyId) {
183-
payload.integrity = integrity ?? fromData(JSON.stringify(manifest), { algorithms: ["sha512"] }).toString();
182+
const isRoot = current.id === kRootDependencyId;
183+
184+
if (isRoot && payload.integrity) {
185+
payload.integrity = integrity;
186+
}
187+
else if (isRoot) {
188+
const isWorkspace = options.location && "workspaces" in manifest;
189+
payload.integrity = isWorkspace ? null : fromData(JSON.stringify(manifest), { algorithms: ["sha512"] }).toString();
184190
}
185191

186192
// If the dependency is a DevDependencies we ignore it.

workspaces/scanner/test/depWalker.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ describe("scanner.cwd()", () => {
263263
);
264264

265265
assert.strictEqual(result.rootDependencyName, "workspace");
266+
assert.strictEqual(result.integrity, null);
266267
});
267268
});
268269

0 commit comments

Comments
 (0)