Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/cli/cmd/organization_describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"
}
13 changes: 10 additions & 3 deletions app/cli/cmd/organization_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func newOrganizationUpdateCmd() *cobra.Command {
skipRunnerEnvVars bool
envVarRedaction string
redactedEnvVars []string
piiRedaction bool
)

cmd := &cobra.Command{
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
3 changes: 2 additions & 1 deletion app/cli/documentation/cli-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions app/cli/pkg/action/attestation_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions app/cli/pkg/action/membership_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions app/cli/pkg/action/org_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down
23 changes: 18 additions & 5 deletions app/controlplane/api/controlplane/v1/organization.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions app/controlplane/api/controlplane/v1/organization.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 18 additions & 6 deletions app/controlplane/api/controlplane/v1/response_messages.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions app/controlplane/api/controlplane/v1/response_messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
21 changes: 16 additions & 5 deletions app/controlplane/api/controlplane/v1/workflow_run.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/controlplane/api/controlplane/v1/workflow_run.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading