Skip to content

feat(evaluator): Cedar context entity for workload attributes (closes #103) - #105

Merged
scttfrdmn merged 2 commits into
mainfrom
feat/context-workload-entity
Jun 9, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
feat/context-workload-entity

Conversation

@scttfrdmn

Copy link
Copy Markdown
Collaborator

Closes #103. Relates to #102, #104. Phase-two Stream A consumer side of ADR 0001 — epic hub provabl/evidence#2 — after the merged producer re-points vet#9 and qualify#39.

What changes

attest's evaluator built types.Request{Principal, Action, Resource} with no Context, so Cedar policies could not reference context.* even though cedar-go v1.6.0 supports it. This wires the Context entity and reads vet's supply-chain posture into it — so policies can gate on context.workload.* alongside principal.* training.

Files

  • pkg/schema/types.go — WorkloadAttributes (slsa_level, sbom_present, cve_critical, cve_high, signed, artifact_hash); Go fields PascalCase, json tags snake_case matching vet's gate-result.json.
  • internal/workload/workload.go (new) — Load(dir) reads .vet/gate-result.json; absent → (nil,nil) (policies default-deny, like a missing principal attr); malformed → error. The single point mapping vet's JSON → attest's schema. No evidence-kernel dependency — attest reads the JSON artifact, it does not run the kernel.
  • internal/evaluator/evaluator.go — new buildContext builds a nested record-of-records from context.<group>.<attr> keys (reusing toValue) and sets cedarReq.Context. Generic over the middle segment, so a future context.platform.* (nitro, Inject nitro:// runtime attributes into Cedar context #104) needs zero evaluator change. Returns an empty (valid) Record when no context.* keys.
  • cmd/attest/main.go — attest evaluate gains --workload-dir (default .vet); injects context.workload.* (int64 slsa_level → Cedar Long).

Casing decision

Cedar keys are snake_case (context.workload.slsa_level) — consistent with every existing principal.* attribute and a zero-munge copy of vet's JSON tags. Note: the umbrella CLAUDE.md names these PascalCase; a companion umbrella PR corrects that doc + adds the ADR ephemeral-key paragraph.

#102 — satisfied by design (no code)

Producing tools (qualify, vet) appraise in-process with ephemeral keys and persist only lowered attributes (IAM tags / gate-result.json). There is no cross-process evidence bundle for attest to re-verify, and re-appraising already-appraised data under a fresh key adds ceremony with no new trust property. attest is the PDP; it consumes the lowered product. Documented in new docs/integrations/vet.md + the principal package doc. #102 closes as satisfied-by-design.

Verification

  • go build/vet/test ./... green.
  • New evaluator test: context.workload.slsa_level >= 2 policy → ALLOW@2 / DENY@1 / DENY-absent; plus a signed == true case and a buildContext nesting unit test.
  • Reader test: present / absent / malformed.
  • End-to-end: attest evaluate against a real .vet/gate-result.json → ALLOW at slsa_level 2, DENY at 1, DENY when .vet absent.

…103)

Phase-two Stream A (consumer side) of ADR 0001, after the merged producer
re-points vet#9 and qualify#39. attest's evaluator built a Cedar request with
no Context, so policies could not reference context.* even though cedar-go
supports it. This wires the Context entity and reads vet's supply-chain posture
into it, so policies can gate on context.workload.* alongside principal.* training.

- pkg/schema: add WorkloadAttributes (slsa_level, sbom_present, cve_critical,
  cve_high, signed, artifact_hash) — Go fields PascalCase, json tags snake_case
  matching vet's gate-result.json.
- internal/workload: Load(dir) reads .vet/gate-result.json into WorkloadAttributes;
  absent file -> (nil,nil) (policies default-deny, same as a missing principal
  attr); malformed -> error. The SINGLE point mapping vet's JSON fields to attest's
  schema — a vet field rename is a one-line fix here. No dependency on the evidence
  kernel: attest reads the JSON artifact, it does not run the kernel.
- internal/evaluator: new buildContext builds a nested record-of-records from
  context.<group>.<attr> keys (reusing toValue) and sets cedarReq.Context. Generic
  over the middle segment, so a future context.platform.* (nitro, #104) needs no
  evaluator change. Empty when no context.* keys (Cedar requires a valid Record).
- cmd/attest: 'attest evaluate' gains --workload-dir (default .vet); loads workload
  attrs and injects context.workload.* (int64 for slsa_level -> Cedar Long).
- Cedar attribute keys are snake_case (context.workload.slsa_level), consistent
  with principal.* and a zero-munge copy of vet's JSON tags.

#102 (resolver reads appraised attributes) is satisfied by design: producing tools
appraise in-process with ephemeral keys and persist only lowered attributes, so
there is no cross-process bundle for attest to re-verify. attest is the PDP and
consumes the lowered product. Documented in docs/integrations/vet.md and the
principal package doc.

Verified: go build/vet/test green; new evaluator test proves a
context.workload.slsa_level >= 2 policy yields ALLOW@2 / DENY@1 / DENY-absent;
reader test covers present/absent/malformed; e2e 'attest evaluate' against a real
.vet/gate-result.json confirms ALLOW@2, DENY@1, DENY when .vet absent.

Relates to #102, #104.
attest's custom Semgrep rule (attest-filepath-join-no-confinement) flagged the
filepath.Join(dir, ...) in workload.Load. Add the suite's standard Abs-confinement
check (mirroring internal/framework/loader.go): resolve dir and the joined path to
absolute, and reject anything that escapes the base before touching the filesystem.
The filename is a fixed constant, so this confines an operator-supplied --workload-dir
to a direct child read. semgrep: 0 findings.
@scttfrdmn
scttfrdmn merged commit ef766bc into main Jun 9, 2026
2 checks passed
@scttfrdmn
scttfrdmn deleted the feat/context-workload-entity branch June 9, 2026 03:13
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.

Inject lowered workload attributes into Cedar context (context.workload.*)

1 participant