-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Yarn Audit on a workspaces yarn project doesn't verify devDependencies #7047
Comments
Here is a script I run in my CI/CD pipeline to audit only production packages: const fs = require("fs");
const filepath = "./reports/yarn-audit.json";
try {
const report = fs
.readFileSync(filepath, "utf8")
.toString()
.split("\n");
const packageJson = require("../package.json");
const advisoryURL = "https://npmjs.com/advisories/";
const advisories = report
.map(item => {
try {
return JSON.parse(item);
} catch (e) {
return null;
}
})
.filter(advisory => advisory !== null && advisory.type === "auditAdvisory");
const findings = advisories.filter(advisory => {
// Check for all findings if the root module is in devDependencies
const advisoryFindings = advisory.data.advisory.findings;
const advisoryFindingsProduction = advisoryFindings.filter(find => {
const rootModule = find.paths[0].split(">")[0];
return Object.keys(packageJson.dependencies).includes(rootModule);
});
return advisoryFindingsProduction.length > 0;
});
if (findings.length > 0) {
console.log(`found ${findings.length} vulnerabilities among production dependencies. Please visit below link for details`);
console.log("--------------------");
findings.forEach(finding => {
console.log(`URL: ${advisoryURL}${finding.data.resolution.id}`);
console.log(`Path: ${finding.data.resolution.path}`);
console.log("--------------------");
});
try {
fs.unlinkSync(filepath);
} catch (err) {
console.error(err);
}
process.exit(1);
} else {
try {
fs.unlinkSync(filepath);
} catch (err) {
console.error(err);
}
process.exit(0);
}
} catch (e) {
console.log(e);
try {
fs.unlinkSync(filepath);
} catch (err) {
console.error(err);
}
process.exit(1);
} Gitlab pipeline yaml
...and the npm script:
|
@sbuckpesch your script does the opposite of what the issue is here. |
This issue is also mentioned by
|
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
For some reason when I run
yarn audit
on a workspaces yarn project it only verifies the dependencies and not devDependenciesIf the current behavior is a bug, please provide the steps to reproduce.
https://github.com/uyuni-project/uyuni/blob/master/susemanager-frontend/package.json
What is the expected behavior?
The default behavior with all the packages checked for vulnerabilities
Please mention your node.js, yarn and operating system version.
yarn: 1.14.0
nodejs: 10.15.0
The text was updated successfully, but these errors were encountered: