Skip to content

chore: pass schemas to opa test #386

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

Merged
merged 3 commits into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
bundle.tar.gz
opa
schemas

.idea
.vscode
Expand Down
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ test:
test-integration:
go test -v -timeout 5m -tags=integration ./integration/...

.PHONY: download-schemas
download-schemas:
@schemas_path=schemas ; \
base_url=https://raw.githubusercontent.com/aquasecurity/trivy/main/pkg/iac/rego/schemas ; \
mkdir -p $$schemas_path ; \
for file in cloud.json dockerfile.json kubernetes.json ; do \
wget -q -O $$schemas_path/$$file $$base_url/$$file ; \
done

.PHONY: rego
rego: fmt-rego check-rego lint-rego test-rego docs

Expand All @@ -29,8 +38,8 @@ test-rego:
go run ./cmd/opa test --explain=fails lib/ checks/ examples/ --ignore '*.yaml'

.PHONY: check-rego
check-rego:
@go run ./cmd/opa check lib checks --v0-v1 --strict
check-rego: download-schemas
@go run ./cmd/opa check lib checks --v0-v1 --strict -s schemas

.PHONY: lint-rego
lint-rego: check-rego
Expand Down
2 changes: 0 additions & 2 deletions examples/serverless/python2.rego
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
# Ensure that you use a supported runtime version, such as Python 3.x,
# to maintain the security and reliability of your serverless application.
# scope: package
# schemas:
# - input: schema["yaml"]
# related_resources:
# - https://www.python.org/doc/sunset-python-2/
# custom:
Expand Down
2 changes: 0 additions & 2 deletions examples/terraform-plan/asg_capacity.rego
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#
# Ensure that the desired capacity for Auto Scaling Groups is set to a reasonable value, typically within limits defined by your organization.
# scope: package
# schemas:
# - input: schema["json"]
# related_resources:
# - https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/autoscaling_group
# custom:
Expand Down