-
Notifications
You must be signed in to change notification settings - Fork 169
Add list of resolved vulnerabilities to the PR Comment / Logs #1032
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
Open
david-wiggs
wants to merge
8
commits into
actions:main
Choose a base branch
from
david-wiggs:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a2a0ad8
feat: Add resolved vulnerabilities feedback to dependency review
david-wiggs bb6c2cf
fix: improve summary formatting for better GitHub rendering
david-wiggs d4e0ae2
Fix dual-context formatting: Use HTML for Action summary and Markdown…
david-wiggs 506c8ac
Fix formatting issues: separate HTML/Markdown lists, add newline befo…
david-wiggs feed587
Merge branch 'actions:main' into main
david-wiggs 092de4f
Remove extra markdown files
david-wiggs c50e73b
Remove unused function
david-wiggs 228875b
Apply suggestions from code review
david-wiggs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,122 @@ | ||
| import {test, expect} from '@jest/globals' | ||
| import {getResolvedVulnerabilities} from '../src/resolved-vulnerabilities' | ||
| import {Changes, Change} from '../src/schemas' | ||
|
|
||
| const vulnerableRemovedChange: Change = { | ||
| change_type: 'removed', | ||
| manifest: 'package.json', | ||
| ecosystem: 'npm', | ||
| name: 'lodash', | ||
| version: '4.17.20', | ||
| package_url: 'pkg:npm/lodash@4.17.20', | ||
| license: 'MIT', | ||
| source_repository_url: 'https://github.com/lodash/lodash', | ||
| scope: 'runtime', | ||
| vulnerabilities: [ | ||
| { | ||
| severity: 'high', | ||
| advisory_ghsa_id: 'GHSA-35jh-r3h4-6jhm', | ||
| advisory_summary: 'lodash Prototype Pollution vulnerability', | ||
| advisory_url: 'https://github.com/advisories/GHSA-35jh-r3h4-6jhm' | ||
| }, | ||
| { | ||
| severity: 'critical', | ||
| advisory_ghsa_id: 'GHSA-p6mc-m468-83gw', | ||
| advisory_summary: 'lodash Command Injection via template', | ||
| advisory_url: 'https://github.com/advisories/GHSA-p6mc-m468-83gw' | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| const nonVulnerableRemovedChange: Change = { | ||
| change_type: 'removed', | ||
| manifest: 'package.json', | ||
| ecosystem: 'npm', | ||
| name: 'express', | ||
| version: '4.18.0', | ||
| package_url: 'pkg:npm/express@4.18.0', | ||
| license: 'MIT', | ||
| source_repository_url: 'https://github.com/expressjs/express', | ||
| scope: 'runtime', | ||
| vulnerabilities: [] | ||
| } | ||
|
|
||
| const addedChange: Change = { | ||
| change_type: 'added', | ||
| manifest: 'package.json', | ||
| ecosystem: 'npm', | ||
| name: 'react', | ||
| version: '18.0.0', | ||
| package_url: 'pkg:npm/react@18.0.0', | ||
| license: 'MIT', | ||
| source_repository_url: 'https://github.com/facebook/react', | ||
| scope: 'runtime', | ||
| vulnerabilities: [ | ||
| { | ||
| severity: 'moderate', | ||
| advisory_ghsa_id: 'GHSA-test-1234', | ||
| advisory_summary: 'Test vulnerability', | ||
| advisory_url: 'https://github.com/advisories/GHSA-test-1234' | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| test('extracts resolved vulnerabilities from removed packages', () => { | ||
| const changes: Changes = [ | ||
| vulnerableRemovedChange, | ||
| nonVulnerableRemovedChange, | ||
| addedChange | ||
| ] | ||
|
|
||
| const resolvedVulns = getResolvedVulnerabilities(changes) | ||
|
|
||
| expect(resolvedVulns).toHaveLength(2) | ||
|
|
||
| expect(resolvedVulns[0]).toEqual({ | ||
| severity: 'high', | ||
| advisory_ghsa_id: 'GHSA-35jh-r3h4-6jhm', | ||
| advisory_summary: 'lodash Prototype Pollution vulnerability', | ||
| advisory_url: 'https://github.com/advisories/GHSA-35jh-r3h4-6jhm', | ||
| package_name: 'lodash', | ||
| package_version: '4.17.20', | ||
| package_url: 'pkg:npm/lodash@4.17.20', | ||
| manifest: 'package.json', | ||
| ecosystem: 'npm' | ||
| }) | ||
|
|
||
| expect(resolvedVulns[1]).toEqual({ | ||
| severity: 'critical', | ||
| advisory_ghsa_id: 'GHSA-p6mc-m468-83gw', | ||
| advisory_summary: 'lodash Command Injection via template', | ||
| advisory_url: 'https://github.com/advisories/GHSA-p6mc-m468-83gw', | ||
| package_name: 'lodash', | ||
| package_version: '4.17.20', | ||
| package_url: 'pkg:npm/lodash@4.17.20', | ||
| manifest: 'package.json', | ||
| ecosystem: 'npm' | ||
| }) | ||
| }) | ||
|
|
||
| test('returns empty array when no removed packages have vulnerabilities', () => { | ||
| const changes: Changes = [nonVulnerableRemovedChange, addedChange] | ||
|
|
||
| const resolvedVulns = getResolvedVulnerabilities(changes) | ||
|
|
||
| expect(resolvedVulns).toHaveLength(0) | ||
| }) | ||
|
|
||
| test('ignores added packages with vulnerabilities', () => { | ||
| const changes: Changes = [addedChange] | ||
|
|
||
| const resolvedVulns = getResolvedVulnerabilities(changes) | ||
|
|
||
| expect(resolvedVulns).toHaveLength(0) | ||
| }) | ||
|
|
||
| test('handles empty changes array', () => { | ||
| const changes: Changes = [] | ||
|
|
||
| const resolvedVulns = getResolvedVulnerabilities(changes) | ||
|
|
||
| expect(resolvedVulns).toHaveLength(0) | ||
| }) |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
README documents a new
resolved-vulnerabilitiesaction output, butaction.ymldoes not declare it underoutputs. For GitHub Actions consumers and Marketplace docs, outputs should be listed inaction.ymlas well.