-
Notifications
You must be signed in to change notification settings - Fork 18
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
add organization ID check from JWT token for internal rules #85
add organization ID check from JWT token for internal rules #85
Conversation
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.
LGTM, just hope the token is not sensitive.
content/parsing.go
Outdated
|
||
for _, ruleIDPart := range splitRuleID { | ||
if ruleIDPart == internalRuleStr { | ||
isInternal = true |
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'd just return true here, but it's a nitpick :)
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.
Looks great! Thanks :)
Codecov Report
@@ Coverage Diff @@
## master #85 +/- ##
==========================================
+ Coverage 42.09% 48.73% +6.63%
==========================================
Files 11 11
Lines 867 911 +44
==========================================
+ Hits 365 444 +79
+ Misses 462 413 -49
- Partials 40 54 +14
Continue to review full report at Codecov.
|
@@ -59,6 +59,15 @@ func (server HTTPServer) getContentForRule(writer http.ResponseWriter, request * | |||
return | |||
} | |||
|
|||
// check for internal rule permissions | |||
if internal := content.IsRuleInternal(ruleID); internal == true { |
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.
internal == true
=> internal
Just a nitpick
// check for internal rule permissions | ||
if internal := content.IsRuleInternal(ruleID); internal == true { | ||
ok := server.checkInternalRulePermissions(writer, request) | ||
if ok != true { |
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.
ok != true
=> !ok
RuleContentInternal1 = ics_content.RuleContent{ | ||
Summary: testdata.Rule1.Summary, | ||
Reason: testdata.Rule1.Reason, | ||
Resolution: testdata.Rule1.Resolution, | ||
MoreInfo: testdata.Rule1.MoreInfo, | ||
Plugin: ics_content.RulePluginInfo{ | ||
Name: testdata.Rule1.Name, | ||
NodeID: "", | ||
ProductCode: "", | ||
PythonModule: internalTestRuleModule, | ||
}, | ||
ErrorKeys: map[string]ics_content.RuleErrorKeyContent{ | ||
"ek1": { | ||
Generic: testdata.RuleErrorKey1.Generic, | ||
Metadata: ics_content.ErrorKeyMetadata{ | ||
Condition: testdata.RuleErrorKey1.Condition, | ||
Description: testdata.RuleErrorKey1.Description, | ||
Impact: testdata.ImpactIntToStr[testdata.RuleErrorKey1.Impact], | ||
Likelihood: testdata.RuleErrorKey1.Likelihood, | ||
PublishDate: testdata.RuleErrorKey1.PublishDate.UTC().Format(time.RFC3339), | ||
Tags: testdata.RuleErrorKey1.Tags, | ||
Status: "active", | ||
}, | ||
}, | ||
}, | ||
} |
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.
Move this definition to testdata
package in insights-results-aggregator-data
repository, but it can be done later
Description
This adds a security check for internal rules based on organization ID
Fixes #76
Blocks RedHatInsights/insights-content-service#97
Blocked by https://github.com/RedHatInsights/e2e-deploy/pull/1923
Type of change
Testing steps
Modified requests to contain diffferent org_ids to test manually