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
16 changes: 9 additions & 7 deletions cmd/validate/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ func validateImageCmd(validate imageValidationFunc) *cobra.Command {

showSuccesses, _ := cmd.Flags().GetBool("show-successes")
showWarnings, _ := cmd.Flags().GetBool("show-warnings")
showPolicyDocsLink, _ := cmd.Flags().GetBool("show-policy-docs-link")

// worker is responsible for processing one component at a time from the jobs channel,
// and for emitting a corresponding result for the component on the results channel.
Expand Down Expand Up @@ -429,13 +430,14 @@ func validateImageCmd(validate imageValidationFunc) *cobra.Command {
}

reportData := validate_utils.ReportData{
Snapshot: data.snapshot,
Components: components,
Policy: data.policy,
PolicyInputs: manyPolicyInput,
Expansion: data.expansion,
ShowSuccesses: showSuccesses,
ShowWarnings: showWarnings,
Snapshot: data.snapshot,
Components: components,
Policy: data.policy,
PolicyInputs: manyPolicyInput,
Expansion: data.expansion,
ShowSuccesses: showSuccesses,
ShowWarnings: showWarnings,
ShowPolicyDocsLink: showPolicyDocsLink,
}
outputOpts := validate_utils.ReportOutputOptions{
Output: data.output,
Expand Down
3 changes: 2 additions & 1 deletion cmd/validate/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func validateInputCmd(validate InputValidationFunc) *cobra.Command {

showSuccesses, _ := cmd.Flags().GetBool("show-successes")
showWarnings, _ := cmd.Flags().GetBool("show-warnings")
showPolicyDocsLink, _ := cmd.Flags().GetBool("show-policy-docs-link")

// Set numWorkers to the value from our flag. The default is 5.
numWorkers := data.workers
Expand Down Expand Up @@ -210,7 +211,7 @@ func validateInputCmd(validate InputValidationFunc) *cobra.Command {
return inputs[i].FilePath > inputs[j].FilePath
})

report, err := input.NewReport(inputs, data.policy, manyPolicyInput, showSuccesses, showWarnings)
report, err := input.NewReport(inputs, data.policy, manyPolicyInput, showSuccesses, showWarnings, showPolicyDocsLink)
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions cmd/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ func NewValidateCmd() *cobra.Command {
}
validateCmd.PersistentFlags().Bool("show-successes", false, "")
validateCmd.PersistentFlags().Bool("show-warnings", true, "")
validateCmd.PersistentFlags().Bool("show-policy-docs-link", false, "Show link to policy documentation in output when there are violations or warnings")
return validateCmd
Comment on lines 46 to 49
Copy link
Contributor

Choose a reason for hiding this comment

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

Action required

1. Wrong flag default 🐞 Bug ✓ Correctness

The new persistent flag --show-policy-docs-link is registered with default=false, so the
documentation link will be hidden by default and validate output changes from prior behavior (and
from the PR description).
Agent Prompt
### Issue description
`--show-policy-docs-link` is intended to default to `true` (backward compatible), but it is currently registered with a default of `false`. Because the text report templates now require `ShowPolicyDocsLink` to be true to render the docs link, the docs link is suppressed by default.

### Issue Context
This impacts validate subcommands inheriting the persistent flag (`validate image`, `validate input`, `validate vsa` fallback reports).

### Fix Focus Areas
- cmd/validate/validate.go[46-49]  
  - Change the default value to `true`.
- docs/modules/ROOT/pages/ec_validate.adoc[5-10]  
  - Update displayed default to `true`.
- docs/modules/ROOT/pages/ec_validate_image.adoc[172-177]
- docs/modules/ROOT/pages/ec_validate_input.adoc[76-81]
- docs/modules/ROOT/pages/ec_validate_policy.adoc[37-42]
- docs/modules/ROOT/pages/ec_validate_vsa.adoc[60-65]
  - Update displayed defaults consistently.

### Notes
After changing the default, consider adding/adjusting tests that validate the docs link appears by default when warnings/violations exist.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the PR description to reflect the current beahviour. Recheck :whip:

}
24 changes: 15 additions & 9 deletions cmd/validate/vsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ type validateVSAData struct {
workers int // Number of worker threads for parallel processing

// Output formatting options
noColor bool // Disable color output
forceColor bool // Force color output
noColor bool // Disable color output
forceColor bool // Force color output
showPolicyDocsLink bool // Show policy docs link in output

// Internal state
policySpec ecapi.EnterpriseContractPolicySpec
Expand Down Expand Up @@ -266,6 +267,9 @@ func runValidateVSA(cmd *cobra.Command, data *validateVSAData, args []string) er
// Set color support based on flags
utils.SetColorEnabled(data.noColor, data.forceColor)

// Get show-policy-docs-link flag value
data.showPolicyDocsLink, _ = cmd.Flags().GetBool("show-policy-docs-link")

// Parse VSA expiration
if err := parseVSAExpiration(data); err != nil {
return err
Expand Down Expand Up @@ -1095,13 +1099,14 @@ func buildFallbackReportData(fallbackResults []validate_utils.Result, vsaData *v
}

return validate_utils.ReportData{
Snapshot: vsaData.images,
Components: components,
Policy: vsaData.fallbackContext.FallbackPolicy,
PolicyInputs: manyPolicyInput,
Expansion: nil,
ShowSuccesses: false,
ShowWarnings: true,
Snapshot: vsaData.images,
Components: components,
Policy: vsaData.fallbackContext.FallbackPolicy,
PolicyInputs: manyPolicyInput,
Expansion: nil,
ShowSuccesses: false,
ShowWarnings: true,
ShowPolicyDocsLink: vsaData.showPolicyDocsLink,
}, nil
}

Expand All @@ -1121,6 +1126,7 @@ func createFallbackReport(allData AllSectionsData, vsaData *validateVSAData) (*a
reportData.PolicyInputs,
reportData.ShowSuccesses,
reportData.ShowWarnings,
reportData.ShowPolicyDocsLink,
reportData.Expansion,
)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions cmd/validate/vsa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,8 @@ func TestValidateSingleVSA(t *testing.T) {
ctx := context.Background()
cmd := &cobra.Command{}
cmd.SetContext(ctx)
// Add the persistent flag that runValidateVSA expects
cmd.Flags().Bool("show-policy-docs-link", false, "")

// Use the unified runValidateVSA function which handles both single and snapshot cases
err := runValidateVSA(cmd, tt.data, tt.args)
Expand Down Expand Up @@ -1132,6 +1134,8 @@ func TestValidateSnapshotVSAs(t *testing.T) {
ctx := context.Background()
cmd := &cobra.Command{}
cmd.SetContext(ctx)
// Add the persistent flag that runValidateVSA expects
cmd.Flags().Bool("show-policy-docs-link", false, "")

// Use the unified runValidateVSA function which handles both single and snapshot cases
err := runValidateVSA(cmd, tt.data, []string{})
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_validate.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Validate conformance with the provided policies
== Options

-h, --help:: help for validate (Default: false)
--show-policy-docs-link:: Show link to policy documentation in output when there are violations or warnings (Default: false)
--show-successes:: (Default: false)
--show-warnings:: (Default: true)

Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_validate_image.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ JSON of the "spec" or a reference to a Kubernetes object [<namespace>/]<name>
--retry-jitter:: randomness factor for backoff calculation (0.0-1.0) (Default: 0.1)
--retry-max-retry:: maximum number of retry attempts (Default: 3)
--retry-max-wait:: maximum wait time between retries (Default: 3s)
--show-policy-docs-link:: Show link to policy documentation in output when there are violations or warnings (Default: false)
--show-successes:: (Default: false)
--show-warnings:: (Default: true)
--timeout:: max overall execution duration (Default: 5m0s)
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_validate_input.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ mark (?) sign, for example: --output text=output.txt?show-successes=false
--retry-jitter:: randomness factor for backoff calculation (0.0-1.0) (Default: 0.1)
--retry-max-retry:: maximum number of retry attempts (Default: 3)
--retry-max-wait:: maximum wait time between retries (Default: 3s)
--show-policy-docs-link:: Show link to policy documentation in output when there are violations or warnings (Default: false)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C2 --type=go 'show-policy-docs-link' cmd/validate
printf '\n'
rg -n -C1 --type=adoc 'show-policy-docs-link' docs/modules/ROOT/pages

Repository: conforma/cli

Length of output: 2464


Update flag default to true for backward compatibility.

The --show-policy-docs-link flag defaults to false in both code (cmd/validate/validate.go:48) and documentation (line 79), but backward compatibility requires it to default to true. This flips the behavior from opt-out to opt-in, breaking existing workflows. Update the flag registration and documentation to use Default: true.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/modules/ROOT/pages/ec_validate_input.adoc` at line 79, The
--show-policy-docs-link flag currently has a default of false; change its
registration in the validate command (the flag registration that defines
"show-policy-docs-link" in validate.go) to use Default: true (or set the Bool
flag default to true) and update the documentation entry that shows the default
value (the line displaying "--show-policy-docs-link:: ... (Default: false)" in
the ec_validate_input.adoc page) to reflect "(Default: true)". Ensure the flag
variable/name remains unchanged and only the default and doc text are updated so
behavior and help output match.

--show-successes:: (Default: false)
--show-warnings:: (Default: true)
--timeout:: max overall execution duration (Default: 5m0s)
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_validate_policy.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ ec validate policy --policy-configuration github.com/org/repo/policy.yaml
--retry-jitter:: randomness factor for backoff calculation (0.0-1.0) (Default: 0.1)
--retry-max-retry:: maximum number of retry attempts (Default: 3)
--retry-max-wait:: maximum wait time between retries (Default: 3s)
--show-policy-docs-link:: Show link to policy documentation in output when there are violations or warnings (Default: false)
--show-successes:: (Default: false)
--show-warnings:: (Default: true)
--timeout:: max overall execution duration (Default: 5m0s)
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_validate_vsa.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ mark (?) sign, for example: --output text=output.txt?show-successes=false
--retry-jitter:: randomness factor for backoff calculation (0.0-1.0) (Default: 0.1)
--retry-max-retry:: maximum number of retry attempts (Default: 3)
--retry-max-wait:: maximum wait time between retries (Default: 3s)
--show-policy-docs-link:: Show link to policy documentation in output when there are violations or warnings (Default: false)
--show-successes:: (Default: false)
--show-warnings:: (Default: true)
--timeout:: max overall execution duration (Default: 5m0s)
Expand Down
Loading
Loading