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(schema): Add schema generation #32

Merged
merged 10 commits into from
Oct 25, 2023
Merged

feat(schema): Add schema generation #32

merged 10 commits into from
Oct 25, 2023

Conversation

simar7
Copy link
Member

@simar7 simar7 commented Oct 16, 2023

No description provided.


b := newBuilder()

inputValue := reflect.ValueOf(state.State{})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nikpivkin state.State{} comes from defsec today and is shared across trivy-iac and trivy-aws as well. It's one of those dependencies which is hard to get away from as it's shared between all of the components.

"github.com/aquasecurity/trivy-policies/pkg/types"
)

func Register(rule scan.Rule, f scan.CheckFunc) types.RegisteredRule {
Copy link
Collaborator

@nikpivkin nikpivkin Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is used to register Go rules. For example, https://github.com/aquasecurity/trivy-policies/blob/main/rules/cloud/policies/aws/s3/block_public_acls.go#L11. Maybe we should make Go rules in trivy-policies public and register them with trivy-iac? Or what should we do?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should make Go rules in trivy-policies public and register them with trivy-iac?

Yes that's the idea. I was planning for that happen via

"github.com/aquasecurity/trivy-iac/pkg/rules"
where the rules are imported.

But it seems a couple of tests are failing at the moment. Upon investigating them it seems they don't seem to be registered Go rules, so an import somewhere is missing (which would trigger the registration of Go rules).

Copy link
Collaborator

@nikpivkin nikpivkin Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simar7 When importing rules, they are saved in the rules registry, which is located in trivy-policies. Therefore, importing rules is not enough.

@nikpivkin
Copy link
Collaborator

nikpivkin commented Oct 18, 2023

@simar7
We should update the import of embed and rego packages.

"github.com/aquasecurity/trivy-policies/pkg/rego"
"github.com/aquasecurity/trivy-policies/pkg/rego/embed"

* bump defsec and trivy-policies

* test: use embedded FS

* refactor: use embedded FS to generate documentation

* chore: bump defsec and trivy-policies

* refactor: use registered rules as is
@simar7 simar7 marked this pull request as ready for review October 24, 2023 23:43
Copy link
Collaborator

@nikpivkin nikpivkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with Trivy.

@simar7 simar7 merged commit 00033a7 into main Oct 25, 2023
3 checks passed
@simar7 simar7 deleted the schema-gen branch October 25, 2023 20:12
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