trivy icon indicating copy to clipboard operation
trivy copied to clipboard

feat(docs): Add examples as unit tests

Open simar7 opened this issue 2 years ago • 5 comments

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

simar7 avatar May 09 '23 21:05 simar7

There are Rego policies for testing here. We can replace them with examples or use them in the unit tests additionally.

knqyf263 avatar May 10 '23 09:05 knqyf263

Also few more here https://github.com/aquasecurity/trivy/tree/b43b19ba54cbf30adfaf98febccef033701a1df3/examples/misconf/custom-policy

simar7 avatar May 11 '23 22:05 simar7

This issue is stale because it has been labeled with inactivity.

github-actions[bot] avatar Sep 24 '23 00:09 github-actions[bot]

@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?

nikpivkin avatar Jul 26 '24 07:07 nikpivkin

@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.

simar7 avatar Aug 06 '24 23:08 simar7