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
4 changes: 2 additions & 2 deletions .changeset/calm-dingos-hunt.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
"@nodesecure/tree-walker": major
"@nodesecure/scanner": major
"@nodesecure/tree-walker": minor
"@nodesecure/scanner": minor
---

feat(scanner): add manifest integrity of root dependency in payload
5 changes: 5 additions & 0 deletions .changeset/warm-jars-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nodesecure/scanner": minor
---

feat(depWalker): do not add integrity to payload in cwd for workspace
10 changes: 8 additions & 2 deletions workspaces/scanner/src/depWalker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,14 @@ export async function depWalker(
dependencies.set(name, dependency);
}

if (current.id === kRootDependencyId) {
payload.integrity = integrity ?? fromData(JSON.stringify(manifest), { algorithms: ["sha512"] }).toString();
const isRoot = current.id === kRootDependencyId;

if (isRoot && payload.integrity) {
payload.integrity = integrity;
}
else if (isRoot) {
const isWorkspace = options.location && "workspaces" in manifest;
payload.integrity = isWorkspace ? null : fromData(JSON.stringify(manifest), { algorithms: ["sha512"] }).toString();
}

// If the dependency is a DevDependencies we ignore it.
Expand Down
1 change: 1 addition & 0 deletions workspaces/scanner/test/depWalker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ describe("scanner.cwd()", () => {
);

assert.strictEqual(result.rootDependencyName, "workspace");
assert.strictEqual(result.integrity, null);
});
});