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

Filter blocking dependency changes by scopes #243

Merged
merged 8 commits into from Sep 20, 2022

Conversation

sarahkemi
Copy link
Contributor

The dependency review API now returns a dependency's scope in the endpoint response!

{
    "change_type": "added",
    "manifest": "pom.xml",
    "ecosystem": "maven",
    "name": "org.postgresql:postgresql",
    "version": "42.3.2",
    "package_url": "pkg:maven/org.postgresql/postgresql@42.3.2",
    "license": "BSD-2-Clause",
    "source_repository_url": "https://github.com/pgjdbc/pgjdbc",
    "scope": "runtime",
}

Let's utilize it to allow users of the action to filter out which types of dependencies they actually want to block on. For example, users will now be able to decide that they don't want to block a PR on a vulnerability if it's on a dependency only utilized in development.

To create this functionality I added a new fail-on-scopes configuration input that can take a list of the 3 possible scope types (unknown, runtime, and development). We then parse the list and run the dependency changes from the API through filterChangesByScopesthat will return only changes that that are in the specified scopes. We then run through the standard filtering of severity and license validation.

To ensure that we don't break the action for GHES users who won't have access to the current REST API version with scope just yet, we treat all their dependency changes as runtime and detect vulns/licenses on them. This emulates the preexisting behavior.

@sarahkemi sarahkemi marked this pull request as ready for review September 19, 2022 18:16
@sarahkemi sarahkemi requested a review from a team as a code owner September 19, 2022 18:16
Copy link
Contributor

@febuiles febuiles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great @sarahkemi! I've tested it with both runtime and runtime/development vulnerabilities (PR here) and everything works as expected.

Development Only:
Screenshot 2022-09-20 at 12 43 46

Development/Runtime:
Screenshot 2022-09-20 at 12 46 02

@sarahkemi sarahkemi merged commit 4300ce8 into main Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants