generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
464e360
commit 223f2bb
Showing
6 changed files
with
107 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const buildCommitBody = require("../buildCommitBody"); | ||
const report = require("./report.json"); | ||
|
||
test("buildCommitBody()", () => { | ||
expect(buildCommitBody(report)).toEqual(`Summary: | ||
- Updated packages: 2 | ||
- Added packages: 1 | ||
- Removed packages: 1 | ||
Fixed vulnerabilities: | ||
- mocha: "Prototype Pollution" (https://npmjs.com/advisories/1179) | ||
`); | ||
|
||
expect(buildCommitBody({ added: [], removed: [], updated: [], packageCount: 0, packageUrls: {} })) | ||
.toEqual(`Summary: | ||
- Updated packages: 0 | ||
- Added packages: 0 | ||
- Removed packages: 0 | ||
No fixed vulnerabilities. | ||
`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @param {Report} report | ||
* @returns {string} | ||
*/ | ||
module.exports = function buildCommitBody(report) { | ||
const lines = []; | ||
|
||
lines.push("Summary:"); | ||
lines.push(`- Updated packages: ${report.updated.length}`); | ||
lines.push(`- Added packages: ${report.added.length}`); | ||
lines.push(`- Removed packages: ${report.removed.length}`); | ||
|
||
lines.push(""); | ||
if (report.updated.length > 0) { | ||
lines.push("Fixed vulnerabilities:"); | ||
report.updated.forEach((e) => { | ||
if ("severity" in e) { | ||
lines.push(`- ${e.name}: "${e.title}" (${e.url})`); | ||
} | ||
}); | ||
} else { | ||
lines.push("No fixed vulnerabilities."); | ||
} | ||
|
||
return lines.map((line) => `${line}\n`).join(""); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters