Skip to content

Commit

Permalink
More juice-shop edge cases
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
  • Loading branch information
prabhu committed Dec 30, 2024
1 parent d25cf5a commit 3ebac9c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
31 changes: 25 additions & 6 deletions lib/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1181,11 +1181,17 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
value: "true",
});
}
if (!node?.isRegistryDependency) {
pkg.properties.push({
name: "cdx:npm:isRegistryDependency",
value: "false",
});
// This getter method could fail with errors at times.
// Example Error: Invalid tag name "^>=6.0.0" of package "^>=6.0.0": Tags may not have any characters that encodeURIComponent encodes.
try {
if (!node?.isRegistryDependency) {
pkg.properties.push({
name: "cdx:npm:isRegistryDependency",
value: "false",
});
}
} catch (err) {
// ignore
}
if (node?.isWorkspace) {
pkg.properties.push({
Expand Down Expand Up @@ -1383,7 +1389,11 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
// if we can't find the version of the edge, continue
// it may be an optional peer dependency
if (!targetVersion || !targetName) {
if (DEBUG_MODE && !options.deep && edge?.type !== "optional") {
if (
DEBUG_MODE &&
!options.deep &&
!["optional", "peer", "peerOptional"].includes(edge?.type)
) {
if (!targetVersion) {
console.log(
`Unable to determine the version for the dependency ${edge.name} from the path ${edge?.from?.path}. This is likely an edge case that is not handled.`,
Expand All @@ -1396,6 +1406,15 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
);
}
}
// juice-shop
// Lock files created with --legacy-peer-deps will have certain peer dependencies missing
// This flags any non-missing peers
if (DEBUG_MODE && edge?.type === "peer" && edge?.error !== "MISSING") {
console.log(
`Unable to determine the version for the dependency ${edge.name} from the path ${edge?.from?.path}. This is likely an edge case that is not handled.`,
edge,
);
}
continue;
}
const depPurlString = decodeURIComponent(
Expand Down
2 changes: 1 addition & 1 deletion types/lib/helpers/utils.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3ebac9c

Please sign in to comment.