-
Notifications
You must be signed in to change notification settings - Fork 7
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
feature: add support for allowlists #123
Conversation
This adds supports for denying all packages, and only allow selected ones by implementing support for `mode: "allow"`. Such as: ``` rules: - pattern: "BSD-*" name: "bsd-allow" - pattern: "*" name: "default-deny-all" mode: "deny" ``` Signed-off-by: Mikail Kocak <[email protected]>
722d6d7
to
84db6a4
Compare
if !l.IsSPDX() && ec.CheckNonSPDX { | ||
if denied, rule := ec.Policy.IsDenied(l, pkg); denied { | ||
var reason Reason | ||
if rule != nil { | ||
reason = Reason{ | ||
Detail: ReasonLicenseDeniedPolicy, | ||
RuleName: rule.Name, | ||
} | ||
} | ||
return NewLicenseEvaluation(l, pkg, ec.Policy, []Reason{reason}, false) | ||
} | ||
} |
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.
If I'm not mistaken, the behavior was the same no matter whether it's SPDX or not here:
grant/grant/evalutation/license_evalutation.go
Lines 47 to 77 in 082dc48
if !l.IsSPDX() && ec.CheckNonSPDX { | |
if denied, rule := ec.Policy.IsDenied(l, pkg); denied { | |
var reason Reason | |
if rule != nil { | |
reason = Reason{ | |
Detail: ReasonLicenseDeniedPolicy, | |
RuleName: rule.Name, | |
} | |
} | |
return NewLicenseEvaluation(l, pkg, ec.Policy, []Reason{reason}, false) | |
} | |
} | |
if ec.OsiApproved && l.IsSPDX() { | |
if !l.IsOsiApproved { | |
return NewLicenseEvaluation(l, pkg, ec.Policy, []Reason{{ | |
Detail: ReasonLicenseDeniedOSI, | |
RuleName: RuleNameNotOSIApproved, | |
}}, false) | |
} | |
} | |
if denied, rule := ec.Policy.IsDenied(l, pkg); denied { | |
var reason Reason | |
if rule != nil { | |
reason = Reason{ | |
Detail: ReasonLicenseDeniedPolicy, | |
RuleName: rule.Name, | |
} | |
} | |
return NewLicenseEvaluation(l, pkg, ec.Policy, []Reason{reason}, false) | |
} |
I believe ec.CheckNonSPDX
should be passed to ec.Policy.IsDenied(l, pkg)
but I do not know what is the expected behavior. If indeed the code previous code was invalid, then it could be handled in another PR.
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.
I can take this on and move ec.CheckNonSPDX
into the ec.Policy.IsDenied
The previous code was invalid.
@NyanKiyoshi thank you so much for the PR - I'm working on getting #124 integrated and will then come back here, answer questions, and get this shaped up and ready for merge |
Signed-off-by: Christopher Angelo Phillips <[email protected]>
Cleaning up this PR and responding to @NyanKiyoshi questions and getting it incorporated into the next release. Thank you so so much @NyanKiyoshi for the contribution here |
Signed-off-by: Christopher Phillips <[email protected]>
Signed-off-by: Christopher Phillips <[email protected]>
Signed-off-by: Christopher Phillips <[email protected]>
Thank you @spiffcs! |
This adds supports for denying all packages, and only allow selected ones by implementing support for
mode: "allow"
.Fixes: #101
Such as:
Example
Config:
Results: