Repository navigation
feat(evaluator): Cedar context entity for workload attributes (closes #103) - #105
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 referencecontext.*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 oncontext.workload.*alongsideprincipal.*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'sgate-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— newbuildContextbuilds a nested record-of-records fromcontext.<group>.<attr>keys (reusingtoValue) and setscedarReq.Context. Generic over the middle segment, so a futurecontext.platform.*(nitro, Inject nitro:// runtime attributes into Cedar context #104) needs zero evaluator change. Returns an empty (valid) Record when nocontext.*keys.cmd/attest/main.go—attest evaluategains--workload-dir(default.vet); injectscontext.workload.*(int64slsa_level → CedarLong).Casing decision
Cedar keys are snake_case (
context.workload.slsa_level) — consistent with every existingprincipal.*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+ theprincipalpackage doc. #102 closes as satisfied-by-design.Verification
go build/vet/test ./...green.context.workload.slsa_level >= 2policy → ALLOW@2 / DENY@1 / DENY-absent; plus asigned == truecase and abuildContextnesting unit test.attest evaluateagainst a real.vet/gate-result.json→ ALLOW at slsa_level 2, DENY at 1, DENY when.vetabsent.