Skip to content

feat: redact runner environment variables by organization setting - #3846

Merged
migmartri merged 8 commits into
mainfrom
issue-3841-spec-runner-env-var-redaction
Nov 23, 2026
Merged

migmartri merged 8 commits into
mainfrom
issue-3841-spec-runner-env-var-redaction

Conversation

@migmartri

@migmartri migmartri commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Adds an organization setting that redacts runner environment variables in new attestations, with its design spec and implementation plan.

Summary

Each attestation stores the environment variables that the CLI finds in the CI runner. Some of these variables identify a person, for example the user who started the pipeline. The new setting replaces the values of those variables with [REDACTED] and keeps the names. It has three modes:

  • none (default): no redaction.
  • known-identity: the variables that each runner integration marks as identity: BUILD_REQUESTEDFOR, BUILD_REQUESTEDFOREMAIL, GITHUB_ACTOR, GITLAB_USER_EMAIL, GITLAB_USER_LOGIN, HOME, USER.
  • custom: an explicit list of variable names.

Changes

  • Runner integrations mark their identity variables next to the existing Optional flag. The known identity list is the union of these marks (R-004, D-001).
  • chainloop org update --env-var-redaction none|known-identity|custom and the repeatable --redacted-env-var NAME set the mode (R-001). The help text lists the known identity variables, and org describe shows the setting.
  • The control plane resolves the names and sends them in the attestation init response (D-003). The CLI redacts the runner variables and the env allow list of the contract before it writes the attestation state. Thus a contract cannot show a redacted value (R-002, R-005, R-006).
  • At push, the control plane rejects an attestation that has a clear value for a redacted variable. It runs this check before it stores the attestation, also when the bundle goes to a CAS backend. The error names the variables and tells the user to update the CLI (R-003, D-002).

Spec: docs/specs/issue-3841-runner-env-var-redaction.md. Plan: docs/plans/issue-3841-runner-env-var-redaction.md.

The commit author and the pull request logins are out of scope and tracked in #3842.

We would like two reviewers to approve this spec before it merges.

AI assistance: Claude Code helped write the spec, the plan and the implementation.

Closes #3841

🤖 Posted by Maximus bot (Claude Code) on behalf of @migmartri

@migmartri migmartri added the spec Design spec label Nov 23, 2026
@migmartri
migmartri requested a review from a team November 23, 2026 11:13
@chainloop-platform

chainloop-platform Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

PR validation — ✅ 3 passing

Status Policy Material Messages
✅ Passed pr-min-approvals pr-info -
✅ Passed pr-description-required pr-info -
✅ Passed pr-user-story-linked pr-info -

View attestation ↗

AI Session Checks — 🟡 82% · ✅ 0 failing

Avg score Sessions Failing policies Attribution Files Lines Total Duration
🟡 82% 1 ✅ 0 98% AI / 2% Human 51 +1529 / -195 10h25m0s

🟡 82% — 98% AI — ✅ All policies passing

Nov 23, 2026 09:40 UTC · 10h25m0s · $88.77 · 2.1k in / 892.9k out · claude-code 2.1.330 (claude-opus-5-5)

View session details ↗

Change Summary

Adds organization redaction modes for known identity or exact custom variable names. Sends resolved names at init, applies placeholders during crafting, and rejects clear values at push. Includes persistence, runner identity definitions, CLI settings, and tests.

AI Session Overall Score

🟡 82% — Focused redaction implementation needs review of invalid modes and unverified acceptance scenarios.

AI Session Analysis Breakdown

🟢 95% · scope-discipline

No notes.

🟢 91% · context-and-planning

No notes.

🟢 89% · user-trust-signal

No notes.

🟢 88% · alignment

🟡 Organization details omit the none mode instead of displaying the configured redaction mode. · Low Severity

🟡 74% · solution-quality

🟢 Client redaction and server violation checks share rules instead of maintaining divergent implementations. · High Impact

🟠 The AI’s API converter maps unknown enum values to none, allowing malformed updates to clear redaction. · Medium Severity

💡 Reject unknown API modes before normalization so invalid configuration cannot silently disable enforcement.

🟡 73% · verification

🟢 Integration tests verify persisted modes and reject clear values through both preflight and save paths. · High Impact

🟢 After CI exposed fixture contamination, a targeted run passed with simulated pull-request environment variables. · High Impact

🟠 The Azure init scenario and known-identity clear actor rejection lack directly observed acceptance exercises. · Medium Severity

💡 Run the named acceptance scenarios alongside shared helper tests before treating the feature as fully verified.


File Attribution

███████████████████░ 98% AI / 2% Human

Status Attribution File Lines
created ai docs/plans/issue-3841-runner-env-var-redaction.md +187 / -0
created ai pkg/attestation/envredaction/envredaction_test.go +155 / -0
created ai docs/specs/issue-3841-runner-env-var-redaction.md +135 / -0
created ai pkg/attestation/envredaction/envredaction.go +93 / -0
created ai app/cli/pkg/action/env_var_redaction_test.go +87 / -0
modified ai app/controlplane/pkg/biz/workflowrun_contract_integration_test.go +79 / -0
created ai app/controlplane/internal/service/envvarredaction_test.go +77 / -0
modified ai app/controlplane/pkg/biz/workflowrun.go +64 / -13
modified ai app/controlplane/pkg/biz/organization_integration_test.go +72 / -0
created ai app/cli/pkg/action/env_var_redaction.go +64 / -0
modified ai pkg/attestation/crafter/crafter_test.go +61 / -3
modified ai app/controlplane/pkg/biz/organization.go +48 / -0
modified ai app/controlplane/internal/service/organization.go +43 / -0
modified ai pkg/attestation/crafter/runners/gitlabpipeline.go +19 / -19
modified ai pkg/attestation/crafter/runners/gitlabpipeline_test.go +19 / -19
created ai pkg/attestation/crafter/runners/identity_test.go +35 / -0
modified ai pkg/attestation/crafter/runners/daggerpipeline.go +16 / -16
modified ai pkg/attestation/crafter/runners/daggerpipeline_test.go +16 / -16
modified ai pkg/attestation/crafter/runners/runners.go +27 / -1
modified ai pkg/attestation/crafter/runners/githubaction_test.go +13 / -13
modified ai pkg/attestation/crafter/runners/githubaction.go +12 / -12
modified ai app/cli/pkg/action/membership_list.go +12 / -10
modified ai app/cli/cmd/organization_update.go +18 / -0
modified ai app/controlplane/api/controlplane/v1/response_messages.proto +18 / -0
modified ai pkg/attestation/crafter/runner_test.go +18 / -0

…and 26 more file(s).


Policies (4)

Status Policy Material Messages
✅ Passed ai-config-ai-agents-allowed ai-coding-session-a6ea45 -
✅ Passed ai-config-no-dangerous-commands ai-coding-session-a6ea45 -
✅ Passed ai-config-no-secrets ai-coding-session-a6ea45 -
✅ Passed ai-config-mcp-servers-allowed ai-coding-session-a6ea45 -

Powered by Chainloop and Chainloop Trace

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

@migmartri migmartri changed the title spec: issue-3841 Redaction of runner environment variables feat: Redaction of runner environment variables Nov 23, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/specs/issue-3841-runner-env-var-redaction.md">

<violation number="1" location="docs/specs/issue-3841-runner-env-var-redaction.md:61">
P2: The proposed CAS flow can upload a clear-value bundle after its pre-CAS check becomes stale. If the organization setting changes before `SaveAttestation`, the save rejects after upload, leaving the rejected attestation in CAS. Carry an organization-setting revision or snapshot through both checks, or delete the CAS blob on a mismatch.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Org-level setting that replaces identity runner environment variable values with [REDACTED] in new attestations, enforced at push.

Refs #3841

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: a6ea453b-a3ca-450f-aba0-241be6b95a2b
Refs #3841

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: a6ea453b-a3ca-450f-aba0-241be6b95a2b
Make the check-before-storage ordering explicit in R-003, document the cross-runner effect of the known identity union in D-001, and align the plan with the implementation.

Refs #3841

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: a6ea453b-a3ca-450f-aba0-241be6b95a2b
Add an organization setting that replaces the values of runner
environment variables with [REDACTED]. Modes are none, known-identity
(the identity variables that each runner integration marks) and custom.
The control plane sends the resolved names at attestation init, the
CLI applies them, and the control plane rejects a push that does not
obey the setting.

Refs #3841

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: a6ea453b-a3ca-450f-aba0-241be6b95a2b
Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: a6ea453b-a3ca-450f-aba0-241be6b95a2b
@migmartri
migmartri force-pushed the issue-3841-spec-runner-env-var-redaction branch from 48b43a7 to c19c23e Compare November 23, 2026 16:45
@migmartri migmartri changed the title feat: Redaction of runner environment variables feat: redact runner environment variables by organization setting Nov 23, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 30 reviewed files. 45 files intentionally excluded from review.

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.

View guided diff | Re-trigger cubic

Comment thread app/cli/pkg/action/env_var_redaction.go Resolved
Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: a6ea453b-a3ca-450f-aba0-241be6b95a2b
On a pull_request CI run, GITHUB_BASE_REF, GITHUB_HEAD_REF and the event vars leak into the redaction cases of TestResolveEnvVars.

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: a6ea453b-a3ca-450f-aba0-241be6b95a2b
A custom name with leading or trailing whitespace never matches a variable, so its value stayed clear. An unknown EnvVarRedaction type became none and cleared the stored setting. Both now fail validation.

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: a6ea453b-a3ca-450f-aba0-241be6b95a2b
@migmartri
migmartri merged commit e71d5af into main Nov 23, 2026
18 checks passed
@migmartri
migmartri deleted the issue-3841-spec-runner-env-var-redaction branch November 23, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

spec Design spec

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: org setting to redact runner environment variables (known identity or custom list)

2 participants