Skip to content

feat: extend devcontainer to include OPA provider test content#540

Open
hbraswelrh wants to merge 7 commits into
complytime:mainfrom
hbraswelrh:opsx/opa-devcontainer-content
Open

feat: extend devcontainer to include OPA provider test content#540
hbraswelrh wants to merge 7 commits into
complytime:mainfrom
hbraswelrh:opsx/opa-devcontainer-content

Conversation

@hbraswelrh
Copy link
Copy Markdown
Member

@hbraswelrh hbraswelrh commented Jun 3, 2026

Summary

Add OPA provider test content to the devcontainer environment,
enabling end-to-end get -> generate -> scan testing with
the OPA provider alongside the existing Ampel workflow.

Codespace Testing

complyctl list once complyctl get
Screenshot 2026-06-03 at 11 36 19 AM

complyctl generate is still looking for the target variable for the opa_bundle_ref which will be addressed in a separate PR.

Related Issues

Closes #539

  • Opening an additional PR in the complytime-providers repo to address the opa_bundle_ref requirement that needs to be bypassed by the complypak configuration.

Dependencies

  • PR feat: add complypack pull support #536 (complypack pull support) — required for
    complypacks: config schema, addComplypackArtifact() in
    the mock registry, and ComplypackContentPath proto field
  • Companion PR in complytime-providers — OPA provider
    update to consume ComplypackContentPath as an alternative
    to opa_bundle_ref + conftest pull

Implementation begins after PR #536 merges. The complyctl-side
changes (testdata + config) are independently mergeable — they
are inert until the provider supports ComplypackContentPath.

Planned Changes

File Change
cmd/mock-oci-registry/testdata/ New OPA catalog.yaml + policy.yaml with executor.id: opa
cmd/mock-oci-registry/main.go Seed OPA policy and complypack in seedDefaults()
tests/cross-repo/testdata/complytime.yaml OPA policy-id + complypacks entry
.devcontainer/scripts/post-create.sh OPA granular policy setup (if needed)
docs/TESTING_ENVIRONMENT.md OPA provider command examples

End-to-End Flow

cd ~/test-workspace

# Fetch policies + complypacks from mock registry
complyctl get

# Generate with OPA provider (reads complypack content path)
complyctl generate --policy-id test-opa-bp

# Scan and display results
complyctl scan --policy-id test-opa-bp

OpenSpec Artifacts

Spec artifacts at openspec/changes/opa-devcontainer-content/
(proposal, design, specs/opa-test-content, tasks).

@hbraswelrh hbraswelrh requested a review from a team as a code owner June 3, 2026 14:25
@hbraswelrh hbraswelrh added the enhancement New feature or request label Jun 3, 2026
@hbraswelrh hbraswelrh force-pushed the opsx/opa-devcontainer-content branch from b5f6f44 to e5b7460 Compare June 3, 2026 14:44
Comment thread tests/cross-repo/testdata/test-deployment.yaml Fixed
Comment thread tests/cross-repo/testdata/test-deployment.yaml Fixed
Comment thread tests/cross-repo/testdata/test-deployment.yaml Fixed
Comment thread tests/cross-repo/testdata/test-deployment.yaml Fixed
Comment thread tests/cross-repo/testdata/test-deployment.yaml Fixed
Comment thread tests/cross-repo/testdata/test-deployment.yaml Fixed
Comment thread tests/cross-repo/testdata/test-deployment.yaml Fixed
Comment thread tests/cross-repo/testdata/test-deployment.yaml Fixed
Comment thread tests/cross-repo/testdata/test-deployment.yaml Fixed
Comment thread tests/cross-repo/testdata/test-deployment.yaml Fixed
gvauter
gvauter previously approved these changes Jun 3, 2026
Copy link
Copy Markdown
Member

@gvauter gvauter left a comment

Choose a reason for hiding this comment

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

LGTM — clean PR with complete spec artifacts, appropriate test coverage, all CI green, and no security or constitutional concerns. Independently mergeable ahead of the companion provider PR.

This review was generated by /review-pr (AI-assisted).

Comment thread cmd/mock-oci-registry/main_test.go Outdated
Add spec artifacts for extending the devcontainer environment
to include testable OPA provider content (issue complytime#535). Covers
embedded OPA Gemara testdata, complypack artifact seeding, and
workspace configuration for end-to-end get -> generate -> scan
testing with the OPA provider.

Depends-on: complytime#536 (complypack pull support)
Closes: complytime#535
Add OPA Gemara testdata, Rego policies, and workspace config for
end-to-end OPA provider testing in the devcontainer.

Mock registry:
- test-opa-catalog.yaml: container security controls (run-as-
  nonroot, resource-limits) with OPA-evaluable requirements
- test-opa-policy.yaml: policy with executor.id: opa and two
  assessment plans
- seedDefaults() seeds policies/test-opa-policy alongside the
  existing Ampel policy

OPA complypack content (for PR complytime#536 integration):
- run_as_nonroot.rego: checks securityContext.runAsNonRoot
- resource_limits.rego: checks container resource limits
- complytime-mapping.json: maps requirement IDs to Rego
  namespaces

Workspace:
- complytime.yaml: test-opa-bp policy-id + test-k8s-deployment
  target with input variable
- test-deployment.yaml: sample K8s deployment for OPA evaluation
- post-create.sh: copies test deployment input to workspace

Complypack tasks (2.3, 2.4, 3.2) are blocked on PR complytime#536 which
adds addComplypackArtifact() and complypacks: config schema.

Closes: complytime#535
Add OPA complypack seeding now that PR complytime#536 has merged:

- Embed testdata/opa-complypack/ files (Rego + mapping) via
  go:embed directive
- Add buildTarGzFromFS() to create multi-file tar.gz from
  embedded filesystem at startup
- Seed complypacks/test-opa-complypack with evaluator-id: opa
  via addComplypackArtifact() in seedDefaults()
- Add complypacks entry to complytime.yaml pointing at
  localhost:8765/complypacks/test-opa-complypack
Move the OPA test deployment YAML from committed testdata to
inline generation in post-create.sh. Shipping a Kubernetes
Deployment manifest in the repo triggers GitHub Advanced
Security (Trivy) false positives for missing security fields.

The post-create script now generates test-deployment.yaml
directly in the test workspace at container setup time.
Add metadata.applicability-groups with k8s-deployments entry
and reference it from assessment-requirement applicability
fields. The CUE schema requires applicability-groups when
controls are defined, and applicability values must reference
valid applicability-group IDs.

Also reorder fields to match the canonical layout (metadata
before groups before controls).
- Add CHANGELOG.md entry for OPA devcontainer content
- Add conftest to Binaries table in TESTING_ENVIRONMENT.md
- Replace string concatenation with path.Join in buildTarGzFromFS
  (convention SC-003 compliance for embed.FS paths)
- Add unit tests: buildTarGzFromFS, buildDummyTarGz, seedDefaults
  repository verification (4 tests, all passing)
The OPA provider's MappingEntry struct uses JSON tags 'id' (Rego
namespace) and 'requirement_id' (underscore). The testdata had
'requirement-id' (hyphen) and 'namespace', which unmarshal as
empty strings and fail validation.

Also add the 'version' field expected by MappingFile.
@hbraswelrh hbraswelrh force-pushed the opsx/opa-devcontainer-content branch from 7a7151f to fce72a6 Compare June 3, 2026 19:29
@hbraswelrh hbraswelrh requested a review from gvauter June 3, 2026 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: update post-create.sh script to look for generated rego files

3 participants