feat(docs): Add examples as unit tests
Some of the examples that used to exist as part of markdown documents were either outdated or not maintained actively. One such example is here: https://aquasecurity.github.io/trivy/v0.41/docs/scanner/misconfiguration/custom/examples/
@knqyf263 suggested that we can make them into unit tests as such: https://github.com/aquasecurity/trivy/blob/55fb723a6e00cc36d89a548ab0c7b31544aa6044/integration/module_test.go
There are Rego policies for testing here. We can replace them with examples or use them in the unit tests additionally.
Also few more here https://github.com/aquasecurity/trivy/tree/b43b19ba54cbf30adfaf98febccef033701a1df3/examples/misconf/custom-policy
This issue is stale because it has been labeled with inactivity.
@simar7 Is it still relevant? How will we keep the examples in the documentation up to date?
How about adding tests for good/bad examples for each check in the trivy-checks repository?
@simar7 Is it still relevant? How will we keep the examples in the documentation up to date?
Yes that's why we want to implement them as unit tests so we don't have to continually keep the documentation up to date.
How about adding tests for good/bad examples for each check in the trivy-checks repository?
You can see the example I shared here https://github.com/aquasecurity/trivy/tree/b43b19ba54cbf30adfaf98febccef033701a1df3/examples/misconf/custom-policy and https://github.com/aquasecurity/trivy/tree/2f318ce97d6bd058894e35a413c001e647681ae1/pkg/fanal/artifact/local/testdata/misconfig
we could reuse these assuming most of them are still relevant as they pertain to current checks.