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

feat(docs): Add examples as unit tests #4255

Open
simar7 opened this issue May 9, 2023 · 5 comments
Open

feat(docs): Add examples as unit tests #4255

simar7 opened this issue May 9, 2023 · 5 comments
Assignees
Labels
kind/documentation Categorizes issue or PR as related to documentation. scan/misconfiguration Issues relating to misconfiguration scanning
Milestone

Comments

@simar7
Copy link
Member

simar7 commented May 9, 2023

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 simar7 added the kind/documentation Categorizes issue or PR as related to documentation. label May 9, 2023
simar7 added a commit that referenced this issue May 9, 2023
Partially addresses: #4255

Signed-off-by: Simar <simar@linux.com>
@knqyf263
Copy link
Collaborator

knqyf263 commented May 10, 2023

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

@simar7
Copy link
Member Author

simar7 commented May 11, 2023

@simar7 simar7 added the scan/misconfiguration Issues relating to misconfiguration scanning label Jun 13, 2023
@github-actions
Copy link

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

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and will be auto-closed. label Sep 24, 2023
@simar7 simar7 removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and will be auto-closed. label Sep 25, 2023
@knqyf263 knqyf263 added the priority/backlog Higher priority than priority/awaiting-more-evidence. label Sep 26, 2023
@nikpivkin
Copy link
Contributor

@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
Copy link
Member Author

simar7 commented Aug 6, 2024

@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 simar7 assigned simar7 and unassigned AnaisUrlichs Oct 24, 2024
@simar7 simar7 removed the priority/backlog Higher priority than priority/awaiting-more-evidence. label Oct 24, 2024
@simar7 simar7 added this to the v0.58.0 milestone Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/documentation Categorizes issue or PR as related to documentation. scan/misconfiguration Issues relating to misconfiguration scanning
Projects
Status: No status
Development

No branches or pull requests

4 participants