Skip to content

Commit

Permalink
Resolve #1511 by disabling strict mode with node-tar so warnings …
Browse files Browse the repository at this point in the history
…do not prematurely end expansion.

Signed-off-by: Robert Ross <robross0606@gmail.com>
  • Loading branch information
robross0606 committed Dec 23, 2024
1 parent 50a2d4f commit 821cc52
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 29 deletions.
6 changes: 6 additions & 0 deletions lib/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,9 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
try {
tree = await arb.loadVirtual();
} catch (e) {
if (DEBUG_MODE) {
console.error(e);
}
console.log(
`Unable to parse ${pkgLockFile} without legacy peer dependencies. Retrying ...`,
);
Expand All @@ -1332,6 +1335,9 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
});
tree = await arb.loadVirtual();
} catch (e) {
if (DEBUG_MODE) {
console.error(e);
}
console.log(
`Unable to parse ${pkgLockFile} in legacy and non-legacy mode. The resulting SBOM would be incomplete.`,
);
Expand Down
38 changes: 12 additions & 26 deletions lib/managers/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,11 +754,14 @@ export const extractTar = async (fullImageName, dir) => {
preserveOwner: false,
noMtime: true,
noChmod: true,
strict: true,
strict: false,
C: dir,
portable: true,
onwarn: () => {
onwarn: (code, message) => {
// ignore
if (code !== "TAR_ENTRY_INFO" || DEBUG_MODE) {
console.log(` WARNING: ${message}`);
}
},
filter: (path, entry) => {
// Some files are known to cause issues with extract
Expand Down Expand Up @@ -804,36 +807,19 @@ export const extractTar = async (fullImageName, dir) => {
"Please run cdxgen from a powershell terminal with admin privileges to create symlinks.",
);
console.log(err);
} else if (
![
"TAR_BAD_ARCHIVE",
"TAR_ENTRY_INFO",
"TAR_ENTRY_INVALID",
"TAR_ENTRY_ERROR",
"TAR_ENTRY_UNSUPPORTED",
"TAR_ABORT",
"EACCES",
].includes(err.code)
) {
console.log(
`Error while extracting image ${fullImageName} to ${dir}. Please file this bug to the cdxgen repo. https://github.com/CycloneDX/cdxgen/issues`,
);
console.log("------------");
console.log(err);
console.log("------------");
} else if (err.code === "TAR_BAD_ARCHIVE") {
if (DEBUG_MODE) {
console.log(`Archive ${fullImageName} is empty. Skipping.`);
}
} else if (["EACCES"].includes(err.code)) {
} else if (err.code === "EACCES") {
console.log(err);
/*
* We do not display errors messages for errors:
* 1) TAR_ENTRY_INFO is an informative error indicating that an entry is being modified.
* 2) TAR_ENTRY_INVALID indicates that a given entry is not valid tar archive entry and will be skipped.
*/
} else if (!["TAR_ENTRY_INFO", "TAR_ENTRY_INVALID"].includes(err.code)) {
} else {
console.log(
`Error while extracting image ${fullImageName} to ${dir}. Please file this bug to the cdxgen repo. https://github.com/CycloneDX/cdxgen/issues`
);
console.log("------------");
console.log(err);
console.log("------------");
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion types/lib/cli/index.d.ts.map

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

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.

2 changes: 1 addition & 1 deletion types/lib/managers/docker.d.ts.map

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

0 comments on commit 821cc52

Please sign in to comment.