-
Couldn't load subscription status.
- Fork 1k
fix: allow combining include and exclude #407
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
fix: allow combining include and exclude #407
Conversation
Signed-off-by: wilmardo <info@wilmardenouden.nl>
|
Thanks @wilmardo for the PR, looks interesting and I'll have look asap. |
|
Looks good! Could you update the README with a couple examples as well? |
Signed-off-by: wilmardo <info@wilmardenouden.nl>
|
I made a little improvement to make it a bit more versatile . The sed is now: The change is that it does not match on # sed -ne "/cis() {/,/}/{/{/d; /}/d; p}" functions_lib.sh
host_configuration
docker_daemon_configuration
docker_daemon_files
container_images
container_runtime
docker_security_operations
docker_swarm_configuration
docker_enterprise_configurationSo a command like this works now: I will add a commit for some documentation :) |
|
Awesome! |
Signed-off-by: wilmardo <info@wilmardenouden.nl>
Signed-off-by: wilmardo <info@wilmardenouden.nl>
|
Added the examples in the readme but while writing I found another case which isn't working yet.
I will refactor the logic a bit more, decided against it while starting this change. But now I will make the deepdive since it will simplify the logic. Set the title to WIP until I implented this :) |
|
Great! Thanks for doing this :) |
Signed-off-by: wilmardo <info@wilmardenouden.nl>
|
Reworked the include exclude logic so now all combinations should be possible:
Added them to the readme. I tried my best to test this thoroughly but I could have easily missed something due the fact that is it my own code ;) /ready_for_review 🎉 |
|
@konstruktoid PTAL, no need to rush just bringing this to your attention again :) Best of wishes for 2020! 🎆 |
|
@wilmardo no worries, I just wondered, see comment above, why the export was removed. I believe it might be necessary on some distributions. |
Signed-off-by: wilmardo <info@wilmardenouden.nl>
|
@konstruktoid Good catch, had an issue while testing and accidentally committed the change. Can't remember what the issue was and it seems to work fine with the PATH as it was. |
|
Thanks alot @wilmardo! |
Reason for change
For a CI pipeline I was trying to scan just container images but without the healtcheck and docker trust check:
./docker-bench-security.sh -i test -c container_images -e check_4_5,check_4_6This wasn't yet implemented so I took a stab at it.
Technical explaining
The magic is in the sed:
$iis the checkname, for example container_images so it matches oncontainer_images() {until}This results in:
But I am just interested in the checks so just print the checks:
And then I just did the same grep trick as checkexclude to exlude test.