Skip to content

Migrate test policies to Rego v1#6462

Merged
evankanderson merged 2 commits into
mindersec:mainfrom
dakshhhhh16:rego-v1-test-policy-migration
May 26, 2026
Merged

Migrate test policies to Rego v1#6462
evankanderson merged 2 commits into
mindersec:mainfrom
dakshhhhh16:rego-v1-test-policy-migration

Conversation

@dakshhhhh16

@dakshhhhh16 dakshhhhh16 commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR migrates Minder's embedded Rego test fixtures, sample rule YAML, and Rego docs examples to Rego v1 syntax as part of Phase 2 of #5262. (Parent issue)
Child issue #6463

The production evaluator already supports Rego version detection. This change moves the policy corpus we own toward the Rego v1 baseline by replacing v0 syntax and future.keywords examples with import rego.v1.

What changed

  • Migrated embedded Rego snippets in evaluator and rtengine tests to Rego v1 syntax.
  • Updated Minder sample/fixture rule YAML and quickstart policy YAML to import rego.v1.
  • Updated Rego documentation snippets to stop recommending future.keywords imports.
  • Refreshed the affected mindpak fixture hash after the YAML policy migration.

Validation

  • git diff --check
  • go test ./pkg/mindpak ./internal/engine/eval/... ./pkg/engine/v1/rtengine ./pkg/api/protobuf/go/minder/v1 ./cmd/cli/app/ruletype ./cmd/cli/app/quickstart
  • go test ./... was also attempted. It reaches unrelated failures in internal/engine/actions/remediate/pull_request where tests cannot create a temporary git repository in this local environment.

Notes for reviewers

This is intended to be a syntax-only migration. The remaining v0 snippets in internal/engine/eval/rego/version_test.go are deliberate detector coverage and do not use future.keywords.

@dakshhhhh16
dakshhhhh16 requested a review from a team as a code owner May 19, 2026 09:05
@dakshhhhh16
dakshhhhh16 force-pushed the rego-v1-test-policy-migration branch from 6a2f24a to 19d8a53 Compare May 19, 2026 09:06
@coveralls

coveralls commented May 19, 2026

Copy link
Copy Markdown

Coverage Status

Coverage is 60.449%dakshhhhh16:rego-v1-test-policy-migration into mindersec:main. No base build found for mindersec:main.

@dakshhhhh16
dakshhhhh16 force-pushed the rego-v1-test-policy-migration branch from 19d8a53 to 88c74c3 Compare May 26, 2026 09:12
@dakshhhhh16

Copy link
Copy Markdown
Contributor Author

@JAORMX , @evankanderson
You can have a look into this now!

evankanderson
evankanderson previously approved these changes May 26, 2026

@evankanderson evankanderson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry for the delayed review, and thanks for cleaning these up! A couple questions before I merge.

package minder

import future.keywords.if
import rego.v1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need import rego.v1 with the detection we've implemented? (I think it's fine to leave it in, just curious.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yepp!

Comment on lines 53 to 63
name: "v1 policy with keyword syntax",
def: `
package minder

import future.keywords.if
import future.keywords.in
import rego.v1

default allow = false
default allow := false

allow if {
"admin" in input.profile.roles
}`,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Doesn't this change this test into the next case?
(I think you want to revert this specific test change)

It would also be good to have a test which uses the v1 syntax but does not import rego.v1 explicitly, to show whether that is accepted or an error.

Signed-off-by: dakshhhhh16 <daksh.pathak.ug24@nsut.ac.in>
@dakshhhhh16

dakshhhhh16 commented May 26, 2026

Copy link
Copy Markdown
Contributor Author

@evankanderson
Minor change done!

@evankanderson evankanderson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for adding the test that confirmed my behavior expectation. It's possible in the future I'll come in and remove some of these import rego.v1 lines since they aren't necessary (and may distract from the test), but this change seems fine for now.

@evankanderson
evankanderson merged commit c60cfa1 into mindersec:main May 26, 2026
28 checks passed
@dakshhhhh16

Copy link
Copy Markdown
Contributor Author

Thanks for adding the test that confirmed my behavior expectation. It's possible in the future I'll come in and remove some of these import rego.v1 lines since they aren't necessary (and may distract from the test), but this change seems fine for now.

Same here! I'll myself make these changes after all phases are complete. Will soon come up with the third phase pr.

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.

3 participants