diff --git a/app/cli/cmd/organization_describe.go b/app/cli/cmd/organization_describe.go
index 1ceea5a6a..f11b7e051 100644
--- a/app/cli/cmd/organization_describe.go
+++ b/app/cli/cmd/organization_describe.go
@@ -64,6 +64,8 @@ func contextTableOutput(config *action.ConfigContextItem) error {
orgInfo += "\nBlock attestations on released versions: enabled"
}
+ orgInfo += fmt.Sprintf("\nPII redaction: %s", enabledDisabled(m.Org.PIIRedaction))
+
if r := m.Org.EnvVarRedaction; r != nil {
orgInfo += fmt.Sprintf("\nEnv var redaction: %s", r.Mode)
if len(r.EnvVars) > 0 {
@@ -83,3 +85,10 @@ func contextTableOutput(config *action.ConfigContextItem) error {
gt.Render()
return nil
}
+
+func enabledDisabled(on bool) string {
+ if on {
+ return "enabled"
+ }
+ return "disabled"
+}
diff --git a/app/cli/cmd/organization_update.go b/app/cli/cmd/organization_update.go
index 36c42ef82..1d74b5c9a 100644
--- a/app/cli/cmd/organization_update.go
+++ b/app/cli/cmd/organization_update.go
@@ -39,6 +39,7 @@ func newOrganizationUpdateCmd() *cobra.Command {
skipRunnerEnvVars bool
envVarRedaction string
redactedEnvVars []string
+ piiRedaction bool
)
cmd := &cobra.Command{
@@ -82,6 +83,10 @@ func newOrganizationUpdateCmd() *cobra.Command {
opts.EnvVarRedaction = redaction
}
+ if cmd.Flags().Changed("pii-redaction") {
+ opts.PIIRedaction = &piiRedaction
+ }
+
if cmd.Flags().Changed("api-token-max-days-inactive") {
days, err := strconv.Atoi(apiTokenMaxDaysInactive)
if err != nil {
@@ -116,9 +121,11 @@ func newOrganizationUpdateCmd() *cobra.Command {
cmd.Flags().BoolVar(&blockAttestationsOnReleasedVersions, "block-attestations-on-released-versions", false, "reject new attestations pushed to project versions that are already released")
cmd.Flags().BoolVar(&skipRunnerEnvVars, "skip-runner-env-vars", false, "opt out of storing the environment variables automatically discovered by the CI runner in the attestation")
cmd.Flags().StringVar(&envVarRedaction, "env-var-redaction", "", fmt.Sprintf(
- "replace the values of environment variables with %s in new attestations, one of: %s, %s (variables that identify a person: %s), %s (the variables in --redacted-env-var)",
- envredaction.RedactedValue, envredaction.ModeNone, envredaction.ModeKnownIdentity,
- strings.Join(runners.KnownIdentityEnvVars(), ", "), envredaction.ModeCustom))
+ "replace the values of more environment variables with %s in new attestations, one of: %s, %s (the variables in --redacted-env-var, in addition to the ones of --pii-redaction). %s is deprecated: use --pii-redaction",
+ envredaction.RedactedValue, envredaction.ModeNone, envredaction.ModeCustom, envredaction.ModeKnownIdentity))
cmd.Flags().StringArrayVar(&redactedEnvVars, "redacted-env-var", nil, "exact name of an environment variable to redact, can be set multiple times. Requires --env-var-redaction custom")
+ cmd.Flags().BoolVar(&piiRedaction, "pii-redaction", false, fmt.Sprintf(
+ "replace personal data with %s in new attestations: the head commit author, the PR/MR author and reviewer logins, and the environment variables that identify a person (%s)",
+ envredaction.RedactedValue, strings.Join(runners.KnownIdentityEnvVars(), ", ")))
return cmd
}
diff --git a/app/cli/documentation/cli-reference.md b/app/cli/documentation/cli-reference.md
index 2ae75d804..039403429 100644
--- a/app/cli/documentation/cli-reference.md
+++ b/app/cli/documentation/cli-reference.md
@@ -2838,9 +2838,10 @@ Options
--block[=true|false] set the default policy violation blocking strategy
--block-attestations-on-released-versions[=true|false] reject new attestations pushed to project versions that are already released
--enable-ai-agent-collector[=true|false] enable automatic AI agent config collection during attestation init
---env-var-redaction string replace the values of environment variables with [REDACTED] in new attestations, one of: none, known-identity (variables that identify a person: BUILD_REQUESTEDFOR, BUILD_REQUESTEDFOREMAIL, GITHUB_ACTOR, GITLAB_USER_EMAIL, GITLAB_USER_LOGIN, HOME, USER), custom (the variables in --redacted-env-var)
+--env-var-redaction string replace the values of more environment variables with [REDACTED] in new attestations, one of: none, custom (the variables in --redacted-env-var, in addition to the ones of --pii-redaction). known-identity is deprecated: use --pii-redaction
-h, --help[=true|false] help for update
--name string organization name
+--pii-redaction[=true|false] replace personal data with [REDACTED] in new attestations: the head commit author, the PR/MR author and reviewer logins, and the environment variables that identify a person (BUILD_REQUESTEDFOR, BUILD_REQUESTEDFOREMAIL, GITHUB_ACTOR, GITLAB_USER_EMAIL, GITLAB_USER_LOGIN, HOME, USER)
--policies-allowed-hostnames strings set the allowed hostnames for the policy engine
--prevent-implicit-workflow-creation[=true|false] prevent workflows and projects from being created implicitly during attestation init
--redacted-env-var stringArray exact name of an environment variable to redact, can be set multiple times. Requires --env-var-redaction custom
diff --git a/app/cli/pkg/action/attestation_init.go b/app/cli/pkg/action/attestation_init.go
index d895f0636..cd8828f65 100644
--- a/app/cli/pkg/action/attestation_init.go
+++ b/app/cli/pkg/action/attestation_init.go
@@ -233,6 +233,7 @@ func (action *AttestationInit) Run(ctx context.Context, opts *AttestationInitRun
enableAIAgentCollector bool
skipRunnerEnvVars bool
redactedEnvVars []string
+ piiRedaction bool
// Timestamp Authority URL for new attestations
timestampAuthorityURL, signingCAName string
uiDashboardURL string
@@ -269,6 +270,7 @@ func (action *AttestationInit) Run(ctx context.Context, opts *AttestationInitRun
skipRunnerEnvVars = result.GetSkipRunnerEnvVars()
// the control plane resolves the names for every mode, so they match its push check
redactedEnvVars = result.GetRedactedEnvVars()
+ piiRedaction = result.GetPiiRedaction()
signingOpts := result.GetSigningOptions()
timestampAuthorityURL = signingOpts.GetTimestampAuthorityUrl()
signingCAName = signingOpts.GetSigningCa()
@@ -323,6 +325,7 @@ func (action *AttestationInit) Run(ctx context.Context, opts *AttestationInitRun
PoliciesAllowedHostnames: policiesAllowedHostnames,
SkipRunnerEnvVars: skipRunnerEnvVars,
RedactedEnvVars: redactedEnvVars,
+ PIIRedaction: piiRedaction,
SigningOptions: &crafter.SigningOpts{
TimestampAuthorityURL: timestampAuthorityURL,
SigningCAName: signingCAName,
diff --git a/app/cli/pkg/action/membership_list.go b/app/cli/pkg/action/membership_list.go
index 09955bc5a..6dce44243 100644
--- a/app/cli/pkg/action/membership_list.go
+++ b/app/cli/pkg/action/membership_list.go
@@ -40,6 +40,7 @@ type OrgItem struct {
BlockAttestationsOnReleasedVersions bool `json:"blockAttestationsOnReleasedVersions"`
SkipRunnerEnvVars bool `json:"skipRunnerEnvVars"`
EnvVarRedaction *EnvVarRedactionItem `json:"envVarRedaction,omitempty"`
+ PIIRedaction bool `json:"piiRedaction"`
}
type MembershipItem struct {
@@ -146,6 +147,7 @@ func pbOrgItemToAction(in *pb.OrgItem) *OrgItem {
BlockAttestationsOnReleasedVersions: in.BlockAttestationsOnReleasedVersions,
SkipRunnerEnvVars: in.SkipRunnerEnvVars,
EnvVarRedaction: pbEnvVarRedactionToAction(in.GetEnvVarRedaction()),
+ PIIRedaction: in.GetPiiRedaction(),
}
if in.DefaultPolicyViolationStrategy == pb.OrgItem_POLICY_VIOLATION_BLOCKING_STRATEGY_BLOCK {
diff --git a/app/cli/pkg/action/org_update.go b/app/cli/pkg/action/org_update.go
index ff29a6767..33275ef90 100644
--- a/app/cli/pkg/action/org_update.go
+++ b/app/cli/pkg/action/org_update.go
@@ -46,6 +46,8 @@ type NewOrgUpdateOpts struct {
SkipRunnerEnvVars *bool
// EnvVarRedaction sets the redaction of env var values in new attestations. nil means no change
EnvVarRedaction *pb.EnvVarRedaction
+ // PIIRedaction sets the redaction of personal data in new attestations. nil means no change
+ PIIRedaction *bool
}
func (action *OrgUpdate) Run(ctx context.Context, name string, opts *NewOrgUpdateOpts) (*OrgItem, error) {
@@ -60,6 +62,7 @@ func (action *OrgUpdate) Run(ctx context.Context, name string, opts *NewOrgUpdat
BlockAttestationsOnReleasedVersions: opts.BlockAttestationsOnReleasedVersions,
SkipRunnerEnvVars: opts.SkipRunnerEnvVars,
EnvVarRedaction: opts.EnvVarRedaction,
+ PiiRedaction: opts.PIIRedaction,
}
if opts.PoliciesAllowedHostnames != nil {
diff --git a/app/controlplane/api/controlplane/v1/organization.pb.go b/app/controlplane/api/controlplane/v1/organization.pb.go
index 281e2ca75..49b05d475 100644
--- a/app/controlplane/api/controlplane/v1/organization.pb.go
+++ b/app/controlplane/api/controlplane/v1/organization.pb.go
@@ -457,9 +457,13 @@ type OrganizationServiceUpdateRequest struct {
// Opt out of storing the environment variables automatically discovered by the CI runner in the attestation
SkipRunnerEnvVars *bool `protobuf:"varint,10,opt,name=skip_runner_env_vars,json=skipRunnerEnvVars,proto3,oneof" json:"skip_runner_env_vars,omitempty"`
// Redaction of environment variable values in new attestations. Not set means no change.
+ // TYPE_KNOWN_IDENTITY is deprecated: the control plane turns it into pii_redaction = true.
EnvVarRedaction *EnvVarRedaction `protobuf:"bytes,11,opt,name=env_var_redaction,json=envVarRedaction,proto3" json:"env_var_redaction,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
+ // Replace personal data with "[REDACTED]" in new attestations: the known identity env vars,
+ // the head commit author, and the PR/MR author and reviewer logins. Not set means no change.
+ PiiRedaction *bool `protobuf:"varint,12,opt,name=pii_redaction,json=piiRedaction,proto3,oneof" json:"pii_redaction,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
}
func (x *OrganizationServiceUpdateRequest) Reset() {
@@ -569,6 +573,13 @@ func (x *OrganizationServiceUpdateRequest) GetEnvVarRedaction() *EnvVarRedaction
return nil
}
+func (x *OrganizationServiceUpdateRequest) GetPiiRedaction() bool {
+ if x != nil && x.PiiRedaction != nil {
+ return *x.PiiRedaction
+ }
+ return false
+}
+
type OrganizationServiceUpdateResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Result *OrgItem `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"`
@@ -727,7 +738,7 @@ const file_controlplane_v1_organization_proto_rawDesc = "" +
" OrganizationServiceCreateRequest\x12\x1b\n" +
"\x04name\x18\x01 \x01(\tB\a\xbaH\x04r\x02\x10\x01R\x04name\"U\n" +
"!OrganizationServiceCreateResponse\x120\n" +
- "\x06result\x18\x01 \x01(\v2\x18.controlplane.v1.OrgItemR\x06result\"\x8d\b\n" +
+ "\x06result\x18\x01 \x01(\v2\x18.controlplane.v1.OrgItemR\x06result\"\xc9\b\n" +
" OrganizationServiceUpdateRequest\x12\x1b\n" +
"\x04name\x18\x01 \x01(\tB\a\xbaH\x04r\x02\x10\x01R\x04name\x12>\n" +
"\x19block_on_policy_violation\x18\x02 \x01(\bH\x00R\x16blockOnPolicyViolation\x88\x01\x01\x12<\n" +
@@ -740,14 +751,16 @@ const file_controlplane_v1_organization_proto_rawDesc = "" +
"'block_attestations_on_released_versions\x18\t \x01(\bH\x05R#blockAttestationsOnReleasedVersions\x88\x01\x01\x124\n" +
"\x14skip_runner_env_vars\x18\n" +
" \x01(\bH\x06R\x11skipRunnerEnvVars\x88\x01\x01\x12L\n" +
- "\x11env_var_redaction\x18\v \x01(\v2 .controlplane.v1.EnvVarRedactionR\x0fenvVarRedactionB\x1c\n" +
+ "\x11env_var_redaction\x18\v \x01(\v2 .controlplane.v1.EnvVarRedactionR\x0fenvVarRedaction\x12(\n" +
+ "\rpii_redaction\x18\f \x01(\bH\aR\fpiiRedaction\x88\x01\x01B\x1c\n" +
"\x1a_block_on_policy_violationB%\n" +
"#_prevent_implicit_workflow_creationB+\n" +
")_restrict_contract_creation_to_org_adminsB\x1e\n" +
"\x1c_api_token_max_days_inactiveB\x1c\n" +
"\x1a_enable_ai_agent_collectorB*\n" +
"(_block_attestations_on_released_versionsB\x17\n" +
- "\x15_skip_runner_env_vars\"U\n" +
+ "\x15_skip_runner_env_varsB\x10\n" +
+ "\x0e_pii_redaction\"U\n" +
"!OrganizationServiceUpdateResponse\x120\n" +
"\x06result\x18\x01 \x01(\v2\x18.controlplane.v1.OrgItemR\x06result\"?\n" +
" OrganizationServiceDeleteRequest\x12\x1b\n" +
diff --git a/app/controlplane/api/controlplane/v1/organization.proto b/app/controlplane/api/controlplane/v1/organization.proto
index d863f719a..8fb34ca3e 100644
--- a/app/controlplane/api/controlplane/v1/organization.proto
+++ b/app/controlplane/api/controlplane/v1/organization.proto
@@ -113,7 +113,12 @@ message OrganizationServiceUpdateRequest {
optional bool skip_runner_env_vars = 10;
// Redaction of environment variable values in new attestations. Not set means no change.
+ // TYPE_KNOWN_IDENTITY is deprecated: the control plane turns it into pii_redaction = true.
EnvVarRedaction env_var_redaction = 11;
+
+ // Replace personal data with "[REDACTED]" in new attestations: the known identity env vars,
+ // the head commit author, and the PR/MR author and reviewer logins. Not set means no change.
+ optional bool pii_redaction = 12;
}
message OrganizationServiceUpdateResponse {
diff --git a/app/controlplane/api/controlplane/v1/response_messages.pb.go b/app/controlplane/api/controlplane/v1/response_messages.pb.go
index 58be5eacb..9fb53aa85 100644
--- a/app/controlplane/api/controlplane/v1/response_messages.pb.go
+++ b/app/controlplane/api/controlplane/v1/response_messages.pb.go
@@ -736,9 +736,10 @@ type EnvVarRedaction_Type int32
const (
// no redaction
EnvVarRedaction_TYPE_UNSPECIFIED EnvVarRedaction_Type = 0
- // redact the variables that Chainloop runner integrations mark as identifying a person
+ // Replaced by the pii_redaction organization setting, kept for older clients.
+ // The control plane turns an update with this type into pii_redaction = true and no env var redaction.
EnvVarRedaction_TYPE_KNOWN_IDENTITY EnvVarRedaction_Type = 1
- // redact only the variables listed in env_vars
+ // redact the variables listed in env_vars, in addition to the ones of pii_redaction
EnvVarRedaction_TYPE_CUSTOM EnvVarRedaction_Type = 2
)
@@ -2522,8 +2523,11 @@ type OrgItem struct {
SkipRunnerEnvVars bool `protobuf:"varint,12,opt,name=skip_runner_env_vars,json=skipRunnerEnvVars,proto3" json:"skip_runner_env_vars,omitempty"`
// Redaction of the values of environment variables stored in new attestations
EnvVarRedaction *EnvVarRedaction `protobuf:"bytes,13,opt,name=env_var_redaction,json=envVarRedaction,proto3" json:"env_var_redaction,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
+ // Whether personal data is replaced with "[REDACTED]" in new attestations: the known identity env vars,
+ // the head commit author, and the PR/MR author and reviewer logins
+ PiiRedaction bool `protobuf:"varint,14,opt,name=pii_redaction,json=piiRedaction,proto3" json:"pii_redaction,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
}
func (x *OrgItem) Reset() {
@@ -2647,6 +2651,13 @@ func (x *OrgItem) GetEnvVarRedaction() *EnvVarRedaction {
return nil
}
+func (x *OrgItem) GetPiiRedaction() bool {
+ if x != nil {
+ return x.PiiRedaction
+ }
+ return false
+}
+
// EnvVarRedaction configures which environment variable values are replaced with "[REDACTED]"
// in new attestations. It applies to runner-discovered variables and to the contract's env allow list.
type EnvVarRedaction struct {
@@ -3601,7 +3612,7 @@ const file_controlplane_v1_response_messages_proto_rawDesc = "" +
"created_at\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x129\n" +
"\n" +
"updated_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\tupdatedAt\x123\n" +
- "\x04role\x18\x06 \x01(\x0e2\x1f.controlplane.v1.MembershipRoleR\x04role\"\xb1\b\n" +
+ "\x04role\x18\x06 \x01(\x0e2\x1f.controlplane.v1.MembershipRoleR\x04role\"\xd6\b\n" +
"\aOrgItem\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" +
"\x04name\x18\x02 \x01(\tR\x04name\x129\n" +
@@ -3618,7 +3629,8 @@ const file_controlplane_v1_response_messages_proto_rawDesc = "" +
" \x01(\bR\x16enableAiAgentCollector\x12T\n" +
"'block_attestations_on_released_versions\x18\v \x01(\bR#blockAttestationsOnReleasedVersions\x12/\n" +
"\x14skip_runner_env_vars\x18\f \x01(\bR\x11skipRunnerEnvVars\x12L\n" +
- "\x11env_var_redaction\x18\r \x01(\v2 .controlplane.v1.EnvVarRedactionR\x0fenvVarRedaction\"\xb4\x01\n" +
+ "\x11env_var_redaction\x18\r \x01(\v2 .controlplane.v1.EnvVarRedactionR\x0fenvVarRedaction\x12#\n" +
+ "\rpii_redaction\x18\x0e \x01(\bR\fpiiRedaction\"\xb4\x01\n" +
"\x1fPolicyViolationBlockingStrategy\x122\n" +
".POLICY_VIOLATION_BLOCKING_STRATEGY_UNSPECIFIED\x10\x00\x12,\n" +
"(POLICY_VIOLATION_BLOCKING_STRATEGY_BLOCK\x10\x01\x12/\n" +
diff --git a/app/controlplane/api/controlplane/v1/response_messages.proto b/app/controlplane/api/controlplane/v1/response_messages.proto
index 3b17e0c72..9dbacc864 100644
--- a/app/controlplane/api/controlplane/v1/response_messages.proto
+++ b/app/controlplane/api/controlplane/v1/response_messages.proto
@@ -430,6 +430,9 @@ message OrgItem {
bool skip_runner_env_vars = 12;
// Redaction of the values of environment variables stored in new attestations
EnvVarRedaction env_var_redaction = 13;
+ // Whether personal data is replaced with "[REDACTED]" in new attestations: the known identity env vars,
+ // the head commit author, and the PR/MR author and reviewer logins
+ bool pii_redaction = 14;
enum PolicyViolationBlockingStrategy {
POLICY_VIOLATION_BLOCKING_STRATEGY_UNSPECIFIED = 0;
@@ -444,9 +447,10 @@ message EnvVarRedaction {
enum Type {
// no redaction
TYPE_UNSPECIFIED = 0;
- // redact the variables that Chainloop runner integrations mark as identifying a person
+ // Replaced by the pii_redaction organization setting, kept for older clients.
+ // The control plane turns an update with this type into pii_redaction = true and no env var redaction.
TYPE_KNOWN_IDENTITY = 1;
- // redact only the variables listed in env_vars
+ // redact the variables listed in env_vars, in addition to the ones of pii_redaction
TYPE_CUSTOM = 2;
}
Type type = 1;
diff --git a/app/controlplane/api/controlplane/v1/workflow_run.pb.go b/app/controlplane/api/controlplane/v1/workflow_run.pb.go
index e68422a0f..18b8f031b 100644
--- a/app/controlplane/api/controlplane/v1/workflow_run.pb.go
+++ b/app/controlplane/api/controlplane/v1/workflow_run.pb.go
@@ -2107,8 +2107,11 @@ type AttestationServiceInitResponse_Result struct {
// Names of the environment variables whose values the CLI replaces with "[REDACTED]".
// The control plane resolves them from the org setting and enforces the same list at push.
RedactedEnvVars []string `protobuf:"bytes,10,rep,name=redacted_env_vars,json=redactedEnvVars,proto3" json:"redacted_env_vars,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
+ // Replace the head commit author and the PR/MR author and reviewer logins with "[REDACTED]".
+ // The control plane enforces it at push.
+ PiiRedaction bool `protobuf:"varint,11,opt,name=pii_redaction,json=piiRedaction,proto3" json:"pii_redaction,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
}
func (x *AttestationServiceInitResponse_Result) Reset() {
@@ -2204,6 +2207,13 @@ func (x *AttestationServiceInitResponse_Result) GetRedactedEnvVars() []string {
return nil
}
+func (x *AttestationServiceInitResponse_Result) GetPiiRedaction() bool {
+ if x != nil {
+ return x.PiiRedaction
+ }
+ return false
+}
+
type AttestationServiceInitResponse_SigningOptions struct {
state protoimpl.MessageState `protogen:"open.v1"`
// TSA service to be used for signing
@@ -2990,9 +3000,9 @@ const file_controlplane_v1_workflow_run_proto_rawDesc = "" +
"\x18require_existing_version\x18\a \x01(\bR\x16requireExistingVersion\x12,\n" +
"\x12use_latest_version\x18\b \x01(\bR\x10useLatestVersion\x12)\n" +
"\x0emark_as_latest\x18\t \x01(\bH\x00R\fmarkAsLatest\x88\x01\x01B\x11\n" +
- "\x0f_mark_as_latest\"\xf1\x05\n" +
+ "\x0f_mark_as_latest\"\x96\x06\n" +
"\x1eAttestationServiceInitResponse\x12N\n" +
- "\x06result\x18\x01 \x01(\v26.controlplane.v1.AttestationServiceInitResponse.ResultR\x06result\x1a\x95\x04\n" +
+ "\x06result\x18\x01 \x01(\v26.controlplane.v1.AttestationServiceInitResponse.ResultR\x06result\x1a\xba\x04\n" +
"\x06Result\x12C\n" +
"\fworkflow_run\x18\x02 \x01(\v2 .controlplane.v1.WorkflowRunItemR\vworkflowRun\x12\"\n" +
"\forganization\x18\x03 \x01(\tR\forganization\x129\n" +
@@ -3003,7 +3013,8 @@ const file_controlplane_v1_workflow_run_proto_rawDesc = "" +
"\x19enable_ai_agent_collector\x18\b \x01(\bR\x16enableAiAgentCollector\x12/\n" +
"\x14skip_runner_env_vars\x18\t \x01(\bR\x11skipRunnerEnvVars\x12*\n" +
"\x11redacted_env_vars\x18\n" +
- " \x03(\tR\x0fredactedEnvVars\x1ag\n" +
+ " \x03(\tR\x0fredactedEnvVars\x12#\n" +
+ "\rpii_redaction\x18\v \x01(\bR\fpiiRedaction\x1ag\n" +
"\x0eSigningOptions\x126\n" +
"\x17timestamp_authority_url\x18\x01 \x01(\tR\x15timestampAuthorityUrl\x12\x1d\n" +
"\n" +
diff --git a/app/controlplane/api/controlplane/v1/workflow_run.proto b/app/controlplane/api/controlplane/v1/workflow_run.proto
index 2c4ba76bf..5c8e7b808 100644
--- a/app/controlplane/api/controlplane/v1/workflow_run.proto
+++ b/app/controlplane/api/controlplane/v1/workflow_run.proto
@@ -162,6 +162,9 @@ message AttestationServiceInitResponse {
// Names of the environment variables whose values the CLI replaces with "[REDACTED]".
// The control plane resolves them from the org setting and enforces the same list at push.
repeated string redacted_env_vars = 10;
+ // Replace the head commit author and the PR/MR author and reviewer logins with "[REDACTED]".
+ // The control plane enforces it at push.
+ bool pii_redaction = 11;
}
message SigningOptions {
diff --git a/app/controlplane/api/gen/frontend/attestation/v1/crafting_state.ts b/app/controlplane/api/gen/frontend/attestation/v1/crafting_state.ts
index c3e0050f0..78a4f8e6d 100644
--- a/app/controlplane/api/gen/frontend/attestation/v1/crafting_state.ts
+++ b/app/controlplane/api/gen/frontend/attestation/v1/crafting_state.ts
@@ -59,6 +59,11 @@ export interface Attestation {
* It applies to the runner env vars and to the contract's env_allow_list.
*/
redactedEnvVars: string[];
+ /**
+ * replace the head commit author and the PR/MR author and reviewer logins with "[REDACTED]",
+ * as set by the organization PII redaction setting
+ */
+ piiRedaction: boolean;
}
export interface Attestation_MaterialsEntry {
@@ -670,6 +675,7 @@ function createBaseAttestation(): Attestation {
casBackend: undefined,
skipRunnerEnvVars: false,
redactedEnvVars: [],
+ piiRedaction: false,
};
}
@@ -732,6 +738,9 @@ export const Attestation = {
for (const v of message.redactedEnvVars) {
writer.uint32(170).string(v!);
}
+ if (message.piiRedaction === true) {
+ writer.uint32(176).bool(message.piiRedaction);
+ }
return writer;
},
@@ -884,6 +893,13 @@ export const Attestation = {
message.redactedEnvVars.push(reader.string());
continue;
+ case 22:
+ if (tag !== 176) {
+ break;
+ }
+
+ message.piiRedaction = reader.bool();
+ continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
@@ -937,6 +953,7 @@ export const Attestation = {
casBackend: isSet(object.casBackend) ? Attestation_CASBackend.fromJSON(object.casBackend) : undefined,
skipRunnerEnvVars: isSet(object.skipRunnerEnvVars) ? Boolean(object.skipRunnerEnvVars) : false,
redactedEnvVars: Array.isArray(object?.redactedEnvVars) ? object.redactedEnvVars.map((e: any) => String(e)) : [],
+ piiRedaction: isSet(object.piiRedaction) ? Boolean(object.piiRedaction) : false,
};
},
@@ -994,6 +1011,7 @@ export const Attestation = {
} else {
obj.redactedEnvVars = [];
}
+ message.piiRedaction !== undefined && (obj.piiRedaction = message.piiRedaction);
return obj;
},
@@ -1053,6 +1071,7 @@ export const Attestation = {
: undefined;
message.skipRunnerEnvVars = object.skipRunnerEnvVars ?? false;
message.redactedEnvVars = object.redactedEnvVars?.map((e) => e) || [];
+ message.piiRedaction = object.piiRedaction ?? false;
return message;
},
};
diff --git a/app/controlplane/api/gen/frontend/controlplane/v1/organization.ts b/app/controlplane/api/gen/frontend/controlplane/v1/organization.ts
index ac444dad3..3e06815be 100644
--- a/app/controlplane/api/gen/frontend/controlplane/v1/organization.ts
+++ b/app/controlplane/api/gen/frontend/controlplane/v1/organization.ts
@@ -101,8 +101,16 @@ export interface OrganizationServiceUpdateRequest {
skipRunnerEnvVars?:
| boolean
| undefined;
- /** Redaction of environment variable values in new attestations. Not set means no change. */
+ /**
+ * Redaction of environment variable values in new attestations. Not set means no change.
+ * TYPE_KNOWN_IDENTITY is deprecated: the control plane turns it into pii_redaction = true.
+ */
envVarRedaction?: EnvVarRedaction;
+ /**
+ * Replace personal data with "[REDACTED]" in new attestations: the known identity env vars,
+ * the head commit author, and the PR/MR author and reviewer logins. Not set means no change.
+ */
+ piiRedaction?: boolean | undefined;
}
export interface OrganizationServiceUpdateResponse {
@@ -697,6 +705,7 @@ function createBaseOrganizationServiceUpdateRequest(): OrganizationServiceUpdate
blockAttestationsOnReleasedVersions: undefined,
skipRunnerEnvVars: undefined,
envVarRedaction: undefined,
+ piiRedaction: undefined,
};
}
@@ -735,6 +744,9 @@ export const OrganizationServiceUpdateRequest = {
if (message.envVarRedaction !== undefined) {
EnvVarRedaction.encode(message.envVarRedaction, writer.uint32(90).fork()).ldelim();
}
+ if (message.piiRedaction !== undefined) {
+ writer.uint32(96).bool(message.piiRedaction);
+ }
return writer;
},
@@ -822,6 +834,13 @@ export const OrganizationServiceUpdateRequest = {
message.envVarRedaction = EnvVarRedaction.decode(reader, reader.uint32());
continue;
+ case 12:
+ if (tag !== 96) {
+ break;
+ }
+
+ message.piiRedaction = reader.bool();
+ continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
@@ -856,6 +875,7 @@ export const OrganizationServiceUpdateRequest = {
: undefined,
skipRunnerEnvVars: isSet(object.skipRunnerEnvVars) ? Boolean(object.skipRunnerEnvVars) : undefined,
envVarRedaction: isSet(object.envVarRedaction) ? EnvVarRedaction.fromJSON(object.envVarRedaction) : undefined,
+ piiRedaction: isSet(object.piiRedaction) ? Boolean(object.piiRedaction) : undefined,
};
},
@@ -882,6 +902,7 @@ export const OrganizationServiceUpdateRequest = {
message.skipRunnerEnvVars !== undefined && (obj.skipRunnerEnvVars = message.skipRunnerEnvVars);
message.envVarRedaction !== undefined &&
(obj.envVarRedaction = message.envVarRedaction ? EnvVarRedaction.toJSON(message.envVarRedaction) : undefined);
+ message.piiRedaction !== undefined && (obj.piiRedaction = message.piiRedaction);
return obj;
},
@@ -908,6 +929,7 @@ export const OrganizationServiceUpdateRequest = {
message.envVarRedaction = (object.envVarRedaction !== undefined && object.envVarRedaction !== null)
? EnvVarRedaction.fromPartial(object.envVarRedaction)
: undefined;
+ message.piiRedaction = object.piiRedaction ?? undefined;
return message;
},
};
diff --git a/app/controlplane/api/gen/frontend/controlplane/v1/response_messages.ts b/app/controlplane/api/gen/frontend/controlplane/v1/response_messages.ts
index 50293e064..e96da1232 100644
--- a/app/controlplane/api/gen/frontend/controlplane/v1/response_messages.ts
+++ b/app/controlplane/api/gen/frontend/controlplane/v1/response_messages.ts
@@ -976,6 +976,11 @@ export interface OrgItem {
skipRunnerEnvVars: boolean;
/** Redaction of the values of environment variables stored in new attestations */
envVarRedaction?: EnvVarRedaction;
+ /**
+ * Whether personal data is replaced with "[REDACTED]" in new attestations: the known identity env vars,
+ * the head commit author, and the PR/MR author and reviewer logins
+ */
+ piiRedaction: boolean;
}
export enum OrgItem_PolicyViolationBlockingStrategy {
@@ -1030,9 +1035,12 @@ export interface EnvVarRedaction {
export enum EnvVarRedaction_Type {
/** TYPE_UNSPECIFIED - no redaction */
TYPE_UNSPECIFIED = 0,
- /** TYPE_KNOWN_IDENTITY - redact the variables that Chainloop runner integrations mark as identifying a person */
+ /**
+ * TYPE_KNOWN_IDENTITY - Replaced by the pii_redaction organization setting, kept for older clients.
+ * The control plane turns an update with this type into pii_redaction = true and no env var redaction.
+ */
TYPE_KNOWN_IDENTITY = 1,
- /** TYPE_CUSTOM - redact only the variables listed in env_vars */
+ /** TYPE_CUSTOM - redact the variables listed in env_vars, in addition to the ones of pii_redaction */
TYPE_CUSTOM = 2,
UNRECOGNIZED = -1,
}
@@ -4684,6 +4692,7 @@ function createBaseOrgItem(): OrgItem {
blockAttestationsOnReleasedVersions: false,
skipRunnerEnvVars: false,
envVarRedaction: undefined,
+ piiRedaction: false,
};
}
@@ -4728,6 +4737,9 @@ export const OrgItem = {
if (message.envVarRedaction !== undefined) {
EnvVarRedaction.encode(message.envVarRedaction, writer.uint32(106).fork()).ldelim();
}
+ if (message.piiRedaction === true) {
+ writer.uint32(112).bool(message.piiRedaction);
+ }
return writer;
},
@@ -4829,6 +4841,13 @@ export const OrgItem = {
message.envVarRedaction = EnvVarRedaction.decode(reader, reader.uint32());
continue;
+ case 14:
+ if (tag !== 112) {
+ break;
+ }
+
+ message.piiRedaction = reader.bool();
+ continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
@@ -4865,6 +4884,7 @@ export const OrgItem = {
: false,
skipRunnerEnvVars: isSet(object.skipRunnerEnvVars) ? Boolean(object.skipRunnerEnvVars) : false,
envVarRedaction: isSet(object.envVarRedaction) ? EnvVarRedaction.fromJSON(object.envVarRedaction) : undefined,
+ piiRedaction: isSet(object.piiRedaction) ? Boolean(object.piiRedaction) : false,
};
},
@@ -4895,6 +4915,7 @@ export const OrgItem = {
message.skipRunnerEnvVars !== undefined && (obj.skipRunnerEnvVars = message.skipRunnerEnvVars);
message.envVarRedaction !== undefined &&
(obj.envVarRedaction = message.envVarRedaction ? EnvVarRedaction.toJSON(message.envVarRedaction) : undefined);
+ message.piiRedaction !== undefined && (obj.piiRedaction = message.piiRedaction);
return obj;
},
@@ -4919,6 +4940,7 @@ export const OrgItem = {
message.envVarRedaction = (object.envVarRedaction !== undefined && object.envVarRedaction !== null)
? EnvVarRedaction.fromPartial(object.envVarRedaction)
: undefined;
+ message.piiRedaction = object.piiRedaction ?? false;
return message;
},
};
diff --git a/app/controlplane/api/gen/frontend/controlplane/v1/workflow_run.ts b/app/controlplane/api/gen/frontend/controlplane/v1/workflow_run.ts
index 68eef56d5..9e2766990 100644
--- a/app/controlplane/api/gen/frontend/controlplane/v1/workflow_run.ts
+++ b/app/controlplane/api/gen/frontend/controlplane/v1/workflow_run.ts
@@ -146,6 +146,11 @@ export interface AttestationServiceInitResponse_Result {
* The control plane resolves them from the org setting and enforces the same list at push.
*/
redactedEnvVars: string[];
+ /**
+ * Replace the head commit author and the PR/MR author and reviewer logins with "[REDACTED]".
+ * The control plane enforces it at push.
+ */
+ piiRedaction: boolean;
}
export interface AttestationServiceInitResponse_SigningOptions {
@@ -1718,6 +1723,7 @@ function createBaseAttestationServiceInitResponse_Result(): AttestationServiceIn
enableAiAgentCollector: false,
skipRunnerEnvVars: false,
redactedEnvVars: [],
+ piiRedaction: false,
};
}
@@ -1750,6 +1756,9 @@ export const AttestationServiceInitResponse_Result = {
for (const v of message.redactedEnvVars) {
writer.uint32(82).string(v!);
}
+ if (message.piiRedaction === true) {
+ writer.uint32(88).bool(message.piiRedaction);
+ }
return writer;
},
@@ -1823,6 +1832,13 @@ export const AttestationServiceInitResponse_Result = {
message.redactedEnvVars.push(reader.string());
continue;
+ case 11:
+ if (tag !== 88) {
+ break;
+ }
+
+ message.piiRedaction = reader.bool();
+ continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
@@ -1847,6 +1863,7 @@ export const AttestationServiceInitResponse_Result = {
enableAiAgentCollector: isSet(object.enableAiAgentCollector) ? Boolean(object.enableAiAgentCollector) : false,
skipRunnerEnvVars: isSet(object.skipRunnerEnvVars) ? Boolean(object.skipRunnerEnvVars) : false,
redactedEnvVars: Array.isArray(object?.redactedEnvVars) ? object.redactedEnvVars.map((e: any) => String(e)) : [],
+ piiRedaction: isSet(object.piiRedaction) ? Boolean(object.piiRedaction) : false,
};
},
@@ -1872,6 +1889,7 @@ export const AttestationServiceInitResponse_Result = {
} else {
obj.redactedEnvVars = [];
}
+ message.piiRedaction !== undefined && (obj.piiRedaction = message.piiRedaction);
return obj;
},
@@ -1898,6 +1916,7 @@ export const AttestationServiceInitResponse_Result = {
message.enableAiAgentCollector = object.enableAiAgentCollector ?? false;
message.skipRunnerEnvVars = object.skipRunnerEnvVars ?? false;
message.redactedEnvVars = object.redactedEnvVars?.map((e) => e) || [];
+ message.piiRedaction = object.piiRedaction ?? false;
return message;
},
};
diff --git a/app/controlplane/api/gen/jsonschema/attestation.v1.Attestation.jsonschema.json b/app/controlplane/api/gen/jsonschema/attestation.v1.Attestation.jsonschema.json
index 936227f4b..f8e1c0b2e 100644
--- a/app/controlplane/api/gen/jsonschema/attestation.v1.Attestation.jsonschema.json
+++ b/app/controlplane/api/gen/jsonschema/attestation.v1.Attestation.jsonschema.json
@@ -31,6 +31,10 @@
"^(initialized_at)$": {
"$ref": "google.protobuf.Timestamp.jsonschema.json"
},
+ "^(pii_redaction)$": {
+ "description": "replace the head commit author and the PR/MR author and reviewer logins with \"[REDACTED]\",\n as set by the organization PII redaction setting",
+ "type": "boolean"
+ },
"^(policies_allowed_hostnames)$": {
"description": "array of hostnames that are allowed to be used in the policies",
"items": {
@@ -150,6 +154,10 @@
},
"type": "object"
},
+ "piiRedaction": {
+ "description": "replace the head commit author and the PR/MR author and reviewer logins with \"[REDACTED]\",\n as set by the organization PII redaction setting",
+ "type": "boolean"
+ },
"policiesAllowedHostnames": {
"description": "array of hostnames that are allowed to be used in the policies",
"items": {
diff --git a/app/controlplane/api/gen/jsonschema/attestation.v1.Attestation.schema.json b/app/controlplane/api/gen/jsonschema/attestation.v1.Attestation.schema.json
index 28e66c399..9295f595e 100644
--- a/app/controlplane/api/gen/jsonschema/attestation.v1.Attestation.schema.json
+++ b/app/controlplane/api/gen/jsonschema/attestation.v1.Attestation.schema.json
@@ -31,6 +31,10 @@
"^(initializedAt)$": {
"$ref": "google.protobuf.Timestamp.schema.json"
},
+ "^(piiRedaction)$": {
+ "description": "replace the head commit author and the PR/MR author and reviewer logins with \"[REDACTED]\",\n as set by the organization PII redaction setting",
+ "type": "boolean"
+ },
"^(policiesAllowedHostnames)$": {
"description": "array of hostnames that are allowed to be used in the policies",
"items": {
@@ -150,6 +154,10 @@
},
"type": "object"
},
+ "pii_redaction": {
+ "description": "replace the head commit author and the PR/MR author and reviewer logins with \"[REDACTED]\",\n as set by the organization PII redaction setting",
+ "type": "boolean"
+ },
"policies_allowed_hostnames": {
"description": "array of hostnames that are allowed to be used in the policies",
"items": {
diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.AttestationServiceInitResponse.Result.jsonschema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.AttestationServiceInitResponse.Result.jsonschema.json
index 76b3fb382..9520d9e40 100644
--- a/app/controlplane/api/gen/jsonschema/controlplane.v1.AttestationServiceInitResponse.Result.jsonschema.json
+++ b/app/controlplane/api/gen/jsonschema/controlplane.v1.AttestationServiceInitResponse.Result.jsonschema.json
@@ -11,6 +11,10 @@
"description": "Whether AI agent config collection is enabled at the org level",
"type": "boolean"
},
+ "^(pii_redaction)$": {
+ "description": "Replace the head commit author and the PR/MR author and reviewer logins with \"[REDACTED]\".\n The control plane enforces it at push.",
+ "type": "boolean"
+ },
"^(policies_allowed_hostnames)$": {
"description": "array of hostnames that are allowed to be used in the policies",
"items": {
@@ -54,6 +58,10 @@
"description": "organization name",
"type": "string"
},
+ "piiRedaction": {
+ "description": "Replace the head commit author and the PR/MR author and reviewer logins with \"[REDACTED]\".\n The control plane enforces it at push.",
+ "type": "boolean"
+ },
"policiesAllowedHostnames": {
"description": "array of hostnames that are allowed to be used in the policies",
"items": {
diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.AttestationServiceInitResponse.Result.schema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.AttestationServiceInitResponse.Result.schema.json
index f1fb1cba1..b78784b57 100644
--- a/app/controlplane/api/gen/jsonschema/controlplane.v1.AttestationServiceInitResponse.Result.schema.json
+++ b/app/controlplane/api/gen/jsonschema/controlplane.v1.AttestationServiceInitResponse.Result.schema.json
@@ -11,6 +11,10 @@
"description": "Whether AI agent config collection is enabled at the org level",
"type": "boolean"
},
+ "^(piiRedaction)$": {
+ "description": "Replace the head commit author and the PR/MR author and reviewer logins with \"[REDACTED]\".\n The control plane enforces it at push.",
+ "type": "boolean"
+ },
"^(policiesAllowedHostnames)$": {
"description": "array of hostnames that are allowed to be used in the policies",
"items": {
@@ -54,6 +58,10 @@
"description": "organization name",
"type": "string"
},
+ "pii_redaction": {
+ "description": "Replace the head commit author and the PR/MR author and reviewer logins with \"[REDACTED]\".\n The control plane enforces it at push.",
+ "type": "boolean"
+ },
"policies_allowed_hostnames": {
"description": "array of hostnames that are allowed to be used in the policies",
"items": {
diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.OrgItem.jsonschema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.OrgItem.jsonschema.json
index de9e24f6c..4eeed5e72 100644
--- a/app/controlplane/api/gen/jsonschema/controlplane.v1.OrgItem.jsonschema.json
+++ b/app/controlplane/api/gen/jsonschema/controlplane.v1.OrgItem.jsonschema.json
@@ -42,6 +42,10 @@
"$ref": "controlplane.v1.EnvVarRedaction.jsonschema.json",
"description": "Redaction of the values of environment variables stored in new attestations"
},
+ "^(pii_redaction)$": {
+ "description": "Whether personal data is replaced with \"[REDACTED]\" in new attestations: the known identity env vars,\n the head commit author, and the PR/MR author and reviewer logins",
+ "type": "boolean"
+ },
"^(policy_allowed_hostnames)$": {
"items": {
"type": "string"
@@ -110,6 +114,10 @@
"name": {
"type": "string"
},
+ "piiRedaction": {
+ "description": "Whether personal data is replaced with \"[REDACTED]\" in new attestations: the known identity env vars,\n the head commit author, and the PR/MR author and reviewer logins",
+ "type": "boolean"
+ },
"policyAllowedHostnames": {
"items": {
"type": "string"
diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.OrgItem.schema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.OrgItem.schema.json
index 86338188d..fdf40154c 100644
--- a/app/controlplane/api/gen/jsonschema/controlplane.v1.OrgItem.schema.json
+++ b/app/controlplane/api/gen/jsonschema/controlplane.v1.OrgItem.schema.json
@@ -42,6 +42,10 @@
"$ref": "controlplane.v1.EnvVarRedaction.schema.json",
"description": "Redaction of the values of environment variables stored in new attestations"
},
+ "^(piiRedaction)$": {
+ "description": "Whether personal data is replaced with \"[REDACTED]\" in new attestations: the known identity env vars,\n the head commit author, and the PR/MR author and reviewer logins",
+ "type": "boolean"
+ },
"^(policyAllowedHostnames)$": {
"items": {
"type": "string"
@@ -110,6 +114,10 @@
"name": {
"type": "string"
},
+ "pii_redaction": {
+ "description": "Whether personal data is replaced with \"[REDACTED]\" in new attestations: the known identity env vars,\n the head commit author, and the PR/MR author and reviewer logins",
+ "type": "boolean"
+ },
"policy_allowed_hostnames": {
"items": {
"type": "string"
diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.OrganizationServiceUpdateRequest.jsonschema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.OrganizationServiceUpdateRequest.jsonschema.json
index 361c3b581..1cd2d3120 100644
--- a/app/controlplane/api/gen/jsonschema/controlplane.v1.OrganizationServiceUpdateRequest.jsonschema.json
+++ b/app/controlplane/api/gen/jsonschema/controlplane.v1.OrganizationServiceUpdateRequest.jsonschema.json
@@ -23,7 +23,11 @@
},
"^(env_var_redaction)$": {
"$ref": "controlplane.v1.EnvVarRedaction.jsonschema.json",
- "description": "Redaction of environment variable values in new attestations. Not set means no change."
+ "description": "Redaction of environment variable values in new attestations. Not set means no change.\n TYPE_KNOWN_IDENTITY is deprecated: the control plane turns it into pii_redaction = true."
+ },
+ "^(pii_redaction)$": {
+ "description": "Replace personal data with \"[REDACTED]\" in new attestations: the known identity env vars,\n the head commit author, and the PR/MR author and reviewer logins. Not set means no change.",
+ "type": "boolean"
},
"^(policies_allowed_hostnames)$": {
"description": "array of hostnames that are allowed to be used in the policies",
@@ -70,12 +74,16 @@
},
"envVarRedaction": {
"$ref": "controlplane.v1.EnvVarRedaction.jsonschema.json",
- "description": "Redaction of environment variable values in new attestations. Not set means no change."
+ "description": "Redaction of environment variable values in new attestations. Not set means no change.\n TYPE_KNOWN_IDENTITY is deprecated: the control plane turns it into pii_redaction = true."
},
"name": {
"minLength": 1,
"type": "string"
},
+ "piiRedaction": {
+ "description": "Replace personal data with \"[REDACTED]\" in new attestations: the known identity env vars,\n the head commit author, and the PR/MR author and reviewer logins. Not set means no change.",
+ "type": "boolean"
+ },
"policiesAllowedHostnames": {
"description": "array of hostnames that are allowed to be used in the policies",
"items": {
diff --git a/app/controlplane/api/gen/jsonschema/controlplane.v1.OrganizationServiceUpdateRequest.schema.json b/app/controlplane/api/gen/jsonschema/controlplane.v1.OrganizationServiceUpdateRequest.schema.json
index fd284174b..863eaf398 100644
--- a/app/controlplane/api/gen/jsonschema/controlplane.v1.OrganizationServiceUpdateRequest.schema.json
+++ b/app/controlplane/api/gen/jsonschema/controlplane.v1.OrganizationServiceUpdateRequest.schema.json
@@ -23,7 +23,11 @@
},
"^(envVarRedaction)$": {
"$ref": "controlplane.v1.EnvVarRedaction.schema.json",
- "description": "Redaction of environment variable values in new attestations. Not set means no change."
+ "description": "Redaction of environment variable values in new attestations. Not set means no change.\n TYPE_KNOWN_IDENTITY is deprecated: the control plane turns it into pii_redaction = true."
+ },
+ "^(piiRedaction)$": {
+ "description": "Replace personal data with \"[REDACTED]\" in new attestations: the known identity env vars,\n the head commit author, and the PR/MR author and reviewer logins. Not set means no change.",
+ "type": "boolean"
},
"^(policiesAllowedHostnames)$": {
"description": "array of hostnames that are allowed to be used in the policies",
@@ -70,12 +74,16 @@
},
"env_var_redaction": {
"$ref": "controlplane.v1.EnvVarRedaction.schema.json",
- "description": "Redaction of environment variable values in new attestations. Not set means no change."
+ "description": "Redaction of environment variable values in new attestations. Not set means no change.\n TYPE_KNOWN_IDENTITY is deprecated: the control plane turns it into pii_redaction = true."
},
"name": {
"minLength": 1,
"type": "string"
},
+ "pii_redaction": {
+ "description": "Replace personal data with \"[REDACTED]\" in new attestations: the known identity env vars,\n the head commit author, and the PR/MR author and reviewer logins. Not set means no change.",
+ "type": "boolean"
+ },
"policies_allowed_hostnames": {
"description": "array of hostnames that are allowed to be used in the policies",
"items": {
diff --git a/app/controlplane/internal/service/attestation.go b/app/controlplane/internal/service/attestation.go
index 75a0def41..ecb220e14 100644
--- a/app/controlplane/internal/service/attestation.go
+++ b/app/controlplane/internal/service/attestation.go
@@ -235,10 +235,11 @@ func (s *AttestationService) Init(ctx context.Context, req *cpAPI.AttestationSer
SkipRunnerEnvVars: org.SkipRunnerEnvVars,
}
- resp.RedactedEnvVars, err = org.EnvVarRedaction.Names()
+ resp.RedactedEnvVars, err = org.RedactedEnvVars()
if err != nil {
return nil, handleUseCaseErr(ctx, err, s.log)
}
+ resp.PiiRedaction = org.PIIRedaction
resp.SigningOptions = &cpAPI.AttestationServiceInitResponse_SigningOptions{}
tsa := s.signingUseCase.GetCurrentTSA()
diff --git a/app/controlplane/internal/service/context.go b/app/controlplane/internal/service/context.go
index 5a820200a..1acc3af51 100644
--- a/app/controlplane/internal/service/context.go
+++ b/app/controlplane/internal/service/context.go
@@ -129,6 +129,7 @@ func bizOrgToPb(m *biz.Organization) *pb.OrgItem {
BlockAttestationsOnReleasedVersions: m.BlockAttestationsOnReleasedVersions,
SkipRunnerEnvVars: m.SkipRunnerEnvVars,
EnvVarRedaction: bizEnvVarRedactionToPb(m.EnvVarRedaction),
+ PiiRedaction: m.PIIRedaction,
}
if m.APITokenInactivityThresholdDays != nil {
diff --git a/app/controlplane/internal/service/organization.go b/app/controlplane/internal/service/organization.go
index 94d18f99c..5eb518d74 100644
--- a/app/controlplane/internal/service/organization.go
+++ b/app/controlplane/internal/service/organization.go
@@ -126,6 +126,7 @@ func (s *OrganizationService) Update(ctx context.Context, req *pb.OrganizationSe
BlockAttestationsOnReleasedVersions: req.BlockAttestationsOnReleasedVersions,
SkipRunnerEnvVars: req.SkipRunnerEnvVars,
EnvVarRedaction: pbEnvVarRedactionToBiz(req.EnvVarRedaction),
+ PIIRedaction: req.PiiRedaction,
})
if err != nil {
return nil, handleUseCaseErr(ctx, err, s.log)
diff --git a/app/controlplane/pkg/biz/organization.go b/app/controlplane/pkg/biz/organization.go
index 146b4735f..a96cf3724 100644
--- a/app/controlplane/pkg/biz/organization.go
+++ b/app/controlplane/pkg/biz/organization.go
@@ -20,11 +20,13 @@ import (
"errors"
"fmt"
"io"
+ "slices"
"time"
"github.com/chainloop-dev/chainloop/app/controlplane/pkg/auditor/events"
"github.com/chainloop-dev/chainloop/app/controlplane/pkg/authz"
config "github.com/chainloop-dev/chainloop/app/controlplane/pkg/conf/controlplane/config/v1"
+ "github.com/chainloop-dev/chainloop/pkg/attestation/crafter/runners"
"github.com/chainloop-dev/chainloop/pkg/attestation/envredaction"
"github.com/chainloop-dev/chainloop/pkg/otelx"
"github.com/chainloop-dev/chainloop/pkg/servicelogger"
@@ -57,6 +59,9 @@ type Organization struct {
SkipRunnerEnvVars bool
// EnvVarRedaction replaces the values of selected env vars with a placeholder in new attestations. nil = no redaction
EnvVarRedaction *EnvVarRedaction
+ // PIIRedaction replaces personal data with a placeholder in new attestations: the known identity
+ // env vars, the head commit author, and the PR/MR author and reviewer logins
+ PIIRedaction bool
// Suspended indicates whether the organization is suspended
Suspended bool
}
@@ -76,6 +81,28 @@ func (r *EnvVarRedaction) Names() ([]string, error) {
return envredaction.Names(r.Mode, r.EnvVars)
}
+// RedactedEnvVars returns the names of the env vars that the organization redacts: the known
+// identity variables when PII redaction is on, and the custom env var redaction list.
+func (o *Organization) RedactedEnvVars() ([]string, error) {
+ if o == nil {
+ return nil, nil
+ }
+
+ names, err := o.EnvVarRedaction.Names()
+ if err != nil {
+ return nil, err
+ }
+
+ // Clone so that sorting does not change the stored setting
+ names = slices.Clone(names)
+ if o.PIIRedaction {
+ names = append(names, runners.KnownIdentityEnvVars()...)
+ }
+
+ slices.Sort(names)
+ return slices.Compact(names), nil
+}
+
// normalize validates the setting and returns the value to store. Only the custom mode keeps
// the variable list, and an empty mode becomes ModeNone, which the repository clears.
func (r *EnvVarRedaction) normalize() (*EnvVarRedaction, error) {
@@ -107,6 +134,7 @@ type OrganizationUpdateOpts struct {
SkipRunnerEnvVars *bool
// EnvVarRedaction nil means no change. A value with envredaction.ModeNone clears the setting.
EnvVarRedaction *EnvVarRedaction
+ PIIRedaction *bool
}
type OrganizationRepo interface {
@@ -277,6 +305,16 @@ func (uc *OrganizationUseCase) Update(ctx context.Context, userID, orgName strin
// Copy so the caller's opts are not changed
o := *opts
o.EnvVarRedaction = normalized
+
+ // The known identity mode is deprecated: PII redaction includes its variables.
+ // Older clients still send it, so it turns PII redaction on and clears the env var setting.
+ if normalized.Mode == envredaction.ModeKnownIdentity {
+ if o.PIIRedaction != nil && !*o.PIIRedaction {
+ return nil, NewErrValidationStr("the known identity env var redaction mode requires PII redaction, which is turned off in the same request")
+ }
+ o.PIIRedaction = ToPtr(true)
+ o.EnvVarRedaction = &EnvVarRedaction{Mode: envredaction.ModeNone}
+ }
opts = &o
}
diff --git a/app/controlplane/pkg/biz/organization_integration_test.go b/app/controlplane/pkg/biz/organization_integration_test.go
index cf9c9e93c..57ca19119 100644
--- a/app/controlplane/pkg/biz/organization_integration_test.go
+++ b/app/controlplane/pkg/biz/organization_integration_test.go
@@ -40,6 +40,9 @@ import (
"github.com/stretchr/testify/suite"
)
+// a custom env var that the redaction tests use
+const ownerEnvVar = "MY_OWNER"
+
func (s *OrgIntegrationTestSuite) TestCreateWithRandomName() {
// It can create thousands of orgs without any problem
for i := 0; i < 1000; i++ {
@@ -185,22 +188,52 @@ func (s *OrgIntegrationTestSuite) TestUpdate() {
s.False(got.SkipRunnerEnvVars)
})
- s.Run("env var redaction update", func() {
+ s.Run("env var and PII redaction update", func() {
testCases := []struct {
name string
in *biz.EnvVarRedaction
+ inPII *bool
want *biz.EnvVarRedaction
+ wantPII bool
wantErr bool
}{
{
- name: "known identity",
- in: &biz.EnvVarRedaction{Mode: envredaction.ModeKnownIdentity},
- want: &biz.EnvVarRedaction{Mode: envredaction.ModeKnownIdentity},
+ name: "PII redaction on",
+ inPII: toPtrBool(true),
+ wantPII: true,
+ },
+ {
+ name: "PII redaction off",
+ inPII: toPtrBool(false),
+ },
+ {
+ name: "deprecated known identity turns on PII redaction",
+ in: &biz.EnvVarRedaction{Mode: envredaction.ModeKnownIdentity},
+ wantPII: true,
+ },
+ {
+ name: "deprecated known identity drops a custom list",
+ in: &biz.EnvVarRedaction{Mode: envredaction.ModeKnownIdentity, EnvVars: []string{"OTHER_VAR"}},
+ wantPII: true,
},
{
- name: "custom list",
- in: &biz.EnvVarRedaction{Mode: envredaction.ModeCustom, EnvVars: []string{"BUILD_REQUESTEDFOR", "MY_OWNER"}},
- want: &biz.EnvVarRedaction{Mode: envredaction.ModeCustom, EnvVars: []string{"BUILD_REQUESTEDFOR", "MY_OWNER"}},
+ name: "deprecated known identity with PII redaction off is rejected",
+ in: &biz.EnvVarRedaction{Mode: envredaction.ModeKnownIdentity},
+ inPII: toPtrBool(false),
+ wantErr: true,
+ },
+ {
+ name: "custom list and PII redaction together",
+ in: &biz.EnvVarRedaction{Mode: envredaction.ModeCustom, EnvVars: []string{"BUILD_REQUESTEDFOR", ownerEnvVar}},
+ inPII: toPtrBool(true),
+ want: &biz.EnvVarRedaction{Mode: envredaction.ModeCustom, EnvVars: []string{"BUILD_REQUESTEDFOR", ownerEnvVar}},
+ wantPII: true,
+ },
+ {
+ name: "custom list",
+ in: &biz.EnvVarRedaction{Mode: envredaction.ModeCustom, EnvVars: []string{ownerEnvVar}},
+ inPII: toPtrBool(false),
+ want: &biz.EnvVarRedaction{Mode: envredaction.ModeCustom, EnvVars: []string{ownerEnvVar}},
},
{
name: "custom without variables is rejected",
@@ -213,14 +246,10 @@ func (s *OrgIntegrationTestSuite) TestUpdate() {
wantErr: true,
},
{
- name: "known identity drops a custom list",
- in: &biz.EnvVarRedaction{Mode: envredaction.ModeKnownIdentity, EnvVars: []string{"OTHER_VAR"}},
- want: &biz.EnvVarRedaction{Mode: envredaction.ModeKnownIdentity},
- },
- {
- name: "none clears the setting",
- in: &biz.EnvVarRedaction{Mode: envredaction.ModeNone},
- want: nil,
+ name: "none clears the setting",
+ in: &biz.EnvVarRedaction{Mode: envredaction.ModeNone},
+ inPII: toPtrBool(false),
+ want: nil,
},
}
@@ -228,6 +257,7 @@ func (s *OrgIntegrationTestSuite) TestUpdate() {
s.Run(tc.name, func() {
got, err := s.Organization.Update(ctx, s.user.ID, s.org.Name, &biz.OrganizationUpdateOpts{
EnvVarRedaction: tc.in,
+ PIIRedaction: tc.inPII,
})
if tc.wantErr {
s.Error(err)
@@ -236,23 +266,27 @@ func (s *OrgIntegrationTestSuite) TestUpdate() {
}
s.NoError(err)
s.Equal(tc.want, got.EnvVarRedaction)
+ s.Equal(tc.wantPII, got.PIIRedaction)
// it is persisted
stored, err := s.Organization.FindByName(ctx, s.org.Name)
s.NoError(err)
s.Equal(tc.want, stored.EnvVarRedaction)
+ s.Equal(tc.wantPII, stored.PIIRedaction)
})
}
s.Run("not passing a value doesn't change it", func() {
_, err := s.Organization.Update(ctx, s.user.ID, s.org.Name, &biz.OrganizationUpdateOpts{
- EnvVarRedaction: &biz.EnvVarRedaction{Mode: envredaction.ModeKnownIdentity},
+ EnvVarRedaction: &biz.EnvVarRedaction{Mode: envredaction.ModeCustom, EnvVars: []string{ownerEnvVar}},
+ PIIRedaction: toPtrBool(true),
})
s.NoError(err)
got, err := s.Organization.Update(ctx, s.user.ID, s.org.Name, &biz.OrganizationUpdateOpts{SkipRunnerEnvVars: toPtrBool(false)})
s.NoError(err)
- s.Equal(&biz.EnvVarRedaction{Mode: envredaction.ModeKnownIdentity}, got.EnvVarRedaction)
+ s.Equal(&biz.EnvVarRedaction{Mode: envredaction.ModeCustom, EnvVars: []string{ownerEnvVar}}, got.EnvVarRedaction)
+ s.True(got.PIIRedaction)
})
})
diff --git a/app/controlplane/pkg/biz/redaction_test.go b/app/controlplane/pkg/biz/redaction_test.go
new file mode 100644
index 000000000..d9f4e2619
--- /dev/null
+++ b/app/controlplane/pkg/biz/redaction_test.go
@@ -0,0 +1,193 @@
+//
+// Copyright 2026 The Chainloop Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package biz
+
+import (
+ "testing"
+
+ schemaapi "github.com/chainloop-dev/chainloop/app/controlplane/api/workflowcontract/v1"
+ attestationapi "github.com/chainloop-dev/chainloop/pkg/attestation/crafter/api/attestation/v1"
+ "github.com/chainloop-dev/chainloop/pkg/attestation/crafter/runners"
+ "github.com/chainloop-dev/chainloop/pkg/attestation/envredaction"
+ "github.com/chainloop-dev/chainloop/pkg/attestation/renderer/chainloop"
+ intoto "github.com/in-toto/attestation/go/v1"
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+ "google.golang.org/protobuf/types/known/structpb"
+)
+
+const (
+ myOwnerVar = "MY_OWNER"
+ clearNameErr = "the commit author name must be redacted"
+)
+
+func TestOrganizationRedactedEnvVars(t *testing.T) {
+ known := runners.KnownIdentityEnvVars()
+
+ testCases := []struct {
+ name string
+ org *Organization
+ want []string
+ }{
+ {name: "nil organization", org: nil},
+ {name: "no redaction", org: &Organization{}},
+ {name: "PII redaction", org: &Organization{PIIRedaction: true}, want: known},
+ {
+ name: "custom list",
+ org: &Organization{EnvVarRedaction: &EnvVarRedaction{Mode: envredaction.ModeCustom, EnvVars: []string{myOwnerVar}}},
+ want: []string{myOwnerVar},
+ },
+ {
+ name: "PII redaction adds the custom list, with no duplicates",
+ org: &Organization{
+ PIIRedaction: true,
+ EnvVarRedaction: &EnvVarRedaction{Mode: envredaction.ModeCustom, EnvVars: []string{myOwnerVar, known[0]}},
+ },
+ want: append([]string{myOwnerVar}, known...),
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ got, err := tc.org.RedactedEnvVars()
+ require.NoError(t, err)
+ assert.ElementsMatch(t, tc.want, got)
+ })
+ }
+
+ t.Run("does not change the stored list", func(t *testing.T) {
+ stored := []string{"B", "A", "B"}
+ org := &Organization{EnvVarRedaction: &EnvVarRedaction{Mode: envredaction.ModeCustom, EnvVars: stored}}
+ got, err := org.RedactedEnvVars()
+ require.NoError(t, err)
+ assert.Equal(t, []string{"A", "B"}, got)
+ assert.Equal(t, []string{"B", "A", "B"}, stored)
+ })
+}
+
+// stubPredicate returns only the materials, which is all that the PII check reads from the predicate
+type stubPredicate struct {
+ chainloop.NormalizablePredicate
+ materials []*chainloop.NormalizedMaterial
+}
+
+func (p *stubPredicate) GetMaterials() []*chainloop.NormalizedMaterial {
+ return p.materials
+}
+
+func TestValidatePIIRedaction(t *testing.T) {
+ gitHead := func(name, email string) *intoto.ResourceDescriptor {
+ annotations, err := structpb.NewStruct(map[string]any{
+ chainloop.SubjectGitAnnotationAuthorName: name,
+ chainloop.SubjectGitAnnotationAuthorEmail: email,
+ })
+ require.NoError(t, err)
+ return &intoto.ResourceDescriptor{Name: chainloop.SubjectGitHead, Annotations: annotations}
+ }
+
+ prInfo := func(name string, marked bool) *chainloop.NormalizedMaterial {
+ m := &chainloop.NormalizedMaterial{Name: name, Type: schemaapi.CraftingSchema_Material_CHAINLOOP_PR_INFO.String(), Annotations: map[string]string{}}
+ if marked {
+ m.Annotations[attestationapi.AnnotationMaterialPIIRedacted] = attestationapi.AnnotationValueTrue
+ }
+ return m
+ }
+
+ redacted := envredaction.RedactedValue
+ piiOn := &Organization{PIIRedaction: true}
+
+ testCases := []struct {
+ name string
+ org *Organization
+ subjects []*intoto.ResourceDescriptor
+ materials []*chainloop.NormalizedMaterial
+ wantErr string
+ }{
+ {name: "nil organization", subjects: []*intoto.ResourceDescriptor{gitHead("John", "john@example.com")}},
+ {
+ name: "setting off accepts clear values",
+ org: &Organization{},
+ subjects: []*intoto.ResourceDescriptor{gitHead("John", "john@example.com")},
+ materials: []*chainloop.NormalizedMaterial{prInfo("pr", false)},
+ },
+ {
+ name: "redacted author and marked PR info are accepted",
+ org: piiOn,
+ subjects: []*intoto.ResourceDescriptor{gitHead(redacted, redacted)},
+ materials: []*chainloop.NormalizedMaterial{prInfo("pr", true)},
+ },
+ {
+ name: "empty email is accepted",
+ org: piiOn,
+ subjects: []*intoto.ResourceDescriptor{gitHead(redacted, "")},
+ },
+ {name: "no commit and no PR info is accepted", org: piiOn},
+ {
+ name: "clear author name is rejected",
+ org: piiOn,
+ subjects: []*intoto.ResourceDescriptor{gitHead("John", redacted)},
+ wantErr: clearNameErr,
+ },
+ {
+ name: "clear author email is rejected",
+ org: piiOn,
+ subjects: []*intoto.ResourceDescriptor{gitHead(redacted, "john@example.com")},
+ wantErr: "the commit author email must be redacted",
+ },
+ {
+ name: "all violations are named",
+ org: piiOn,
+ subjects: []*intoto.ResourceDescriptor{gitHead("John", "john@example.com")},
+ materials: []*chainloop.NormalizedMaterial{prInfo("pr-1", false), prInfo("pr-2", true)},
+ wantErr: `the commit author name, the commit author email, the PR info material "pr-1" must be redacted`,
+ },
+ {
+ name: "a second git.head subject with a clear author is rejected",
+ org: piiOn,
+ subjects: []*intoto.ResourceDescriptor{gitHead(redacted, redacted), gitHead("John", "")},
+ wantErr: clearNameErr,
+ },
+ {
+ name: "an author that is not a string is rejected",
+ org: piiOn,
+ subjects: func() []*intoto.ResourceDescriptor {
+ annotations, err := structpb.NewStruct(map[string]any{chainloop.SubjectGitAnnotationAuthorName: map[string]any{"first": "John"}})
+ require.NoError(t, err)
+ return []*intoto.ResourceDescriptor{{Name: chainloop.SubjectGitHead, Annotations: annotations}}
+ }(),
+ wantErr: clearNameErr,
+ },
+ {
+ name: "other materials are not checked",
+ org: piiOn,
+ materials: []*chainloop.NormalizedMaterial{{Name: "image", Type: schemaapi.CraftingSchema_Material_SBOM_CYCLONEDX_JSON.String()}},
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ err := validatePIIRedaction(tc.org, &intoto.Statement{Subject: tc.subjects}, &stubPredicate{materials: tc.materials})
+ if tc.wantErr == "" {
+ require.NoError(t, err)
+ return
+ }
+
+ require.Error(t, err)
+ assert.True(t, IsErrValidation(err))
+ assert.ErrorContains(t, err, tc.wantErr)
+ })
+ }
+}
diff --git a/app/controlplane/pkg/biz/workflowrun.go b/app/controlplane/pkg/biz/workflowrun.go
index 53c163cbb..962ecf0c4 100644
--- a/app/controlplane/pkg/biz/workflowrun.go
+++ b/app/controlplane/pkg/biz/workflowrun.go
@@ -43,6 +43,7 @@ import (
"github.com/go-kratos/kratos/v2/log"
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/uuid"
+ intoto "github.com/in-toto/attestation/go/v1"
)
var workflowRunTracer = otelx.Tracer("chainloop-controlplane", "biz/workflowrun")
@@ -483,7 +484,7 @@ func (uc *WorkflowRunUseCase) runOrg(ctx context.Context, run *WorkflowRun) (*Or
// ValidateAttestationContract call it, so they reach the same verdict.
// org is the organization of the run, nil when the run has no workflow loaded.
// It returns the contract schema it validated against.
-func (uc *WorkflowRunUseCase) validatePredicate(ctx context.Context, run *WorkflowRun, org *Organization, predicate chainloop.NormalizablePredicate) (*schemaapi.CraftingSchema, error) {
+func (uc *WorkflowRunUseCase) validatePredicate(ctx context.Context, run *WorkflowRun, org *Organization, statement *intoto.Statement, predicate chainloop.NormalizablePredicate) (*schemaapi.CraftingSchema, error) {
schema, err := uc.validateAgainstContract(ctx, run, predicate)
if err != nil {
return nil, err
@@ -493,6 +494,10 @@ func (uc *WorkflowRunUseCase) validatePredicate(ctx context.Context, run *Workfl
return nil, err
}
+ if err := validatePIIRedaction(org, statement, predicate); err != nil {
+ return nil, err
+ }
+
return schema, nil
}
@@ -507,20 +512,62 @@ func validateEnvVarRedaction(org *Organization, predicate chainloop.Normalizable
return nil
}
- names, err := org.EnvVarRedaction.Names()
+ names, err := org.RedactedEnvVars()
if err != nil {
return fmt.Errorf("resolving env var redaction: %w", err)
}
if violations := envredaction.Violations(predicate.GetEnvVars(), names); len(violations) > 0 {
return NewErrValidation(fmt.Errorf(
- "environment variables %s must have the value %s because of the organization env var redaction setting. Update the Chainloop CLI, or run the attestation again if the setting changed during the run",
+ "environment variables %s must have the value %s because of the organization redaction settings. Update the Chainloop CLI, or run the attestation again if the setting changed during the run",
strings.Join(violations, ", "), envredaction.RedactedValue))
}
return nil
}
+// validatePIIRedaction rejects an attestation that stores the clear author of the
+// head commit, or a PR info material that the CLI did not redact, when the
+// organization has PII redaction on.
+//
+// The commit author is in the signed statement, so the check reads it. The control
+// plane sees only the digest of an uploaded PR info material, so the check reads
+// the redaction mark that the CLI adds to the material.
+func validatePIIRedaction(org *Organization, statement *intoto.Statement, predicate chainloop.NormalizablePredicate) error {
+ if org == nil || !org.PIIRedaction {
+ return nil
+ }
+
+ var clearName, clearEmail bool
+ for _, author := range chainloop.GitHeadAuthors(statement) {
+ clearName = clearName || envredaction.IsClear(author.Name)
+ clearEmail = clearEmail || envredaction.IsClear(author.Email)
+ }
+
+ var violations []string
+ if clearName {
+ violations = append(violations, "the commit author name")
+ }
+ if clearEmail {
+ violations = append(violations, "the commit author email")
+ }
+
+ for _, m := range predicate.GetMaterials() {
+ if m.Type == schemaapi.CraftingSchema_Material_CHAINLOOP_PR_INFO.String() &&
+ m.Annotations[attestationapi.AnnotationMaterialPIIRedacted] != attestationapi.AnnotationValueTrue {
+ violations = append(violations, fmt.Sprintf("the PR info material %q", m.Name))
+ }
+ }
+
+ if len(violations) > 0 {
+ return NewErrValidation(fmt.Errorf(
+ "%s must be redacted because of the organization PII redaction setting. Update the Chainloop CLI, or run the attestation again if the setting changed during the run",
+ strings.Join(violations, ", ")))
+ }
+
+ return nil
+}
+
// ValidateAttestationContract checks a bundle's signature and the contract
// revision pinned on its workflow run without persisting anything.
//
@@ -553,7 +600,12 @@ func (uc *WorkflowRunUseCase) ValidateAttestationContract(ctx context.Context, r
return fmt.Errorf("extracting DSSE envelope: %w", err)
}
- predicate, err := chainloop.ExtractPredicate(dsseEnv)
+ statement, err := chainloop.ExtractStatement(dsseEnv)
+ if err != nil {
+ return fmt.Errorf("extracting statement: %w", err)
+ }
+
+ predicate, err := chainloop.PredicateFromStatement(statement)
if err != nil {
return fmt.Errorf("extracting predicate: %w", err)
}
@@ -563,7 +615,7 @@ func (uc *WorkflowRunUseCase) ValidateAttestationContract(ctx context.Context, r
return err
}
- _, err = uc.validatePredicate(ctx, run, org, predicate)
+ _, err = uc.validatePredicate(ctx, run, org, statement, predicate)
return err
}
@@ -658,7 +710,12 @@ func (uc *WorkflowRunUseCase) SaveAttestation(ctx context.Context, id string, bu
}
// extract statement to run some validations in the content
- predicate, err := chainloop.ExtractPredicate(dsseEnv)
+ statement, err := chainloop.ExtractStatement(dsseEnv)
+ if err != nil {
+ return nil, fmt.Errorf("extracting statement: %w", err)
+ }
+
+ predicate, err := chainloop.PredicateFromStatement(statement)
if err != nil {
return nil, fmt.Errorf("extracting predicate: %w", err)
}
@@ -681,7 +738,7 @@ func (uc *WorkflowRunUseCase) SaveAttestation(ctx context.Context, id string, bu
}
}
- contractSchema, err := uc.validatePredicate(ctx, run, org, predicate)
+ contractSchema, err := uc.validatePredicate(ctx, run, org, statement, predicate)
if err != nil {
return nil, err
}
diff --git a/app/controlplane/pkg/biz/workflowrun_contract_integration_test.go b/app/controlplane/pkg/biz/workflowrun_contract_integration_test.go
index f585b1d6d..7e9e44c28 100644
--- a/app/controlplane/pkg/biz/workflowrun_contract_integration_test.go
+++ b/app/controlplane/pkg/biz/workflowrun_contract_integration_test.go
@@ -39,6 +39,8 @@ import (
const (
attestationFull = "testdata/attestations/full.json"
attestationEmpty = "testdata/attestations/empty.json"
+ // carries a git.head subject with a clear author name and email
+ attestationGitSubject = "testdata/attestations/with-git-subject.json"
)
// The contract is what the organization agreed the run had to produce. It has
@@ -271,25 +273,33 @@ func (s *workflowRunContractIntegrationTestSuite) TestValidateAttestationContrac
})
}
-// The CLI redacts env vars before it signs, so an older or modified CLI can push
-// the real values. The control plane checks the org setting at push time.
+// The CLI redacts env vars and the commit author before it signs, so an older or
+// modified CLI can push the real values. The control plane checks the org settings at push time.
// full.json carries the env vars {"owner": "john-c@chainloop.dev", "project": "chatgpt"}.
-func (s *workflowRunContractIntegrationTestSuite) TestSaveAttestationEnforcesEnvVarRedaction() {
+func (s *workflowRunContractIntegrationTestSuite) TestSaveAttestationEnforcesRedaction() {
// env var name in full.json
const projectEnvVar = "project"
testCases := []struct {
name string
redaction *biz.EnvVarRedaction
+ pii bool
attestation string
wantErr string
}{
{name: "no redaction accepts clear values", attestation: attestationFull},
+ {name: "no redaction accepts a clear commit author", attestation: attestationGitSubject},
{
- name: "known identity with no identity vars in the attestation is accepted",
- redaction: &biz.EnvVarRedaction{Mode: envredaction.ModeKnownIdentity},
+ name: "PII redaction with no identity vars or commit in the attestation is accepted",
+ pii: true,
attestation: attestationFull,
},
+ {
+ name: "PII redaction rejects a clear commit author",
+ pii: true,
+ attestation: attestationGitSubject,
+ wantErr: "the commit author name, the commit author email must be redacted because of the organization PII redaction setting",
+ },
{
name: "custom redaction of a variable that is absent is accepted",
redaction: &biz.EnvVarRedaction{Mode: envredaction.ModeCustom, EnvVars: []string{"GITHUB_ACTOR"}},
@@ -311,7 +321,7 @@ func (s *workflowRunContractIntegrationTestSuite) TestSaveAttestationEnforcesEnv
for i, tc := range testCases {
s.Run(tc.name, func() {
ctx := context.Background()
- s.setOrgEnvVarRedaction(ctx, tc.redaction)
+ s.setOrgRedaction(ctx, tc.redaction, tc.pii)
run := s.newRunWithContract(fmt.Sprintf("redaction-%d", i), " materials: []")
bundleBytes := testhelpers.BundleBytesFromEnvelope(s.T(), tc.attestation)
@@ -338,14 +348,14 @@ func (s *workflowRunContractIntegrationTestSuite) TestSaveAttestationEnforcesEnv
}
}
-func (s *workflowRunContractIntegrationTestSuite) setOrgEnvVarRedaction(ctx context.Context, r *biz.EnvVarRedaction) {
+func (s *workflowRunContractIntegrationTestSuite) setOrgRedaction(ctx context.Context, r *biz.EnvVarRedaction, pii bool) {
s.T().Helper()
orgUUID, err := uuid.Parse(s.org.ID)
require.NoError(s.T(), err)
if r == nil {
r = &biz.EnvVarRedaction{Mode: envredaction.ModeNone}
}
- _, err = s.Repos.OrganizationRepo.Update(ctx, orgUUID, &biz.OrganizationUpdateOpts{EnvVarRedaction: r})
+ _, err = s.Repos.OrganizationRepo.Update(ctx, orgUUID, &biz.OrganizationUpdateOpts{EnvVarRedaction: r, PIIRedaction: &pii})
require.NoError(s.T(), err)
}
diff --git a/app/controlplane/pkg/data/ent/migrate/migrations/20261205004604.sql b/app/controlplane/pkg/data/ent/migrate/migrations/20261205004604.sql
new file mode 100644
index 000000000..4f13c6547
--- /dev/null
+++ b/app/controlplane/pkg/data/ent/migrate/migrations/20261205004604.sql
@@ -0,0 +1,4 @@
+-- Modify "organizations" table
+ALTER TABLE "organizations" ADD COLUMN "pii_redaction" boolean NOT NULL DEFAULT false;
+-- The known identity mode of env var redaction becomes the PII redaction setting
+UPDATE "organizations" SET "pii_redaction" = true, "env_var_redaction" = NULL WHERE "env_var_redaction"->>'mode' = 'known-identity';
diff --git a/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum b/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum
index 5430b58e7..22ccd7576 100644
--- a/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum
+++ b/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum
@@ -1,4 +1,4 @@
-h1:NaN66TTuSxozRg1B/ARWWhfUSdFYVFDwoR6dmNaJAwc=
+h1:iSyubNczGk/+AxaKeYCYEoW+LjbWIjEZfa3/phjKkH0=
20230706165452_init-schema.sql h1:VvqbNFEQnCvUVyj2iDYVQQxDM0+sSXqocpt/5H64k8M=
20230710111950-cas-backend.sql h1:A8iBuSzZIEbdsv9ipBtscZQuaBp3V5/VMw7eZH6GX+g=
20230712094107-cas-backends-workflow-runs.sql h1:a5rzxpVGyd56nLRSsKrmCFc9sebg65RWzLghKHh5xvI=
@@ -149,3 +149,4 @@ h1:NaN66TTuSxozRg1B/ARWWhfUSdFYVFDwoR6dmNaJAwc=
20261117162118.sql h1:kihy12JzE5ELo0Jy79LjMs8X4BBgmCjsh8Q1kpFp60c=
20261123100446.sql h1:m6G8YK7prIatRFKx10ZE1mL3qkL7W1pAcQm3vDwML24=
20261130191056.sql h1:pIT59TQwRU/ZBsSdBJjSEE4dOjbmclXbLWI4Upt7X+0=
+20261205004604.sql h1:vEcXpkw9lM8pazpbkjJHp4B4dtt4rRs2yuWmcp1V9sI=
diff --git a/app/controlplane/pkg/data/ent/migrate/schema.go b/app/controlplane/pkg/data/ent/migrate/schema.go
index 43a03fc69..88a6719fe 100644
--- a/app/controlplane/pkg/data/ent/migrate/schema.go
+++ b/app/controlplane/pkg/data/ent/migrate/schema.go
@@ -498,6 +498,7 @@ var (
{Name: "block_attestations_on_released_versions", Type: field.TypeBool, Default: false},
{Name: "skip_runner_env_vars", Type: field.TypeBool, Default: false},
{Name: "env_var_redaction", Type: field.TypeJSON, Nullable: true},
+ {Name: "pii_redaction", Type: field.TypeBool, Default: false},
{Name: "suspended", Type: field.TypeBool, Default: false},
}
// OrganizationsTable holds the schema information for the "organizations" table.
diff --git a/app/controlplane/pkg/data/ent/mutation.go b/app/controlplane/pkg/data/ent/mutation.go
index 0e13e5d0d..9b07cf681 100644
--- a/app/controlplane/pkg/data/ent/mutation.go
+++ b/app/controlplane/pkg/data/ent/mutation.go
@@ -10116,6 +10116,7 @@ type OrganizationMutation struct {
block_attestations_on_released_versions *bool
skip_runner_env_vars *bool
env_var_redaction **biz.EnvVarRedaction
+ pii_redaction *bool
suspended *bool
clearedFields map[string]struct{}
memberships map[uuid.UUID]struct{}
@@ -10811,6 +10812,42 @@ func (m *OrganizationMutation) ResetEnvVarRedaction() {
delete(m.clearedFields, organization.FieldEnvVarRedaction)
}
+// SetPiiRedaction sets the "pii_redaction" field.
+func (m *OrganizationMutation) SetPiiRedaction(b bool) {
+ m.pii_redaction = &b
+}
+
+// PiiRedaction returns the value of the "pii_redaction" field in the mutation.
+func (m *OrganizationMutation) PiiRedaction() (r bool, exists bool) {
+ v := m.pii_redaction
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldPiiRedaction returns the old "pii_redaction" field's value of the Organization entity.
+// If the Organization object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *OrganizationMutation) OldPiiRedaction(ctx context.Context) (v bool, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldPiiRedaction is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldPiiRedaction requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldPiiRedaction: %w", err)
+ }
+ return oldValue.PiiRedaction, nil
+}
+
+// ResetPiiRedaction resets all changes to the "pii_redaction" field.
+func (m *OrganizationMutation) ResetPiiRedaction() {
+ m.pii_redaction = nil
+}
+
// SetSuspended sets the "suspended" field.
func (m *OrganizationMutation) SetSuspended(b bool) {
m.suspended = &b
@@ -11367,7 +11404,7 @@ func (m *OrganizationMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *OrganizationMutation) Fields() []string {
- fields := make([]string, 0, 14)
+ fields := make([]string, 0, 15)
if m.name != nil {
fields = append(fields, organization.FieldName)
}
@@ -11407,6 +11444,9 @@ func (m *OrganizationMutation) Fields() []string {
if m.env_var_redaction != nil {
fields = append(fields, organization.FieldEnvVarRedaction)
}
+ if m.pii_redaction != nil {
+ fields = append(fields, organization.FieldPiiRedaction)
+ }
if m.suspended != nil {
fields = append(fields, organization.FieldSuspended)
}
@@ -11444,6 +11484,8 @@ func (m *OrganizationMutation) Field(name string) (ent.Value, bool) {
return m.SkipRunnerEnvVars()
case organization.FieldEnvVarRedaction:
return m.EnvVarRedaction()
+ case organization.FieldPiiRedaction:
+ return m.PiiRedaction()
case organization.FieldSuspended:
return m.Suspended()
}
@@ -11481,6 +11523,8 @@ func (m *OrganizationMutation) OldField(ctx context.Context, name string) (ent.V
return m.OldSkipRunnerEnvVars(ctx)
case organization.FieldEnvVarRedaction:
return m.OldEnvVarRedaction(ctx)
+ case organization.FieldPiiRedaction:
+ return m.OldPiiRedaction(ctx)
case organization.FieldSuspended:
return m.OldSuspended(ctx)
}
@@ -11583,6 +11627,13 @@ func (m *OrganizationMutation) SetField(name string, value ent.Value) error {
}
m.SetEnvVarRedaction(v)
return nil
+ case organization.FieldPiiRedaction:
+ v, ok := value.(bool)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetPiiRedaction(v)
+ return nil
case organization.FieldSuspended:
v, ok := value.(bool)
if !ok {
@@ -11720,6 +11771,9 @@ func (m *OrganizationMutation) ResetField(name string) error {
case organization.FieldEnvVarRedaction:
m.ResetEnvVarRedaction()
return nil
+ case organization.FieldPiiRedaction:
+ m.ResetPiiRedaction()
+ return nil
case organization.FieldSuspended:
m.ResetSuspended()
return nil
diff --git a/app/controlplane/pkg/data/ent/organization.go b/app/controlplane/pkg/data/ent/organization.go
index cf1ee91ed..c9bc643b4 100644
--- a/app/controlplane/pkg/data/ent/organization.go
+++ b/app/controlplane/pkg/data/ent/organization.go
@@ -46,6 +46,8 @@ type Organization struct {
SkipRunnerEnvVars bool `json:"skip_runner_env_vars,omitempty"`
// EnvVarRedaction holds the value of the "env_var_redaction" field.
EnvVarRedaction *biz.EnvVarRedaction `json:"env_var_redaction,omitempty"`
+ // PiiRedaction holds the value of the "pii_redaction" field.
+ PiiRedaction bool `json:"pii_redaction,omitempty"`
// Suspended holds the value of the "suspended" field.
Suspended bool `json:"suspended,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
@@ -167,7 +169,7 @@ func (*Organization) scanValues(columns []string) ([]any, error) {
switch columns[i] {
case organization.FieldPoliciesAllowedHostnames, organization.FieldEnvVarRedaction:
values[i] = new([]byte)
- case organization.FieldBlockOnPolicyViolation, organization.FieldPreventImplicitWorkflowCreation, organization.FieldRestrictContractCreationToOrgAdmins, organization.FieldEnableAiAgentCollector, organization.FieldBlockAttestationsOnReleasedVersions, organization.FieldSkipRunnerEnvVars, organization.FieldSuspended:
+ case organization.FieldBlockOnPolicyViolation, organization.FieldPreventImplicitWorkflowCreation, organization.FieldRestrictContractCreationToOrgAdmins, organization.FieldEnableAiAgentCollector, organization.FieldBlockAttestationsOnReleasedVersions, organization.FieldSkipRunnerEnvVars, organization.FieldPiiRedaction, organization.FieldSuspended:
values[i] = new(sql.NullBool)
case organization.FieldAPITokenInactivityThresholdDays:
values[i] = new(sql.NullInt64)
@@ -281,6 +283,12 @@ func (_m *Organization) assignValues(columns []string, values []any) error {
return fmt.Errorf("unmarshal field env_var_redaction: %w", err)
}
}
+ case organization.FieldPiiRedaction:
+ if value, ok := values[i].(*sql.NullBool); !ok {
+ return fmt.Errorf("unexpected type %T for field pii_redaction", values[i])
+ } else if value.Valid {
+ _m.PiiRedaction = value.Bool
+ }
case organization.FieldSuspended:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field suspended", values[i])
@@ -409,6 +417,9 @@ func (_m *Organization) String() string {
builder.WriteString("env_var_redaction=")
builder.WriteString(fmt.Sprintf("%v", _m.EnvVarRedaction))
builder.WriteString(", ")
+ builder.WriteString("pii_redaction=")
+ builder.WriteString(fmt.Sprintf("%v", _m.PiiRedaction))
+ builder.WriteString(", ")
builder.WriteString("suspended=")
builder.WriteString(fmt.Sprintf("%v", _m.Suspended))
builder.WriteByte(')')
diff --git a/app/controlplane/pkg/data/ent/organization/organization.go b/app/controlplane/pkg/data/ent/organization/organization.go
index 899dd7dbf..7b01fd50e 100644
--- a/app/controlplane/pkg/data/ent/organization/organization.go
+++ b/app/controlplane/pkg/data/ent/organization/organization.go
@@ -41,6 +41,8 @@ const (
FieldSkipRunnerEnvVars = "skip_runner_env_vars"
// FieldEnvVarRedaction holds the string denoting the env_var_redaction field in the database.
FieldEnvVarRedaction = "env_var_redaction"
+ // FieldPiiRedaction holds the string denoting the pii_redaction field in the database.
+ FieldPiiRedaction = "pii_redaction"
// FieldSuspended holds the string denoting the suspended field in the database.
FieldSuspended = "suspended"
// EdgeMemberships holds the string denoting the memberships edge name in mutations.
@@ -144,6 +146,7 @@ var Columns = []string{
FieldBlockAttestationsOnReleasedVersions,
FieldSkipRunnerEnvVars,
FieldEnvVarRedaction,
+ FieldPiiRedaction,
FieldSuspended,
}
@@ -174,6 +177,8 @@ var (
DefaultBlockAttestationsOnReleasedVersions bool
// DefaultSkipRunnerEnvVars holds the default value on creation for the "skip_runner_env_vars" field.
DefaultSkipRunnerEnvVars bool
+ // DefaultPiiRedaction holds the default value on creation for the "pii_redaction" field.
+ DefaultPiiRedaction bool
// DefaultSuspended holds the default value on creation for the "suspended" field.
DefaultSuspended bool
// DefaultID holds the default value on creation for the "id" field.
@@ -243,6 +248,11 @@ func BySkipRunnerEnvVars(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSkipRunnerEnvVars, opts...).ToFunc()
}
+// ByPiiRedaction orders the results by the pii_redaction field.
+func ByPiiRedaction(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldPiiRedaction, opts...).ToFunc()
+}
+
// BySuspended orders the results by the suspended field.
func BySuspended(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSuspended, opts...).ToFunc()
diff --git a/app/controlplane/pkg/data/ent/organization/where.go b/app/controlplane/pkg/data/ent/organization/where.go
index 44403ea27..fe878d556 100644
--- a/app/controlplane/pkg/data/ent/organization/where.go
+++ b/app/controlplane/pkg/data/ent/organization/where.go
@@ -111,6 +111,11 @@ func SkipRunnerEnvVars(v bool) predicate.Organization {
return predicate.Organization(sql.FieldEQ(FieldSkipRunnerEnvVars, v))
}
+// PiiRedaction applies equality check predicate on the "pii_redaction" field. It's identical to PiiRedactionEQ.
+func PiiRedaction(v bool) predicate.Organization {
+ return predicate.Organization(sql.FieldEQ(FieldPiiRedaction, v))
+}
+
// Suspended applies equality check predicate on the "suspended" field. It's identical to SuspendedEQ.
func Suspended(v bool) predicate.Organization {
return predicate.Organization(sql.FieldEQ(FieldSuspended, v))
@@ -441,6 +446,16 @@ func EnvVarRedactionNotNil() predicate.Organization {
return predicate.Organization(sql.FieldNotNull(FieldEnvVarRedaction))
}
+// PiiRedactionEQ applies the EQ predicate on the "pii_redaction" field.
+func PiiRedactionEQ(v bool) predicate.Organization {
+ return predicate.Organization(sql.FieldEQ(FieldPiiRedaction, v))
+}
+
+// PiiRedactionNEQ applies the NEQ predicate on the "pii_redaction" field.
+func PiiRedactionNEQ(v bool) predicate.Organization {
+ return predicate.Organization(sql.FieldNEQ(FieldPiiRedaction, v))
+}
+
// SuspendedEQ applies the EQ predicate on the "suspended" field.
func SuspendedEQ(v bool) predicate.Organization {
return predicate.Organization(sql.FieldEQ(FieldSuspended, v))
diff --git a/app/controlplane/pkg/data/ent/organization_create.go b/app/controlplane/pkg/data/ent/organization_create.go
index c726a0d0e..7fc4ae548 100644
--- a/app/controlplane/pkg/data/ent/organization_create.go
+++ b/app/controlplane/pkg/data/ent/organization_create.go
@@ -192,6 +192,20 @@ func (_c *OrganizationCreate) SetEnvVarRedaction(v *biz.EnvVarRedaction) *Organi
return _c
}
+// SetPiiRedaction sets the "pii_redaction" field.
+func (_c *OrganizationCreate) SetPiiRedaction(v bool) *OrganizationCreate {
+ _c.mutation.SetPiiRedaction(v)
+ return _c
+}
+
+// SetNillablePiiRedaction sets the "pii_redaction" field if the given value is not nil.
+func (_c *OrganizationCreate) SetNillablePiiRedaction(v *bool) *OrganizationCreate {
+ if v != nil {
+ _c.SetPiiRedaction(*v)
+ }
+ return _c
+}
+
// SetSuspended sets the "suspended" field.
func (_c *OrganizationCreate) SetSuspended(v bool) *OrganizationCreate {
_c.mutation.SetSuspended(v)
@@ -422,6 +436,10 @@ func (_c *OrganizationCreate) defaults() {
v := organization.DefaultSkipRunnerEnvVars
_c.mutation.SetSkipRunnerEnvVars(v)
}
+ if _, ok := _c.mutation.PiiRedaction(); !ok {
+ v := organization.DefaultPiiRedaction
+ _c.mutation.SetPiiRedaction(v)
+ }
if _, ok := _c.mutation.Suspended(); !ok {
v := organization.DefaultSuspended
_c.mutation.SetSuspended(v)
@@ -461,6 +479,9 @@ func (_c *OrganizationCreate) check() error {
if _, ok := _c.mutation.SkipRunnerEnvVars(); !ok {
return &ValidationError{Name: "skip_runner_env_vars", err: errors.New(`ent: missing required field "Organization.skip_runner_env_vars"`)}
}
+ if _, ok := _c.mutation.PiiRedaction(); !ok {
+ return &ValidationError{Name: "pii_redaction", err: errors.New(`ent: missing required field "Organization.pii_redaction"`)}
+ }
if _, ok := _c.mutation.Suspended(); !ok {
return &ValidationError{Name: "suspended", err: errors.New(`ent: missing required field "Organization.suspended"`)}
}
@@ -552,6 +573,10 @@ func (_c *OrganizationCreate) createSpec() (*Organization, *sqlgraph.CreateSpec)
_spec.SetField(organization.FieldEnvVarRedaction, field.TypeJSON, value)
_node.EnvVarRedaction = value
}
+ if value, ok := _c.mutation.PiiRedaction(); ok {
+ _spec.SetField(organization.FieldPiiRedaction, field.TypeBool, value)
+ _node.PiiRedaction = value
+ }
if value, ok := _c.mutation.Suspended(); ok {
_spec.SetField(organization.FieldSuspended, field.TypeBool, value)
_node.Suspended = value
@@ -926,6 +951,18 @@ func (u *OrganizationUpsert) ClearEnvVarRedaction() *OrganizationUpsert {
return u
}
+// SetPiiRedaction sets the "pii_redaction" field.
+func (u *OrganizationUpsert) SetPiiRedaction(v bool) *OrganizationUpsert {
+ u.Set(organization.FieldPiiRedaction, v)
+ return u
+}
+
+// UpdatePiiRedaction sets the "pii_redaction" field to the value that was provided on create.
+func (u *OrganizationUpsert) UpdatePiiRedaction() *OrganizationUpsert {
+ u.SetExcluded(organization.FieldPiiRedaction)
+ return u
+}
+
// SetSuspended sets the "suspended" field.
func (u *OrganizationUpsert) SetSuspended(v bool) *OrganizationUpsert {
u.Set(organization.FieldSuspended, v)
@@ -1192,6 +1229,20 @@ func (u *OrganizationUpsertOne) ClearEnvVarRedaction() *OrganizationUpsertOne {
})
}
+// SetPiiRedaction sets the "pii_redaction" field.
+func (u *OrganizationUpsertOne) SetPiiRedaction(v bool) *OrganizationUpsertOne {
+ return u.Update(func(s *OrganizationUpsert) {
+ s.SetPiiRedaction(v)
+ })
+}
+
+// UpdatePiiRedaction sets the "pii_redaction" field to the value that was provided on create.
+func (u *OrganizationUpsertOne) UpdatePiiRedaction() *OrganizationUpsertOne {
+ return u.Update(func(s *OrganizationUpsert) {
+ s.UpdatePiiRedaction()
+ })
+}
+
// SetSuspended sets the "suspended" field.
func (u *OrganizationUpsertOne) SetSuspended(v bool) *OrganizationUpsertOne {
return u.Update(func(s *OrganizationUpsert) {
@@ -1627,6 +1678,20 @@ func (u *OrganizationUpsertBulk) ClearEnvVarRedaction() *OrganizationUpsertBulk
})
}
+// SetPiiRedaction sets the "pii_redaction" field.
+func (u *OrganizationUpsertBulk) SetPiiRedaction(v bool) *OrganizationUpsertBulk {
+ return u.Update(func(s *OrganizationUpsert) {
+ s.SetPiiRedaction(v)
+ })
+}
+
+// UpdatePiiRedaction sets the "pii_redaction" field to the value that was provided on create.
+func (u *OrganizationUpsertBulk) UpdatePiiRedaction() *OrganizationUpsertBulk {
+ return u.Update(func(s *OrganizationUpsert) {
+ s.UpdatePiiRedaction()
+ })
+}
+
// SetSuspended sets the "suspended" field.
func (u *OrganizationUpsertBulk) SetSuspended(v bool) *OrganizationUpsertBulk {
return u.Update(func(s *OrganizationUpsert) {
diff --git a/app/controlplane/pkg/data/ent/organization_update.go b/app/controlplane/pkg/data/ent/organization_update.go
index 60e579d28..529f590ec 100644
--- a/app/controlplane/pkg/data/ent/organization_update.go
+++ b/app/controlplane/pkg/data/ent/organization_update.go
@@ -230,6 +230,20 @@ func (_u *OrganizationUpdate) ClearEnvVarRedaction() *OrganizationUpdate {
return _u
}
+// SetPiiRedaction sets the "pii_redaction" field.
+func (_u *OrganizationUpdate) SetPiiRedaction(v bool) *OrganizationUpdate {
+ _u.mutation.SetPiiRedaction(v)
+ return _u
+}
+
+// SetNillablePiiRedaction sets the "pii_redaction" field if the given value is not nil.
+func (_u *OrganizationUpdate) SetNillablePiiRedaction(v *bool) *OrganizationUpdate {
+ if v != nil {
+ _u.SetPiiRedaction(*v)
+ }
+ return _u
+}
+
// SetSuspended sets the "suspended" field.
func (_u *OrganizationUpdate) SetSuspended(v bool) *OrganizationUpdate {
_u.mutation.SetSuspended(v)
@@ -671,6 +685,9 @@ func (_u *OrganizationUpdate) sqlSave(ctx context.Context) (_node int, err error
if _u.mutation.EnvVarRedactionCleared() {
_spec.ClearField(organization.FieldEnvVarRedaction, field.TypeJSON)
}
+ if value, ok := _u.mutation.PiiRedaction(); ok {
+ _spec.SetField(organization.FieldPiiRedaction, field.TypeBool, value)
+ }
if value, ok := _u.mutation.Suspended(); ok {
_spec.SetField(organization.FieldSuspended, field.TypeBool, value)
}
@@ -1290,6 +1307,20 @@ func (_u *OrganizationUpdateOne) ClearEnvVarRedaction() *OrganizationUpdateOne {
return _u
}
+// SetPiiRedaction sets the "pii_redaction" field.
+func (_u *OrganizationUpdateOne) SetPiiRedaction(v bool) *OrganizationUpdateOne {
+ _u.mutation.SetPiiRedaction(v)
+ return _u
+}
+
+// SetNillablePiiRedaction sets the "pii_redaction" field if the given value is not nil.
+func (_u *OrganizationUpdateOne) SetNillablePiiRedaction(v *bool) *OrganizationUpdateOne {
+ if v != nil {
+ _u.SetPiiRedaction(*v)
+ }
+ return _u
+}
+
// SetSuspended sets the "suspended" field.
func (_u *OrganizationUpdateOne) SetSuspended(v bool) *OrganizationUpdateOne {
_u.mutation.SetSuspended(v)
@@ -1761,6 +1792,9 @@ func (_u *OrganizationUpdateOne) sqlSave(ctx context.Context) (_node *Organizati
if _u.mutation.EnvVarRedactionCleared() {
_spec.ClearField(organization.FieldEnvVarRedaction, field.TypeJSON)
}
+ if value, ok := _u.mutation.PiiRedaction(); ok {
+ _spec.SetField(organization.FieldPiiRedaction, field.TypeBool, value)
+ }
if value, ok := _u.mutation.Suspended(); ok {
_spec.SetField(organization.FieldSuspended, field.TypeBool, value)
}
diff --git a/app/controlplane/pkg/data/ent/runtime.go b/app/controlplane/pkg/data/ent/runtime.go
index ace8400c9..c8a0f5a63 100644
--- a/app/controlplane/pkg/data/ent/runtime.go
+++ b/app/controlplane/pkg/data/ent/runtime.go
@@ -241,8 +241,12 @@ func init() {
organizationDescSkipRunnerEnvVars := organizationFields[12].Descriptor()
// organization.DefaultSkipRunnerEnvVars holds the default value on creation for the skip_runner_env_vars field.
organization.DefaultSkipRunnerEnvVars = organizationDescSkipRunnerEnvVars.Default.(bool)
+ // organizationDescPiiRedaction is the schema descriptor for pii_redaction field.
+ organizationDescPiiRedaction := organizationFields[14].Descriptor()
+ // organization.DefaultPiiRedaction holds the default value on creation for the pii_redaction field.
+ organization.DefaultPiiRedaction = organizationDescPiiRedaction.Default.(bool)
// organizationDescSuspended is the schema descriptor for suspended field.
- organizationDescSuspended := organizationFields[14].Descriptor()
+ organizationDescSuspended := organizationFields[15].Descriptor()
// organization.DefaultSuspended holds the default value on creation for the suspended field.
organization.DefaultSuspended = organizationDescSuspended.Default.(bool)
// organizationDescID is the schema descriptor for id field.
diff --git a/app/controlplane/pkg/data/ent/schema/organization.go b/app/controlplane/pkg/data/ent/schema/organization.go
index 4973614d6..006a13e17 100644
--- a/app/controlplane/pkg/data/ent/schema/organization.go
+++ b/app/controlplane/pkg/data/ent/schema/organization.go
@@ -69,6 +69,9 @@ func (Organization) Fields() []ent.Field {
// env_var_redaction replaces the values of selected env vars with a placeholder in new attestations.
// Empty means no redaction.
field.JSON("env_var_redaction", &biz.EnvVarRedaction{}).Optional(),
+ // pii_redaction replaces personal data with a placeholder in new attestations: the known
+ // identity env vars, the head commit author, and the PR/MR author and reviewer logins.
+ field.Bool("pii_redaction").Default(false),
// Suspended orgs are blocked from all operations.
field.Bool("suspended").Default(false),
}
diff --git a/app/controlplane/pkg/data/organization.go b/app/controlplane/pkg/data/organization.go
index 87887add9..cfe68bb4a 100644
--- a/app/controlplane/pkg/data/organization.go
+++ b/app/controlplane/pkg/data/organization.go
@@ -106,6 +106,7 @@ func (r *OrganizationRepo) Update(ctx context.Context, id uuid.UUID, updateOpts
SetNillableEnableAiAgentCollector(updateOpts.EnableAIAgentCollector).
SetNillableBlockAttestationsOnReleasedVersions(updateOpts.BlockAttestationsOnReleasedVersions).
SetNillableSkipRunnerEnvVars(updateOpts.SkipRunnerEnvVars).
+ SetNillablePiiRedaction(updateOpts.PIIRedaction).
SetUpdatedAt(time.Now())
if updateOpts.PoliciesAllowedHostnames != nil {
@@ -196,6 +197,7 @@ func entOrgToBizOrg(eu *ent.Organization) *biz.Organization {
BlockAttestationsOnReleasedVersions: eu.BlockAttestationsOnReleasedVersions,
SkipRunnerEnvVars: eu.SkipRunnerEnvVars,
EnvVarRedaction: eu.EnvVarRedaction,
+ PIIRedaction: eu.PiiRedaction,
Suspended: eu.Suspended,
}
}
diff --git a/docs/plans/issue-3842-pii-redaction.md b/docs/plans/issue-3842-pii-redaction.md
new file mode 100644
index 000000000..7d2843f8d
--- /dev/null
+++ b/docs/plans/issue-3842-pii-redaction.md
@@ -0,0 +1,245 @@
+---
+owner: migmartri
+ticket: https://github.com/chainloop-dev/chainloop/issues/3842
+spec: docs/specs/issue-3842-pii-redaction.md
+skill: br:eng-plan 1.72.1
+---
+
+
+
+# Plan issue-3842: Redaction of personal data
+
+## Overview
+
+### Today
+
+Each new attestation stores the name and email of the author of the head commit. In a pull request or merge request, it also stores the logins of the author and the reviewers. The env var redaction setting does not hide them. Its custom mode also replaces the known identity list.
+
+### After this plan
+
+An organization admin turns on PII redaction. New attestations then store `[REDACTED]` for the known identity variables, the commit author, and each PR/MR login. The custom env var list adds to it. Organizations with the known identity mode move to PII redaction at the upgrade. A push from a CLI that does not redact fails, and the error names the fields.
+
+### How
+
+- The setting takes the path of the env var redaction setting: the update API, the organizations table, the `attestation init` response, and the attestation state. Thus the CLI knows the setting before it reads the commit.
+- The `attestation init` response sends the known identity variables and the custom list as one resolved list. Thus an older CLI still redacts the variables.
+- The CLI replaces the commit author after it verifies the head commit at init. Thus the platform verification still uses the real commit.
+- The PR info crafter replaces the logins with the content override that the AI session redaction uses. Then the crafter adds a marker annotation. Thus the stored digest and the policies use only the redacted content.
+- The push check of env var redaction also reads the commit author from the signed statement and the marker from the material annotations. Thus an older CLI cannot store clear identities.
+
+## Architecture and impact
+
+**Behavior (flow, grouped by layer)**
+
+```mermaid
+flowchart LR
+ subgraph CLI[CLI and crafter]
+ Update[org update]:::changed
+ State[attestation state]:::changed
+ Crafter[crafter]:::changed
+ Commit[git.head subject]:::changed
+ PR[PR info material]:::changed
+ end
+ subgraph SVC[control plane service]
+ OrgSvc[organization service]:::changed
+ Init[init response]:::changed
+ end
+ subgraph BIZ[control plane biz]
+ OrgUC[organization use case]:::changed
+ Check[push redaction check]:::changed
+ end
+ subgraph DATA[control plane data]
+ Org[(organizations table)]:::changed
+ end
+ Update -->|sends setting| OrgSvc
+ OrgSvc -->|passes setting| OrgUC
+ OrgUC -->|stores setting| Org
+ Org -->|returns setting| Init
+ Init -->|writes setting| State
+ State -->|provides setting| Crafter
+ Crafter -->|writes redacted author| Commit
+ Crafter -->|writes redacted logins and marker| PR
+ Commit -->|sends signed author| Check
+ PR -->|sends annotations| Check
+ Org -->|returns setting at push| Check
+ classDef new fill:#d4f7d4,stroke:#2e7d32
+ classDef changed fill:#fff4c2,stroke:#b8860b
+```
+
+Green: new. Yellow: changed. No color: unchanged.
+
+**Data model**
+
+```mermaid
+erDiagram
+ organizations {
+ bool pii_redaction "new"
+ jsonb env_var_redaction "known identity rows move to pii_redaction"
+ }
+```
+
+One new column with the default false. The same migration sets it for the rows with the known identity mode, and clears their env var setting.
+
+| Impact on | What changes | Where |
+|-----------|--------------|-------|
+| Users | Admins get `--pii-redaction`. The help marks `--env-var-redaction known-identity` as deprecated. Attestations with the setting show `[REDACTED]` in the `git.head` annotations and in the PR info material. | `app/cli/cmd/`, `pkg/attestation/crafter/` |
+| Other parts of the product | Policies and the attestation views read the redacted `git.head` annotations and PR info material. A policy that compares the PR author and the reviewers cannot tell them apart. | `pkg/attestation/`, `app/controlplane/pkg/biz/` |
+| Data and migrations | The organizations table gets `pii_redaction`, boolean, default false. The migration moves the known identity rows. | `app/controlplane/pkg/data/ent/` |
+| Rollout | Deploy the control plane, then release the CLI. No change outside this repository. | `app/controlplane/`, `app/cli/` |
+| Compatibility | The API only adds fields. An older CLI fails at push only when PII redaction is on and the attestation has a commit author or a PR info material. This includes the organizations that the migration moves. | `app/controlplane/pkg/biz/` |
+| Rollback | Turn the setting off. A code rollback leaves the column unused, and the moved organizations lose env var redaction until an admin sets it again. Stored attestations keep `[REDACTED]`. | `app/controlplane/` |
+
+## User-facing changes
+
+### API
+
+R-001, R-002, and R-003. `organization.proto` (update request), `response_messages.proto` (`OrgItem`, `EnvVarRedaction`), and `workflow_run.proto` (init response) in `app/controlplane/api/controlplane/v1/`:
+
+```diff
++ // TYPE_KNOWN_IDENTITY is deprecated: the control plane turns it into pii_redaction = true.
+ EnvVarRedaction env_var_redaction = 11;
++ optional bool pii_redaction = 12;
+
+ EnvVarRedaction env_var_redaction = 13;
++ bool pii_redaction = 14;
+
++ // Replaced by the pii_redaction organization setting, kept for older clients.
+ TYPE_KNOWN_IDENTITY = 1;
+- // redact only the variables listed in env_vars
++ // redact the variables listed in env_vars, in addition to the ones of pii_redaction
+ TYPE_CUSTOM = 2;
+
+ repeated string redacted_env_vars = 10;
++ bool pii_redaction = 11;
+```
+
+### CLI
+
+R-001, R-002, and R-006. `chainloop org update`, `chainloop org describe`, and the push error:
+
+```console
+$ chainloop org update --name my-org --pii-redaction=true --env-var-redaction custom --redacted-env-var MY_OWNER
+$ chainloop org describe
+│ Organization │ my-org (role=owner) │
+│ │ PII redaction: enabled │
+│ │ Env var redaction: custom (MY_OWNER) │
+$ chainloop attestation push
+ERR the commit author name, the commit author email, the PR info material "pr-metadata-12" must be redacted because of the organization PII redaction setting. Update the Chainloop CLI, or run the attestation again if the setting changed during the run
+```
+
+## Milestones
+
+### M1: PII redaction, applied by the CLI and enforced at push
+
+**Done when:** an admin turns the setting on. An attestation in a GitHub pull request then shows `[REDACTED]` for the identity variables, the commit author, and the PR/MR logins. `org describe` shows the setting. Known identity organizations show PII redaction after the upgrade. A push from an older CLI fails. Checked by the organization, crafter, PR info, and push tests. Reuse first rung 2: it extends the env var redaction path and check.
+
+**Steps**, in build order. Open a step to see what changes and the files it touches.
+
+
+01 / 06 · Let an admin turn PII redaction on, and move the known identity organizations (R-001, R-002, R-003)
+
+The use case turns a known identity request into PII redaction on. `Organization.RedactedEnvVars` joins the known identity list and the custom list.
+
+| File | Change |
+|------|--------|
+| `app/controlplane/api/controlplane/v1/organization.proto`, `response_messages.proto` | Add the fields and the deprecation comments, then `buf format -w` and `make api`. |
+| `app/controlplane/pkg/data/ent/schema/organization.go` | Add the column, then `make generate` and `make migration_sync`. |
+| `app/controlplane/pkg/data/ent/migrate/migrations/` | Add the `UPDATE` of the known identity rows to the new migration, then `make migration_hash`. |
+| `app/controlplane/pkg/biz/organization.go`, `pkg/data/organization.go` | Add `PIIRedaction`, the known identity translation, and `RedactedEnvVars`. |
+| `app/controlplane/internal/service/organization.go`, `context.go` | Map the fields. |
+| `app/controlplane/pkg/biz/organization_integration_test.go`, `redaction_test.go` | Add cases: on, off, known identity, known identity with off, custom with PII, and no change. |
+
+
+
+
+02 / 06 · Add the `org update` flag, and show the setting in the details (R-001, R-002)
+
+The CLI sends the field only when the user gives the flag, as for `--skip-runner-env-vars`. The details always show the setting, as enabled or disabled. The `--env-var-redaction` help marks the known identity mode as deprecated.
+
+| File | Change |
+|------|--------|
+| `app/cli/cmd/organization_update.go`, `organization_describe.go` | Add the flag and the details line. |
+| `app/cli/pkg/action/org_update.go`, `membership_list.go` | Send and read the field. |
+| `app/cli/documentation/cli-reference.md` | Regenerate. |
+
+
+
+
+03 / 06 · Send the setting at init, and keep it in the attestation state (R-001, R-002)
+
+The init response sends `RedactedEnvVars` of the organization, and `pii_redaction`. The crafter writes `pii_redaction` to the state, next to `redacted_env_vars`. Steps 04 and 05 read it there.
+
+| File | Change |
+|------|--------|
+| `app/controlplane/api/controlplane/v1/workflow_run.proto`, `pkg/attestation/crafter/api/attestation/v1/crafting_state.proto` | Add the fields, then `buf format -w` and `make api`. |
+| `app/controlplane/internal/service/attestation.go` | Fill the fields from the organization. |
+| `app/cli/pkg/action/attestation_init.go`, `pkg/attestation/crafter/crafter.go` | Copy the value to `InitOpts` and to the state. |
+
+
+
+
+04 / 06 · Store `[REDACTED]` as the commit author, after the platform verifies the commit (R-004)
+
+In `initialCraftingState`, after `verifyCommitWithPlatform`, the crafter replaces the name, and the email when it is not empty, with `envredaction.RedactedValue`.
+
+| File | Change |
+|------|--------|
+| `pkg/attestation/crafter/crafter.go` | Replace the author fields when the option is on. |
+| `pkg/attestation/crafter/crafter_test.go` | Add cases: on and off. The hash stays. |
+
+
+
+
+05 / 06 · Store `[REDACTED]` for the PR/MR logins, and mark the material (R-005)
+
+`prinfo.RedactIdentities` rewrites only the author login (or the author string of schema 1.0 to 1.2) and each reviewer login. The PR info crafter stores the bytes with `withContentOverride`, returns them in `CraftResult.Content` for policies, and sets `AnnotationMaterialPIIRedacted`. With PII redaction off, `stageMaterial` drops a marker from a contract or a runtime annotation.
+
+| File | Change |
+|------|--------|
+| `pkg/prinfo/redact.go` | Add `RedactIdentities`. |
+| `pkg/attestation/crafter/api/attestation/v1/crafting_state.go` | Add the annotation key. |
+| `pkg/attestation/crafter/materials/materials.go`, `chainloop_pr_info.go` | Add the option, redact, override the content, and set the annotation. |
+| `pkg/attestation/crafter/crafter.go` | Fill the option from the state, and drop a marker that the crafter did not set. |
+| `pkg/prinfo/redact_test.go`, `pkg/attestation/crafter/materials/chainloop_pr_info_test.go`, `pkg/attestation/crafter/crafter_test.go` | Add cases: object author and reviewers, string author, no identities, invalid types, on and off, and a runtime marker. |
+
+
+
+
+06 / 06 · Reject a push that does not obey the setting (R-006)
+
+Both callers decode the statement once, and `validatePredicate` gets it. `validatePIIRedaction` reads the author with `chainloop.GitHeadAuthor`, and checks the marker of each `CHAINLOOP_PR_INFO` material. One error names them all.
+
+| File | Change |
+|------|--------|
+| `pkg/attestation/renderer/chainloop/chainloop.go`, `v02.go` | Add `GitHeadAuthor` and `PredicateFromStatement`, and export the author keys. |
+| `app/controlplane/pkg/biz/workflowrun.go` | Extract the statement, and add the check to `validatePredicate`. |
+| `app/controlplane/pkg/biz/redaction_test.go`, `workflowrun_contract_integration_test.go` | Add cases: a clear name, a clear email, an unmarked material, all at once, and the redacted, empty, and off cases. |
+
+
+
+Verify: `make -C app/controlplane test && make -C app/cli test && go test ./pkg/...`
+
+## Open Questions
+
+None.
+
+## Skipped and risks
+
+| Skipped step | Reason | Follow-up |
+|--------------|--------|-----------|
+| Names and emails in commit message trailers | Non-goal of the spec. | none |
+
+Not checked: a manual end-to-end run in a real GitHub or GitLab pull request.
+
+| Risk | Mitigation |
+|------|------------|
+| With an older CLI, a user can set the marker annotation by hand. Then the push passes. A new CLI drops a marker that the crafter did not set. | The spec accepts a forged marker (D-002). |
+| Pipelines with an older CLI fail at push after the upgrade, in organizations that the migration moves. | The error tells the user to update the CLI. The release notes give the minimum CLI version and name the migration. |
diff --git a/docs/specs/issue-3841-runner-env-var-redaction.md b/docs/specs/issue-3841-runner-env-var-redaction.md
index c91ad2aed..1639c999f 100644
--- a/docs/specs/issue-3841-runner-env-var-redaction.md
+++ b/docs/specs/issue-3841-runner-env-var-redaction.md
@@ -27,6 +27,8 @@ When your code goes against this spec, say so in your PR. Supersede the entry wh
# Spec issue-3841: Redaction of runner environment variables
+Partly superseded by [Spec issue-3842](issue-3842-pii-redaction.md): R-001 and R-005.
+
## 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. This spec adds an organization setting that replaces the values of those variables with `[REDACTED]`. The setting has three modes: none, a list of identity variables that Chainloop keeps, or a custom list of variable names. The control plane rejects a pushed attestation that does not obey the setting.
diff --git a/docs/specs/issue-3842-pii-redaction.md b/docs/specs/issue-3842-pii-redaction.md
new file mode 100644
index 000000000..27a87fc9e
--- /dev/null
+++ b/docs/specs/issue-3842-pii-redaction.md
@@ -0,0 +1,167 @@
+---
+owner: migmartri
+ticket: https://github.com/chainloop-dev/chainloop/issues/3842
+prd:
+---
+
+
+
+# Spec issue-3842: Redaction of personal data
+
+## Summary
+
+[Spec issue-3841](issue-3841-runner-env-var-redaction.md) lets an organization redact runner environment variables, with a known identity mode or a custom list. Attestations also store personal data that is not in environment variables. They store the name and email of the author of the head commit. They also store the logins of the author and the reviewers of the pull request or merge request (PR/MR). This spec replaces the known identity mode with one on/off PII redaction setting. It supersedes R-001 and R-005 of Spec issue-3841. The setting covers the known identity variables, the commit author, and the PR/MR logins. The custom list stays, and it adds to PII redaction. Organizations that use the known identity mode move to PII redaction. The CLI applies the redaction, and the control plane rejects a push that does not obey the settings.
+
+## Problem
+
+- An organization that turns on env var redaction for GDPR reasons still stores personal data in each attestation:
+ - the author name and email of the head commit.
+ - the author login and the reviewer logins in the PR info material, which the CLI records for each PR/MR.
+- No setting hides these values today. They are not environment variables, so the setting of #3841 does not apply to them.
+- The custom mode of #3841 replaces the known identity list. An organization cannot hide the known identity variables and some variables of its own at the same time.
+
+## Goals and Non-Goals
+
+- Goal: an organization admin turns on one setting to hide the known personal data in new attestations. All other runner, commit, and PR/MR details stay.
+- In scope: the change to the env var redaction setting of #3841 (R-002, R-003). It changes the same setting, and the setting must stay one control for personal data.
+- In scope: push enforcement (R-006). It could ship after the CLI part, but the ticket asks for it, as #3841 did.
+- Non-goal: redact attestations that are already stored. The CLI signs each attestation, and a stored attestation does not change.
+- Non-goal: names and emails in the commit message, for example in `Signed-off-by` and `Co-authored-by` trailers. The ticket names only the commit author and the PR/MR people, and free text needs a different mechanism. Follow-up: a new issue, if an organization asks for it.
+- Non-goal: redaction of other materials or annotations. The user or the contract selects what they contain.
+
+## Requirements
+
+### R-001: PII redaction setting
+An organization admin MUST be able to turn PII redaction on and off. The organization details MUST show the value. The default is off. When the setting is on, it redacts the known identity variables of [Spec issue-3841](issue-3841-runner-env-var-redaction.md) (R-004 and D-001 there). It also redacts the commit author (R-004) and the PR/MR identities (R-005).
+- Done when: `chainloop org update --pii-redaction=true` turns it on, and the organization details show it.
+
+### R-002: Custom env var list adds to PII redaction
+The env var redaction setting MUST have only two modes: none and custom. The custom list MUST redact its variables in addition to the variables of PII redaction.
+- Done when: an organization with PII redaction on and the custom list `MY_OWNER` gets `[REDACTED]` for `GITHUB_ACTOR` and for `MY_OWNER`.
+
+### R-003: Move from the known identity mode
+The release MUST move each organization with the known identity mode to PII redaction on and no custom list. An organization with the custom mode MUST keep its list, with PII redaction off. An update request with the known identity mode MUST turn PII redaction on and clear the custom list. Thus older CLIs can still set it. An update request with the known identity mode and PII redaction off MUST fail.
+- Done when: after the upgrade, an organization that had the known identity mode shows PII redaction enabled and no env var redaction.
+
+### R-004: Commit author redaction
+When PII redaction is on, the head commit of a new attestation MUST store `[REDACTED]` as the author name. It MUST also store `[REDACTED]` as the author email, when the email is not empty. All other commit details MUST stay the same: hash, message, date, remotes, signature, and the platform verification result.
+- Done when: an attestation in a git repository has the commit hash and `[REDACTED]` as author name and email.
+
+### R-005: PR/MR identity redaction
+When PII redaction is on, each PR info material that the CLI records MUST store `[REDACTED]` as the author login. It MUST also store `[REDACTED]` as the login of each reviewer. The material MUST keep the account type (user or bot), the requested flag, the review status, and the other PR/MR fields. This applies to the material that the CLI collects in a pull request. It also applies to a PR info material that a user adds.
+- Done when: a GitHub pull request has one approving reviewer. The PR info material has `[REDACTED]` for the author and the reviewer, and the reviewer keeps the status `APPROVED`.
+
+### R-006: Push enforcement
+The control plane MUST reject an attestation in these cases:
+- a variable that the settings redact (R-001, R-002) has a value that is not empty and not `[REDACTED]`. This is the check of #3841, with the new list.
+- PII redaction is on, and the head commit has an author name or email that is not empty and not `[REDACTED]`.
+- PII redaction is on, and the attestation has a PR info material without the redaction marker (D-002).
+
+The check uses the settings at push time.
+
+The error MUST name the fields. It MUST tell the user to update the CLI, or to run the attestation again if the setting changed during the run.
+- Done when: a CLI without this feature pushes an attestation in a pull request, in an organization with PII redaction on. The push fails.
+
+## Constraints
+
+- Compatibility: the API change only adds fields. The known identity mode stays in the API as a deprecated value (R-003). The PR info material stays valid for its existing schema.
+- The settings are independent from the setting that drops all runner variables. All of them can be on at the same time.
+- Public repository: no internal links, and no customer or user information.
+
+## Proposal
+
+The organization details show PII redaction next to the env var redaction mode. `--env-var-redaction custom --redacted-env-var NAME` adds variables of the organization.
+
+The release has a data migration. It sets PII redaction on, and clears the env var setting, for each organization with the known identity mode (D-004).
+
+The CLI gets the settings from the control plane in the response of `attestation init`. The response has the resolved list of variables to redact, as in #3841, and the PII redaction value. Thus an older CLI still redacts the known identity variables. The CLI keeps the values in the local attestation state.
+
+The CLI reads the head commit and verifies its signature with the platform first. Then it replaces the author name and email before it writes the state. Thus the real values do not go to the state, the signed attestation, or the control plane.
+
+The CLI replaces the logins in each PR info material before it computes the digest and uploads the material. It then adds the redaction marker to the material in the attestation. The marker is an annotation of the material, and only the CLI sets it. The redaction is in the CLI step that records a PR info material. Thus it covers the collected material and a material that a user adds.
+
+At push, the control plane runs the new check next to the env var redaction check (follows D-002 of [Spec issue-3841](issue-3841-runner-env-var-redaction.md)). Thus it runs before the upload of the attestation bundle, and again when the control plane saves the attestation. The commit author is in the signed attestation, so the control plane checks the values. For a PR info material, it checks the marker (D-002).
+
+Policies that the CLI or the control plane evaluates see the redacted values.
+
+```mermaid
+sequenceDiagram
+ participant A as Org admin
+ participant CLI as CLI in CI runner
+ participant CAS as CAS
+ participant CP as Control plane
+ A->>CP: org update --pii-redaction=true
+ CLI->>CP: attestation init
+ CP-->>CLI: Env vars to redact and PII redaction (with the other org settings)
+ CLI->>CLI: Replace env var values, read head commit, verify it, replace author
+ CLI->>CLI: Collect PR info, replace author and reviewer logins
+ CLI->>CAS: Upload redacted PR info material
+ CLI->>CLI: Add redaction marker to the material
+ CLI->>CP: attestation push (signed)
+ CP->>CP: Check env vars and commit author are [REDACTED] or empty, and PR info has the marker
+ CP-->>CLI: Stored, or rejected with the names of the fields
+```
+
+## Decision Record
+
+### D-001: One PII redaction setting replaces the known identity mode
+PII redaction is one on/off organization setting for all the personal data that Chainloop knows about. The env var redaction setting keeps only the custom list, which adds to it.
+- Why: the known identity mode and the commit and PR/MR redaction have the same goal. With one setting, an admin turns on one control to hide people. The custom list then adds variables of the organization, which the custom mode of #3841 cannot do with the known identity list.
+- Alternatives considered:
+ - A separate on/off setting for the commit author and the PR/MR logins, next to the env var modes. An admin turns on two settings for one goal. Also, the custom mode still replaces the known identity list.
+ - The known identity mode also redacts the commit author and the PR/MR logins. The custom mode then cannot redact them. Also, the name "env var redaction" no longer says what the setting does.
+- Source: drafting
+
+### D-002: The control plane checks a redaction marker on the PR info material
+The CLI adds a marker to each PR info material that it redacted. At push, the control plane rejects a PR info material without the marker. It does not read the content of the material.
+- Why: with a CAS backend that is not inline, the control plane sees only the digest of the material. The marker catches an older CLI, which is the threat of #3841, with no CAS read at push. A modified client can add a false marker, but such a client can also forge other data that the control plane does not check.
+- Alternatives considered:
+ - The control plane downloads the material from the CAS at push and checks each login. This is a full check. But each push in a pull request then depends on a read from the CAS backend.
+ - No push check for PR info, and a minimum CLI version in the release notes: nothing stops an older CLI.
+- Source: drafting
+
+### D-003: Redacted identities become `[REDACTED]`, not a pseudonym
+Each redacted value stores the same text, `[REDACTED]`: the commit author name and email, and each PR/MR login.
+- Why: the ticket asks for `[REDACTED]`, as for env vars. A hash of a public login or a known email is easy to reverse, so it does not hide the personal data.
+- Alternatives considered:
+ - A stable hash for each identity: policies can still compare people, for example "the approver is not the author". But a reader can reverse the hash from the list of public logins.
+- Source: drafting
+
+### D-004: Organizations with the known identity mode move to PII redaction on
+The migration turns on PII redaction for each organization with the known identity mode. Thus these organizations also get commit and PR/MR redaction, and its push check.
+- Why: the admin of such an organization turned on redaction to hide personal data. The known identity mode no longer exists, and PII redaction is its replacement.
+- Alternatives considered:
+ - Move these organizations to a custom list of the known identity variables, with PII redaction off. Nothing changes for them. But they do not get commit and PR/MR redaction until an admin turns it on. Also, their list does not get later identity marks.
+- Source: drafting
+
+## Open Questions
+
+No open questions.
+
+## Risks
+
+| Risk | Mitigation |
+|------|------------|
+| A policy that compares people, for example "the approver is not the PR author", cannot tell them apart. | The account type and the review status stay. The organization admin turns on the setting and accepts the effect. The documentation of the setting says so. |
+| Pipelines with an older CLI fail at push in organizations with PII redaction. After the upgrade, this includes the organizations that had the known identity mode (D-004). | The error names the fields and tells the user to update the CLI. The release notes give the minimum CLI version and name the migration. |
+| For the organizations that the migration moves, an older CLI shows no redaction in the organization details, because it cannot read PII redaction. | The release notes say so. The redaction itself still applies. |
+| An admin changes the setting while an attestation is in progress. | The same as in #3841: the push fails with the error from R-006, and a new run of the pipeline uses the new setting. |
diff --git a/pkg/attestation/crafter/api/attestation/v1/crafting_state.go b/pkg/attestation/crafter/api/attestation/v1/crafting_state.go
index 7adf1db84..7fed348b4 100644
--- a/pkg/attestation/crafter/api/attestation/v1/crafting_state.go
+++ b/pkg/attestation/crafter/api/attestation/v1/crafting_state.go
@@ -84,6 +84,11 @@ var (
// redaction because the operator explicitly asked for it. Recorded so the
// bypass is visible to policies rather than silent.
AnnotationMaterialRedactionSkipped = CreateAnnotation("material.redaction.skipped")
+ // AnnotationMaterialPIIRedacted marks a material whose personal data the CLI
+ // replaced because of the organization PII redaction setting. The control
+ // plane only sees the digest of an uploaded material, so it checks this mark
+ // at push.
+ AnnotationMaterialPIIRedacted = CreateAnnotation("material.pii.redacted")
)
type NormalizedMaterialOutput struct {
diff --git a/pkg/attestation/crafter/api/attestation/v1/crafting_state.pb.go b/pkg/attestation/crafter/api/attestation/v1/crafting_state.pb.go
index cc10fcbd0..95a3274de 100644
--- a/pkg/attestation/crafter/api/attestation/v1/crafting_state.pb.go
+++ b/pkg/attestation/crafter/api/attestation/v1/crafting_state.pb.go
@@ -193,8 +193,11 @@ type Attestation struct {
// as resolved by the control plane from the organization setting.
// It applies to the runner env vars and to the contract's env_allow_list.
RedactedEnvVars []string `protobuf:"bytes,21,rep,name=redacted_env_vars,json=redactedEnvVars,proto3" json:"redacted_env_vars,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
+ // replace the head commit author and the PR/MR author and reviewer logins with "[REDACTED]",
+ // as set by the organization PII redaction setting
+ PiiRedaction bool `protobuf:"varint,22,opt,name=pii_redaction,json=piiRedaction,proto3" json:"pii_redaction,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
}
func (x *Attestation) Reset() {
@@ -360,6 +363,13 @@ func (x *Attestation) GetRedactedEnvVars() []string {
return nil
}
+func (x *Attestation) GetPiiRedaction() bool {
+ if x != nil {
+ return x.PiiRedaction
+ }
+ return false
+}
+
// The runner environment in which the attestation was crafted
type RunnerEnvironment struct {
state protoimpl.MessageState `protogen:"open.v1"`
@@ -2853,7 +2863,7 @@ var File_attestation_v1_crafting_state_proto protoreflect.FileDescriptor
const file_attestation_v1_crafting_state_proto_rawDesc = "" +
"\n" +
- "#attestation/v1/crafting_state.proto\x12\x0eattestation.v1\x1a\x1bbuf/validate/validate.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1egoogle/protobuf/wrappers.proto\x1a)workflowcontract/v1/crafting_schema.proto\"\xe9\x1c\n" +
+ "#attestation/v1/crafting_state.proto\x12\x0eattestation.v1\x1a\x1bbuf/validate/validate.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1egoogle/protobuf/wrappers.proto\x1a)workflowcontract/v1/crafting_schema.proto\"\x8e\x1d\n" +
"\vAttestation\x12I\n" +
"\x0einitialized_at\x18\x01 \x01(\v2\x1a.google.protobuf.TimestampB\x06\xbaH\x03\xc8\x01\x01R\rinitializedAt\x12;\n" +
"\vfinished_at\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\n" +
@@ -2878,7 +2888,8 @@ const file_attestation_v1_crafting_state_proto_rawDesc = "" +
"\vcas_backend\x18\x13 \x01(\v2&.attestation.v1.Attestation.CASBackendR\n" +
"casBackend\x12/\n" +
"\x14skip_runner_env_vars\x18\x14 \x01(\bR\x11skipRunnerEnvVars\x12*\n" +
- "\x11redacted_env_vars\x18\x15 \x03(\tR\x0fredactedEnvVars\x1ab\n" +
+ "\x11redacted_env_vars\x18\x15 \x03(\tR\x0fredactedEnvVars\x12#\n" +
+ "\rpii_redaction\x18\x16 \x01(\bR\fpiiRedaction\x1ab\n" +
"\x0eMaterialsEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12:\n" +
"\x05value\x18\x02 \x01(\v2$.attestation.v1.Attestation.MaterialR\x05value:\x028\x01\x1a>\n" +
diff --git a/pkg/attestation/crafter/api/attestation/v1/crafting_state.proto b/pkg/attestation/crafter/api/attestation/v1/crafting_state.proto
index dd23befc2..924629469 100644
--- a/pkg/attestation/crafter/api/attestation/v1/crafting_state.proto
+++ b/pkg/attestation/crafter/api/attestation/v1/crafting_state.proto
@@ -172,6 +172,10 @@ message Attestation {
// It applies to the runner env vars and to the contract's env_allow_list.
repeated string redacted_env_vars = 21;
+ // replace the head commit author and the PR/MR author and reviewer logins with "[REDACTED]",
+ // as set by the organization PII redaction setting
+ bool pii_redaction = 22;
+
message Auth {
AuthType type = 1 [(buf.validate.field).enum = {
not_in: [0]
diff --git a/pkg/attestation/crafter/crafter.go b/pkg/attestation/crafter/crafter.go
index 3e43590e7..52567bbe1 100644
--- a/pkg/attestation/crafter/crafter.go
+++ b/pkg/attestation/crafter/crafter.go
@@ -230,6 +230,8 @@ type InitOpts struct {
SkipRunnerEnvVars bool
// names of the env vars to redact, resolved by the control plane from the org setting
RedactedEnvVars []string
+ // replace the head commit author and the PR/MR author and reviewer logins with a placeholder
+ PIIRedaction bool
// CAS backend information
CASBackend *api.Attestation_CASBackend
// UIDashboardURL is the base URL to build the attestation view link
@@ -325,6 +327,14 @@ type HeadCommit struct {
PlatformVerification *api.Commit_CommitVerification
}
+// redactAuthor replaces the author name, and the email when it is set, with a placeholder
+func (h *HeadCommit) redactAuthor() {
+ h.AuthorName = envredaction.RedactedValue
+ if h.AuthorEmail != "" {
+ h.AuthorEmail = envredaction.RedactedValue
+ }
+}
+
type CommitRemote struct {
Name, URL string
}
@@ -502,6 +512,11 @@ func initialCraftingState(cwd string, opts *InitOpts) (*api.CraftingState, error
headCommit.PlatformVerification = verifyCommitWithPlatform(headCommit, opts.Runner, opts.Logger)
}
+ // Redact only after the platform verification, which needs the real commit
+ if opts.PIIRedaction {
+ headCommit.redactAuthor()
+ }
+
headCommitP = headCommit.toProto()
}
@@ -534,6 +549,7 @@ func initialCraftingState(cwd string, opts *InitOpts) (*api.CraftingState, error
PoliciesAllowedHostnames: opts.PoliciesAllowedHostnames,
SkipRunnerEnvVars: opts.SkipRunnerEnvVars,
RedactedEnvVars: opts.RedactedEnvVars,
+ PiiRedaction: opts.PIIRedaction,
CasBackend: opts.CASBackend,
},
DryRun: opts.DryRun,
@@ -810,9 +826,11 @@ func (c *Crafter) stageMaterial(ctx context.Context, m *schemaapi.CraftingSchema
}
// 3- Craft resulting material
+ piiRedaction := c.CraftingState.GetAttestation().GetPiiRedaction()
crafted, err := materials.Craft(context.Background(), m, value, casBackend, c.ociRegistryAuth, c.Logger, &materials.CraftingOpts{
NoStrictValidation: c.noStrictValidation,
SkipSecretRedaction: c.skipSecretRedaction,
+ PIIRedaction: piiRedaction,
})
if err != nil {
return nil, err
@@ -836,6 +854,12 @@ func (c *Crafter) stageMaterial(ctx context.Context, m *schemaapi.CraftingSchema
mt.Annotations[kr] = vr
}
+ // Only a material crafter sets the PII redaction mark, when it redacts.
+ // Without PII redaction, a contract or a runtime annotation cannot set it.
+ if !piiRedaction {
+ delete(mt.Annotations, api.AnnotationMaterialPIIRedacted)
+ }
+
// Make sure all the annotation values are now set
// This is in fact validated below but by manually checking we can provide a better error message
for k, v := range mt.Annotations {
diff --git a/pkg/attestation/crafter/crafter_test.go b/pkg/attestation/crafter/crafter_test.go
index 3dd81660f..857311e06 100644
--- a/pkg/attestation/crafter/crafter_test.go
+++ b/pkg/attestation/crafter/crafter_test.go
@@ -221,6 +221,79 @@ func (s *crafterSuite) TestInit() {
}
}
+// With PII redaction on, the head commit keeps its hash but stores the
+// redacted author. With it off, the author stays as it is.
+func (s *crafterSuite) TestInitPIIRedaction() {
+ testCases := []struct {
+ name string
+ redact bool
+ wantName string
+ wantEmail string
+ }{
+ {name: "redaction on", redact: true, wantName: envredaction.RedactedValue, wantEmail: envredaction.RedactedValue},
+ {name: "redaction off", wantName: "John Doe", wantEmail: "john@doe.org"},
+ }
+
+ for _, tc := range testCases {
+ s.Run(tc.name, func() {
+ contract, err := loadSchema("testdata/contracts/empty_generic.yaml")
+ require.NoError(s.T(), err)
+
+ statePath := fmt.Sprintf("%s/attestation.json", s.T().TempDir())
+ c, err := crafter.NewCrafter(testingStateManager(s.T(), statePath), nil, crafter.WithWorkingDirPath(s.repoPath))
+ require.NoError(s.T(), err)
+
+ require.NoError(s.T(), c.Init(context.Background(), &crafter.InitOpts{
+ SchemaV1: contract, WfInfo: s.workflowMetadata, DryRun: true,
+ Runner: runners.NewGeneric(), PIIRedaction: tc.redact,
+ }))
+
+ head := c.CraftingState.GetAttestation().GetHead()
+ s.Equal(s.repoHead, head.GetHash())
+ s.Equal(tc.wantName, head.GetAuthorName())
+ s.Equal(tc.wantEmail, head.GetAuthorEmail())
+ s.Equal(tc.redact, c.CraftingState.GetAttestation().GetPiiRedaction())
+ })
+ }
+}
+
+// Only the crafter sets the PII redaction mark of a PR info material: a runtime
+// annotation can neither set it nor keep it when the crafter did not redact.
+func (s *crafterSuite) TestAddMaterialPRInfoPIIRedactionMark() {
+ const evidence = `{"chainloop.material.evidence.id":"CHAINLOOP_PR_INFO","schema":"https://schemas.chainloop.dev/prinfo/1.3/pr-info.schema.json",` +
+ `"data":{"platform":"github","type":"pull_request","number":"1","url":"https://github.com/org/repo/pull/1","author":{"login":"jdoe","type":"User"}}}`
+
+ testCases := []struct {
+ name string
+ redact bool
+ wantMark bool
+ }{
+ {name: "redaction on sets the mark", redact: true, wantMark: true},
+ {name: "redaction off drops a runtime mark"},
+ }
+
+ for _, tc := range testCases {
+ s.Run(tc.name, func() {
+ path := filepath.Join(s.T().TempDir(), "pr-info.json")
+ require.NoError(s.T(), os.WriteFile(path, []byte(evidence), 0o600))
+
+ c, err := newInitializedCrafter(s.T(), "testdata/contracts/empty_generic.yaml", &v1.WorkflowMetadata{}, true, "", runners.NewGeneric())
+ require.NoError(s.T(), err)
+ c.CraftingState.Attestation.PiiRedaction = tc.redact
+
+ m, err := c.AddMaterialContractFree(context.Background(), "",
+ schemaapi.CraftingSchema_Material_CHAINLOOP_PR_INFO.String(), "pr", path,
+ &casclient.CASBackend{Name: "inline"},
+ map[string]string{v1.AnnotationMaterialPIIRedacted: v1.AnnotationValueTrue})
+ require.NoError(s.T(), err)
+
+ _, marked := m.Annotations[v1.AnnotationMaterialPIIRedacted]
+ s.Equal(tc.wantMark, marked)
+ s.Equal(tc.redact, strings.Contains(string(m.GetArtifact().GetContent()), envredaction.RedactedValue))
+ })
+ }
+}
+
func (s *crafterSuite) TestInitPRMode() {
// PR mode sets the chainloop.dev/is-pull-request=true annotation on the
// attestation. When PR mode is off, no such annotation is present.
diff --git a/pkg/attestation/crafter/materials/chainloop_pr_info.go b/pkg/attestation/crafter/materials/chainloop_pr_info.go
index 46694c4a4..cfdf0c0af 100644
--- a/pkg/attestation/crafter/materials/chainloop_pr_info.go
+++ b/pkg/attestation/crafter/materials/chainloop_pr_info.go
@@ -22,6 +22,8 @@ import (
"os"
schemaapi "github.com/chainloop-dev/chainloop/app/controlplane/api/workflowcontract/v1"
+ api "github.com/chainloop-dev/chainloop/pkg/attestation/crafter/api/attestation/v1"
+ "github.com/chainloop-dev/chainloop/pkg/attestation/envredaction"
"github.com/chainloop-dev/chainloop/pkg/casclient"
"github.com/chainloop-dev/chainloop/pkg/prinfo"
@@ -30,19 +32,33 @@ import (
type ChainloopPRInfoCrafter struct {
*crafterCommon
- backend *casclient.CASBackend
+ backend *casclient.CASBackend
+ piiRedaction bool
+}
+
+type ChainloopPRInfoCrafterOption func(*ChainloopPRInfoCrafter)
+
+// WithPRInfoPIIRedaction replaces the author and reviewer logins with a placeholder
+// before the material is stored.
+func WithPRInfoPIIRedaction(redact bool) ChainloopPRInfoCrafterOption {
+ return func(c *ChainloopPRInfoCrafter) { c.piiRedaction = redact }
}
// NewChainloopPRInfoCrafter generates a new CHAINLOOP_PR_INFO material.
// This material type contains Pull Request or Merge Request metadata
// collected automatically during attestation in a PR/MR context.
-func NewChainloopPRInfoCrafter(schema *schemaapi.CraftingSchema_Material, backend *casclient.CASBackend, l *zerolog.Logger) (*ChainloopPRInfoCrafter, error) {
+func NewChainloopPRInfoCrafter(schema *schemaapi.CraftingSchema_Material, backend *casclient.CASBackend, l *zerolog.Logger, opts ...ChainloopPRInfoCrafterOption) (*ChainloopPRInfoCrafter, error) {
if schema.Type != schemaapi.CraftingSchema_Material_CHAINLOOP_PR_INFO {
return nil, fmt.Errorf("material type is not chainloop_pr_info")
}
craftCommon := &crafterCommon{logger: l, input: schema}
- return &ChainloopPRInfoCrafter{backend: backend, crafterCommon: craftCommon}, nil
+ c := &ChainloopPRInfoCrafter{backend: backend, crafterCommon: craftCommon}
+ for _, opt := range opts {
+ opt(c)
+ }
+
+ return c, nil
}
// Craft will validate the PR info against the JSON schema, calculate the digest of the artifact,
@@ -78,11 +94,24 @@ func (i *ChainloopPRInfoCrafter) Craft(ctx context.Context, artifactPath string)
return nil, fmt.Errorf("PR info validation failed: %w", err)
}
- // Upload the artifact
- material, err := uploadAndCraft(ctx, i.input, i.backend, artifactPath, i.logger)
+ // With PII redaction, store and evaluate only the redacted content
+ var redacted []byte
+ var craftOpts []uploadAndCraftOption
+ if i.piiRedaction {
+ if redacted, err = prinfo.RedactIdentities(f, envredaction.RedactedValue); err != nil {
+ return nil, fmt.Errorf("redacting PR info: %w", err)
+ }
+ craftOpts = append(craftOpts, withContentOverride(redacted))
+ }
+
+ material, err := uploadAndCraft(ctx, i.input, i.backend, artifactPath, i.logger, craftOpts...)
if err != nil {
return nil, err
}
- return craftResult(material, nil)
+ if i.piiRedaction {
+ material.Annotations[api.AnnotationMaterialPIIRedacted] = api.AnnotationValueTrue
+ }
+
+ return &CraftResult{Material: material, Content: redacted}, nil
}
diff --git a/pkg/attestation/crafter/materials/chainloop_pr_info_test.go b/pkg/attestation/crafter/materials/chainloop_pr_info_test.go
index 31144270e..0f66d17bd 100644
--- a/pkg/attestation/crafter/materials/chainloop_pr_info_test.go
+++ b/pkg/attestation/crafter/materials/chainloop_pr_info_test.go
@@ -16,12 +16,16 @@
package materials
import (
+ "context"
"encoding/json"
"os"
"path/filepath"
"testing"
schemaapi "github.com/chainloop-dev/chainloop/app/controlplane/api/workflowcontract/v1"
+ api "github.com/chainloop-dev/chainloop/pkg/attestation/crafter/api/attestation/v1"
+ "github.com/chainloop-dev/chainloop/pkg/attestation/envredaction"
+ "github.com/chainloop-dev/chainloop/pkg/casclient"
"github.com/chainloop-dev/chainloop/pkg/prinfo"
"github.com/rs/zerolog"
"github.com/stretchr/testify/assert"
@@ -189,3 +193,50 @@ func TestChainloopPRInfoCrafter_WrongMaterialType(t *testing.T) {
require.Error(t, err)
assert.Contains(t, err.Error(), "material type is not chainloop_pr_info")
}
+
+func TestChainloopPRInfoCrafter_PIIRedaction(t *testing.T) {
+ const evidence = `{"chainloop.material.evidence.id":"CHAINLOOP_PR_INFO","schema":"https://schemas.chainloop.dev/prinfo/1.3/pr-info.schema.json",` +
+ `"data":{"platform":"github","type":"pull_request","number":"1","url":"https://github.com/org/repo/pull/1",` +
+ `"author":{"login":"jdoe","type":"User"},"reviewers":[{"login":"asmith","type":"User","requested":true,"review_status":"APPROVED"}]}}`
+
+ testCases := []struct {
+ name string
+ redact bool
+ }{
+ {name: "redaction on stores the redacted content", redact: true},
+ {name: "redaction off stores the file as it is"},
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "pr-info.json")
+ require.NoError(t, os.WriteFile(path, []byte(evidence), 0600))
+
+ logger := zerolog.Nop()
+ schema := &schemaapi.CraftingSchema_Material{Name: "pr", Type: schemaapi.CraftingSchema_Material_CHAINLOOP_PR_INFO}
+ crafter, err := NewChainloopPRInfoCrafter(schema, &casclient.CASBackend{Name: "inline"}, &logger, WithPRInfoPIIRedaction(tc.redact))
+ require.NoError(t, err)
+
+ got, err := crafter.Craft(context.TODO(), path)
+ require.NoError(t, err)
+
+ stored := got.Material.GetArtifact().GetContent()
+ _, marked := got.Material.Annotations[api.AnnotationMaterialPIIRedacted]
+ assert.Equal(t, tc.redact, marked)
+ if !tc.redact {
+ assert.Equal(t, evidence, string(stored))
+ assert.Nil(t, got.Content)
+ return
+ }
+
+ // policies get the same bytes that are stored
+ assert.Equal(t, stored, got.Content)
+
+ var ev prinfo.Evidence
+ require.NoError(t, json.Unmarshal(stored, &ev))
+ assert.Equal(t, &prinfo.Author{Login: envredaction.RedactedValue, Type: "User"}, ev.Data.Author)
+ assert.Equal(t, []prinfo.Reviewer{{Login: envredaction.RedactedValue, Type: "User", Requested: true, ReviewStatus: "APPROVED"}}, ev.Data.Reviewers)
+ assert.Equal(t, "https://github.com/org/repo/pull/1", ev.Data.URL)
+ })
+ }
+}
diff --git a/pkg/attestation/crafter/materials/materials.go b/pkg/attestation/crafter/materials/materials.go
index d7dbc0151..ed6674b8b 100644
--- a/pkg/attestation/crafter/materials/materials.go
+++ b/pkg/attestation/crafter/materials/materials.go
@@ -385,6 +385,9 @@ type CraftingOpts struct {
// SkipSecretRedaction stores evidence exactly as captured, without stripping
// secrets out of it first. Only material types that redact honour it.
SkipSecretRedaction bool
+ // PIIRedaction replaces the personal data of the material types that hold it
+ // with a placeholder. Today only the PR info material honours it.
+ PIIRedaction bool
}
//nolint:gocyclo
@@ -456,7 +459,7 @@ func Craft(ctx context.Context, materialSchema *schemaapi.CraftingSchema_Materia
case schemaapi.CraftingSchema_Material_CHAINLOOP_RUNNER_CONTEXT:
crafter, err = NewRunnerContextCrafter(materialSchema, casBackend, logger)
case schemaapi.CraftingSchema_Material_CHAINLOOP_PR_INFO:
- crafter, err = NewChainloopPRInfoCrafter(materialSchema, casBackend, logger)
+ crafter, err = NewChainloopPRInfoCrafter(materialSchema, casBackend, logger, WithPRInfoPIIRedaction(opts.PIIRedaction))
case schemaapi.CraftingSchema_Material_GITLEAKS_JSON:
crafter, err = NewGitleaksReportCrafter(materialSchema, casBackend, logger)
case schemaapi.CraftingSchema_Material_YELP_DETECT_SECRETS_BASELINE:
diff --git a/pkg/attestation/envredaction/envredaction.go b/pkg/attestation/envredaction/envredaction.go
index 78b1495d9..2e9445ca9 100644
--- a/pkg/attestation/envredaction/envredaction.go
+++ b/pkg/attestation/envredaction/envredaction.go
@@ -84,10 +84,16 @@ func Apply(env map[string]string, names []string) {
func Violations(env map[string]string, names []string) []string {
var out []string
for _, name := range names {
- if v := env[name]; v != "" && v != RedactedValue {
+ if IsClear(env[name]) {
out = append(out, name)
}
}
slices.Sort(out)
return out
}
+
+// IsClear reports whether a value that the setting redacts still holds data:
+// it is not empty and it is not the placeholder.
+func IsClear(v string) bool {
+ return v != "" && v != RedactedValue
+}
diff --git a/pkg/attestation/renderer/chainloop/chainloop.go b/pkg/attestation/renderer/chainloop/chainloop.go
index 76758799a..404326537 100644
--- a/pkg/attestation/renderer/chainloop/chainloop.go
+++ b/pkg/attestation/renderer/chainloop/chainloop.go
@@ -276,10 +276,16 @@ func ExtractPredicate(envelope *dsse.Envelope) (NormalizablePredicate, error) {
}
// 2 - Extract the Chainloop predicate from the in-toto statement
+ return PredicateFromStatement(statement)
+}
+
+// PredicateFromStatement extracts the Chainloop attestation predicate from an in-toto statement
+// that the caller already decoded, for callers that also read the statement itself.
+func PredicateFromStatement(statement *intoto.Statement) (NormalizablePredicate, error) {
switch statement.PredicateType {
case PredicateTypeV02:
var predicate ProvenancePredicateV02
- if err = extractPredicate(statement, &predicate); err != nil {
+ if err := extractPredicate(statement, &predicate); err != nil {
return nil, fmt.Errorf("extracting predicate: %w", err)
}
@@ -357,8 +363,8 @@ func (p *ProvenancePredicateCommon) GetMetadata() *Metadata {
const (
// Subject names
SubjectGitHead = "git.head"
- subjectGitAnnotationAuthorEmail = "author.email"
- subjectGitAnnotationAuthorName = "author.name"
+ SubjectGitAnnotationAuthorEmail = "author.email"
+ SubjectGitAnnotationAuthorName = "author.name"
subjectGitAnnotationAuthorVerificationStatus = "author.verification_status"
subjectGitAnnotationWhen = "date"
subjectGitAnnotationMessage = "message"
@@ -366,3 +372,45 @@ const (
subjectGitAnnotationSignature = "signature"
subjectGitAnnotationSignatureAlgorithm = "signature.algorithm"
)
+
+// GitAuthor is the commit author that a git.head subject records
+type GitAuthor struct {
+ Name, Email string
+}
+
+// GitHeadAuthors returns the author of each git.head subject of a statement.
+// A value that is not a string is returned in its JSON form, so that a caller
+// that checks the values does not read it as empty.
+func GitHeadAuthors(statement *intoto.Statement) []GitAuthor {
+ var authors []GitAuthor
+ for _, subject := range statement.GetSubject() {
+ if subject.GetName() != SubjectGitHead {
+ continue
+ }
+
+ fields := subject.GetAnnotations().GetFields()
+ authors = append(authors, GitAuthor{
+ Name: annotationText(fields[SubjectGitAnnotationAuthorName]),
+ Email: annotationText(fields[SubjectGitAnnotationAuthorEmail]),
+ })
+ }
+
+ return authors
+}
+
+// annotationText returns the text of an annotation value: empty for a missing or
+// null value, the string for a string, and the JSON form for any other kind.
+func annotationText(v *structpb.Value) string {
+ switch v.GetKind().(type) {
+ case nil, *structpb.Value_NullValue:
+ return ""
+ case *structpb.Value_StringValue:
+ return v.GetStringValue()
+ default:
+ b, err := protojson.Marshal(v)
+ if err != nil {
+ return v.String()
+ }
+ return string(b)
+ }
+}
diff --git a/pkg/attestation/renderer/chainloop/v02.go b/pkg/attestation/renderer/chainloop/v02.go
index 0e20929cb..336c0b3c9 100644
--- a/pkg/attestation/renderer/chainloop/v02.go
+++ b/pkg/attestation/renderer/chainloop/v02.go
@@ -192,8 +192,8 @@ func (r *RendererV02) Statement(_ context.Context) (*intoto.Statement, error) {
func commitAnnotations(c *v1.Commit) (*structpb.Struct, error) {
annotationsRaw := map[string]interface{}{
subjectGitAnnotationWhen: c.GetDate().AsTime().Format(time.RFC3339),
- subjectGitAnnotationAuthorEmail: c.GetAuthorEmail(),
- subjectGitAnnotationAuthorName: c.GetAuthorName(),
+ SubjectGitAnnotationAuthorEmail: c.GetAuthorEmail(),
+ SubjectGitAnnotationAuthorName: c.GetAuthorName(),
subjectGitAnnotationMessage: c.GetMessage(),
}
diff --git a/pkg/prinfo/redact.go b/pkg/prinfo/redact.go
new file mode 100644
index 000000000..6754dfa50
--- /dev/null
+++ b/pkg/prinfo/redact.go
@@ -0,0 +1,134 @@
+//
+// Copyright 2026 The Chainloop Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package prinfo
+
+import (
+ "encoding/json"
+ "fmt"
+ "strings"
+)
+
+// jsonNull is the raw form of a JSON null
+const jsonNull = "null"
+
+// jsonObject keeps the fields of a JSON object that the redaction does not change as they are
+type jsonObject map[string]json.RawMessage
+
+// keys returns the keys of the object that match name. Like encoding/json, which the
+// validation before the redaction uses, the match ignores case.
+func (o jsonObject) keys(name string) []string {
+ var out []string
+ for k := range o {
+ if strings.EqualFold(k, name) {
+ out = append(out, k)
+ }
+ }
+ return out
+}
+
+// RedactIdentities replaces the login of the author and of each reviewer of PR info
+// evidence with placeholder. All other fields keep their value and their form, so an
+// author string of the older schemas stays a string, and the evidence stays valid
+// for the schema it names.
+func RedactIdentities(evidence []byte, placeholder string) ([]byte, error) {
+ login, err := json.Marshal(placeholder)
+ if err != nil {
+ return nil, err
+ }
+
+ var doc jsonObject
+ if err := json.Unmarshal(evidence, &doc); err != nil {
+ return nil, fmt.Errorf("decoding evidence: %w", err)
+ }
+
+ for _, dataKey := range doc.keys("data") {
+ var data jsonObject
+ if err := json.Unmarshal(doc[dataKey], &data); err != nil {
+ return nil, fmt.Errorf("decoding data: %w", err)
+ }
+
+ for _, k := range data.keys("author") {
+ if data[k], err = redactAuthor(data[k], login); err != nil {
+ return nil, err
+ }
+ }
+
+ for _, k := range data.keys("reviewers") {
+ if data[k], err = redactReviewers(data[k], login); err != nil {
+ return nil, err
+ }
+ }
+
+ if doc[dataKey], err = json.Marshal(data); err != nil {
+ return nil, err
+ }
+ }
+
+ return json.Marshal(doc)
+}
+
+// redactAuthor replaces the author login. The author is a string in the schemas
+// 1.0 to 1.2, and an object in later ones, as Data.UnmarshalJSON also accepts.
+// It keeps the form, which a round trip through Data would turn into an object.
+func redactAuthor(author, login json.RawMessage) (json.RawMessage, error) {
+ if string(author) == jsonNull {
+ return author, nil
+ }
+
+ var s string
+ if err := json.Unmarshal(author, &s); err == nil {
+ return login, nil
+ }
+
+ var obj jsonObject
+ if err := json.Unmarshal(author, &obj); err != nil {
+ return nil, fmt.Errorf("author field must be a string or an object: %w", err)
+ }
+
+ setLogin(obj, login)
+ return json.Marshal(obj)
+}
+
+// redactReviewers replaces the login of each reviewer
+func redactReviewers(raw, login json.RawMessage) (json.RawMessage, error) {
+ if string(raw) == jsonNull {
+ return raw, nil
+ }
+
+ var reviewers []jsonObject
+ if err := json.Unmarshal(raw, &reviewers); err != nil {
+ return nil, fmt.Errorf("decoding reviewers: %w", err)
+ }
+
+ for _, r := range reviewers {
+ setLogin(r, login)
+ }
+
+ return json.Marshal(reviewers)
+}
+
+// setLogin replaces each login field of an account object, in any letter case.
+// The schema requires the field, so it adds it when the object has none.
+func setLogin(obj jsonObject, login json.RawMessage) {
+ keys := obj.keys("login")
+ if len(keys) == 0 {
+ keys = []string{"login"}
+ }
+
+ for _, k := range keys {
+ obj[k] = login
+ }
+}
diff --git a/pkg/prinfo/redact_test.go b/pkg/prinfo/redact_test.go
new file mode 100644
index 000000000..6516d47d2
--- /dev/null
+++ b/pkg/prinfo/redact_test.go
@@ -0,0 +1,81 @@
+//
+// Copyright 2026 The Chainloop Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package prinfo
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+)
+
+func TestRedactIdentities(t *testing.T) {
+ const placeholder = "[REDACTED]"
+
+ testCases := []struct {
+ name string
+ in string
+ want string
+ wantErr bool
+ }{
+ {
+ name: "object author and reviewers",
+ in: `{"schema":"s","data":{"number":"1","author":{"login":"jdoe","type":"User"},"reviewers":[{"login":"a","type":"Bot","requested":false,"review_status":"APPROVED"},{"login":"b","type":"User","requested":true}]}}`,
+ want: `{"data":{"author":{"login":"[REDACTED]","type":"User"},"number":"1","reviewers":[{"login":"[REDACTED]","requested":false,"review_status":"APPROVED","type":"Bot"},{"login":"[REDACTED]","requested":true,"type":"User"}]},"schema":"s"}`,
+ },
+ {
+ name: "string author of the older schemas stays a string",
+ in: `{"schema":"s","data":{"author":"jdoe"}}`,
+ want: `{"data":{"author":"[REDACTED]"},"schema":"s"}`,
+ },
+ {
+ name: "no author and no reviewers",
+ in: `{"schema":"s","data":{"number":"1"}}`,
+ want: `{"data":{"number":"1"},"schema":"s"}`,
+ },
+ {
+ name: "null author and reviewers stay null",
+ in: `{"data":{"author":null,"reviewers":null}}`,
+ want: `{"data":{"author":null,"reviewers":null}}`,
+ },
+ {
+ name: "keys in another letter case are redacted, as decoding ignores case",
+ in: `{"Data":{"Author":{"Login":"jdoe","type":"User"},"REVIEWERS":[{"LOGIN":"a","type":"User","requested":true}]}}`,
+ want: `{"Data":{"Author":{"Login":"[REDACTED]","type":"User"},"REVIEWERS":[{"LOGIN":"[REDACTED]","requested":true,"type":"User"}]}}`,
+ },
+ {
+ name: "an account without a login gets the placeholder",
+ in: `{"data":{"author":{"type":"User"},"reviewers":[{"type":"User","requested":true}]}}`,
+ want: `{"data":{"author":{"login":"[REDACTED]","type":"User"},"reviewers":[{"login":"[REDACTED]","requested":true,"type":"User"}]}}`,
+ },
+ {name: "invalid JSON", in: `{`, wantErr: true},
+ {name: "author of an invalid type", in: `{"data":{"author":1}}`, wantErr: true},
+ {name: "reviewers of an invalid type", in: `{"data":{"reviewers":"jdoe"}}`, wantErr: true},
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ got, err := RedactIdentities([]byte(tc.in), placeholder)
+ if tc.wantErr {
+ require.Error(t, err)
+ return
+ }
+
+ require.NoError(t, err)
+ assert.JSONEq(t, tc.want, string(got))
+ })
+ }
+}