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

No way to deny all licenses while allowing specific ones #101

Closed
tapanagupta opened this issue Jul 10, 2024 · 3 comments · Fixed by #123
Closed

No way to deny all licenses while allowing specific ones #101

tapanagupta opened this issue Jul 10, 2024 · 3 comments · Fixed by #123
Assignees
Labels
bug Something isn't working

Comments

@tapanagupta
Copy link

Hello,

I'm trying to create a .grant.yaml config file that would achieve the following behavior: Deny all licenses except for the ones that have corresponding 'allow' rules in .grant.yaml.

First, I tried to specify allow rules for specific licenses, as shown below, expecting that non-matching licenses would be denied. However, the resulting output allowed ALL licenses.

#.grant.yaml
config: ".grant.yaml"
format: json # table, json
show-packages: true # show the packages which contain the licenses --show-packages
non-spdx: true # list only licenses that could not be matched to an SPDX identifier --non-spdx
osi-approved: true # highlight licenses that are not OSI approved --osi-approved
rules: 
    - pattern: "LGPL"
      name: "allow-lgpl"
      mode: "allow"
      reason: "LGPL is good."

Next, I tried to specify a 'deny all' rule alongside the allow rule, but this time ALL licenses were denied.

#.grant.yaml
config: ".grant.yaml"
format: json # table, json
show-packages: true # show the packages which contain the licenses --show-packages
non-spdx: true # list only licenses that could not be matched to an SPDX identifier --non-spdx
osi-approved: true # highlight licenses that are not OSI approved --osi-approved
rules:
    - pattern: "LGPL"
      name: "allow-lgpl"
      mode: "allow"
      reason: "LGPL is good."
    - pattern: "**"
      name: "deny-all"
      mode: "deny"
      reason: "Deny everything by default."

Below is the command used for running the tests (SBOM from Syft fed as input):

grant check -o json syft.spdx-json.json | jq > grant.json

In general, from my testing, I observed that when Grant is supplied with a config file, it allows all licenses by default, but when not supplied with a config file, it denies all licenses by default.

From the Grant documentation:

Grant can be used to deny specific licenses while allowing all others. It can also be used to allow specific licenses, denying all others.

Question is, how do I achieve the latter, i.e. allow specific licenses while denying all others? Thank you for looking into this issue.

@tapanagupta tapanagupta changed the title No way to deny all licenses while only allowing specific ones No way to deny all licenses while allowing specific ones Jul 10, 2024
@spiffcs
Copy link
Collaborator

spiffcs commented Jul 11, 2024

Thanks @tapanagupta! I'll take a look at this right away because this is definitely not behaving as expected. ** should be a valid rule - does * also fail for your as well?

Here is our integration test for denial on an empty config:
https://github.com/anchore/grant/blob/main/test/cli/check_test.go

I'll get this fleshed out with your case and a bit more cases so this feature is behaving as expected.

@spiffcs spiffcs added this to OSS Jul 11, 2024
@spiffcs spiffcs moved this to In Progress in OSS Jul 11, 2024
@spiffcs spiffcs self-assigned this Jul 11, 2024
@tapanagupta
Copy link
Author

Thanks for looking into this, @spiffcs! To answer your question, I ran a test using * instead of ** and got the same result.

Looking forward to further updates on this.

@spiffcs spiffcs added the bug Something isn't working label Jul 23, 2024
@willpxxr
Copy link

Looks like only denies have been implemented per

if rule.Mode != Deny {

There is also a comment above in the policy struct w/ a todo for that feature

// TODO: maybe there should be a strict option that denies all and then only allows what is explicitly allowed

So it looks like it's not possible to implement a deny by default and allow list licenses right now.

psududemike added a commit to psududemike/grant that referenced this issue Sep 10, 2024
psududemike added a commit to psududemike/grant that referenced this issue Sep 10, 2024
psududemike added a commit to psududemike/grant that referenced this issue Sep 10, 2024
psududemike added a commit to psududemike/grant that referenced this issue Sep 10, 2024
Signed-off-by: Michael Frederick <mike.frederick@cesium.com>
psududemike added a commit to psududemike/grant that referenced this issue Sep 10, 2024
Signed-off-by: Mike Frederick <mike.frederick@cesium.com>
spiffcs added a commit that referenced this issue Oct 3, 2024
Signed-off-by: Mike Frederick <mike.frederick@cesium.com>
Co-authored-by: Christopher Angelo Phillips <32073428+spiffcs@users.noreply.github.com>
@github-project-automation github-project-automation bot moved this from Stalled to Done in OSS Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants