Skip to content
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

Show vulnerabities and license information on the job summary. #181

Merged
merged 5 commits into from Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -4,8 +4,13 @@ This action scans your pull requests for dependency changes and will raise an er

The action is available for all public repositories, as well as private repositories that have GitHub Advanced Security licensed.

You can see the results on the job logs

<img width="854" alt="Screen Shot 2022-03-31 at 1 10 51 PM" src="https://user-images.githubusercontent.com/2161/161042286-b22d7dd3-13cb-458d-8744-ce70ed9bf562.png">

or on the job summary

<img src="https://user-images.githubusercontent.com/7847935/182871416-50332bbb-b279-4621-a136-ca72a4314301.png">

## Installation

Expand Down Expand Up @@ -58,6 +63,7 @@ jobs:
```

## Configuration

You can pass additional options to the Dependency Review
Action using your workflow file. Here's an example workflow with
all the possible configurations:
Expand Down Expand Up @@ -159,4 +165,5 @@ We are grateful for any contributions made to this project.
Please read [CONTRIBUTING.MD](https://github.com/actions/dependency-review-action/blob/main/CONTRIBUTING.md) to get started.

## License

This project is released under the [MIT License](https://github.com/actions/dependency-review-action/blob/main/LICENSE).
171 changes: 164 additions & 7 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

30 changes: 20 additions & 10 deletions src/main.ts
Expand Up @@ -7,6 +7,7 @@ import {Change, PullRequestSchema, Severity} from './schemas'
import {readConfig} from '../src/config'
import {filterChangesBySeverity} from '../src/filter'
import {getDeniedLicenseChanges} from './licenses'
import * as summary from './summary'

async function run(): Promise<void> {
try {
Expand Down Expand Up @@ -36,34 +37,41 @@ async function run(): Promise<void> {
deny: config.deny_licenses
}

const filteredChanges = filterChangesBySeverity(
const addedChanges = filterChangesBySeverity(
minSeverity as Severity,
changes
)

for (const change of filteredChanges) {
if (
).filter(
change =>
change.change_type === 'added' &&
change.vulnerabilities !== undefined &&
change.vulnerabilities.length > 0
) {
printChangeVulnerabilities(change)
failed = true
}
}
)

const [licenseErrors, unknownLicenses] = getDeniedLicenseChanges(
changes,
licenses
)

summary.addSummaryToSummary(addedChanges, licenseErrors, unknownLicenses)

if (addedChanges.length > 0) {
for (const change of addedChanges) {
printChangeVulnerabilities(change)
}
failed = true
}

summary.addChangeVulnerabilitiesToSummary(addedChanges, minSeverity || '')

if (licenseErrors.length > 0) {
printLicensesError(licenseErrors)
core.setFailed('Dependency review detected incompatible licenses.')
}

printNullLicenses(unknownLicenses)

summary.addLicensesToSummary(licenseErrors, unknownLicenses, config)

if (failed) {
core.setFailed('Dependency review detected vulnerable packages.')
} else {
Expand All @@ -87,6 +95,8 @@ async function run(): Promise<void> {
core.setFailed('Unexpected fatal error')
}
}
} finally {
await core.summary.write()
}
}

Expand Down