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

chore: store examples in YAML #271

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nikpivkin
Copy link
Contributor

@nikpivkin nikpivkin commented Oct 14, 2024

In this PR:

  • Terraform and CloudFormation examples moved from cf.go and tf.go to yaml,
  • all checks now refer to the yaml examples
  • added command for formatting examples

Although all the examples for a single check are in a single file, we need to reference it from multiple check fields. I suggest adding a new examples field that will point to a single file, while maintaining support for the current method of referencing examples for backwards compatibility.

Old example files will be deleted in another PR as they are still referenced by Go checks.

@nikpivkin nikpivkin force-pushed the examples-yaml branch 2 times, most recently from c6aebb2 to 9c789af Compare October 15, 2024 10:22
@nikpivkin
Copy link
Contributor Author

Will be ready for review after the release of Trivy v0.57

@nikpivkin nikpivkin changed the title chore: use examples as YAML chore: store examples in YAML Oct 16, 2024
Signed-off-by: Nikita Pivkin <[email protected]>
@nikpivkin nikpivkin marked this pull request as ready for review November 6, 2024 09:15
@simar7
Copy link
Member

simar7 commented Nov 7, 2024

One thing to keep in mind with the examples is the avd generator. I believe it uses the go files as well. Could you confirm that @nikpivkin?

@nikpivkin
Copy link
Contributor Author

@simar7 I'll check, but as far as I remember avd-generator uses generated md files.

@nikpivkin
Copy link
Contributor Author

avd-generator uses only generated .md files https://github.com/aquasecurity/avd-generator/blob/main/docGen/defsec.go#L151-L161

@nikpivkin
Copy link
Contributor Author

Maybe we should change the file schema to the following?

id: avdid
examples:
   terraform:
   cloudformation:

This will allow us to associate examples and checks without using the trivy and trivy-checks packages to run the tests. To do this now, we need to load all the checks and then load all the examples based on the check metadata.

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.

2 participants