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

Add exemptions to config #204

Merged
merged 10 commits into from
Oct 23, 2019
Merged

Add exemptions to config #204

merged 10 commits into from
Oct 23, 2019

Conversation

rbren
Copy link
Contributor

@rbren rbren commented Sep 13, 2019

No description provided.

@codecov
Copy link

codecov bot commented Oct 15, 2019

Codecov Report

Merging #204 into master will decrease coverage by 1.84%.
The diff coverage is 86.25%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #204      +/-   ##
=========================================
- Coverage   81.15%   79.3%   -1.85%     
=========================================
  Files          11      12       +1     
  Lines         711     749      +38     
=========================================
+ Hits          577     594      +17     
- Misses        107     130      +23     
+ Partials       27      25       -2
Impacted Files Coverage Δ
pkg/config/config.go 72% <ø> (ø) ⬆️
pkg/config/ids.go 0% <0%> (ø)
pkg/config/exemptions.go 0% <0%> (ø)
pkg/validator/pod.go 100% <100%> (ø) ⬆️
pkg/validator/controller.go 88.88% <100%> (ø) ⬆️
pkg/validator/container.go 94.84% <98.91%> (+0.42%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b172f61...81d44f1. Read the comment docs.

@rbren
Copy link
Contributor Author

rbren commented Oct 15, 2019

Screen Shot 2019-10-15 at 10 01 08 AM

@rbren rbren marked this pull request as ready for review October 15, 2019 14:23
@endzyme
Copy link
Contributor

endzyme commented Oct 23, 2019

Initial testing

Tested:

  • Ignore all errors for all scanned deployments (results in 100% score) (seems fine)
  • Using with examples/config-full.yaml and got very weird results (see Screenshot
    ) (bug?) (found the issue, full isn't setup to scan any deployment controllers, thus no checks are run)
  • Tried to figure out how to exclude capabilities individually (can't right now) but wasn't immediately clear how to look up the rule names
  • Tested invalid configuration for exemptions (tried a non-valid rule name but didn't fail as I might expect) - accidentally had a typo in a rule name and it just skips over it

Initial thoughts: Looks like maybe the reflection should have the context of the "group" since it is using the `json:"<name>"` as the name of the rule. I think you might accidentally exempt something if there happened to be a duplicate name in the json formatting options.

Example:

type Configuration struct {
...
	Security           Security              `json:"security"`
	AnotherThing       TheThing              `json:"theThing"`
	Exemptions         []Exemption           `json:"exemptions"`
...
}

type Security struct {
...
	Capabilities SecurityCapabilities `json:"capabilities"`
...
}

type AnotherThing struct {
...
	Capabilities []string `json:"capabilities"`
...
}
---------

Coupled with:

exemptions:
- controllerNames:
  - some-controller-name-here
  rules:
  - capabilities

This would accidentally exclude both the "security" context group as well as the AnotherThing context group. (if i'm reading the code right).

Copy link
Contributor

@endzyme endzyme left a comment

Choose a reason for hiding this comment

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

Overall this is definitely a huge +1 - some stuff to chat about in the future but for now this seems to satisfy the need, assuming we're ok with the accidental exemption issue noted in my previous comment.

@rbren
Copy link
Contributor Author

rbren commented Oct 23, 2019

Good points! Thanks for the review. Can definitely try and hit some of these (esp failing on invalid names) in a future PR.

@rbren rbren merged commit 2b15f11 into master Oct 23, 2019
@delete-merged-branch delete-merged-branch bot deleted the rb/exemption-profiles branch October 23, 2019 21:14
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.

3 participants