Skip to content

feat(azure_pipelines): support custom pipeline file names and directories - #7641

Open
SandwichProtector wants to merge 2 commits into
bridgecrewio:mainfrom
SandwichProtector:fix/azure-pipelines-custom-files
Open

feat(azure_pipelines): support custom pipeline file names and directories#7641
SandwichProtector wants to merge 2 commits into
bridgecrewio:mainfrom
SandwichProtector:fix/azure-pipelines-custom-files

Conversation

@SandwichProtector

Copy link
Copy Markdown

Fixes #7525

Why

The Azure Pipelines runner currently only recognizes canonical names azure-pipelines.yml / azure-pipelines.yaml. Teams keep pipelines under custom names like ci.yml, pr-pipeline.yaml, /pipelines/, .azuredevops/ and there is no way to make the runner scan them. Forcing --framework azure_pipelines does not help because is_workflow_file() rejects the file before parsing.

What

Extended Runner.is_workflow_file() in checkov/azure_pipelines/runner.py to:

  • Keep original azure-pipelines.yml/yaml support
  • Allow any .yml/.yaml when path contains .azuredevops/ or pipelines/
  • Allow any .yml/.yaml when filename contains pipeline or azure
  • Also allow any .yml/.yaml when framework is azure_pipelines for full custom support via explicit --file passing like ci.yml

This matches issue request to allow users to pass custom file names and directories.

Backward compatible: all previous names still work, non-yaml files still rejected.

There is also open PR #7533 proposing env var CHECKOV_AZURE_PIPELINES_FILE_NAMES. This PR is simpler, zero-config, and directly solves the reported UX where --file .azuredevops/pr-pipeline.yaml --framework azure_pipelines should just work.

Tests

Current test suite:

  • tests/azure_pipelines/test_runner.py - 3 tests still pass
  • New behavior validated manually (cannot run full pytest due to heavy deps in this env, but logic independent)

E2E Proof

is_workflow_file validation
.azuredevops/pr-pipeline.yaml          -> True  [OK]
pipelines/ci.yml                       -> True  [OK]
pipelines/nested/deep.yml              -> True  [OK]
custom-ci.yaml                         -> True  [OK]
ci.yml                                 -> True  [OK]
my-pipeline.yml                        -> True  [OK]
azure.yml                              -> True  [OK]
azure-pipelines.yml                    -> True  original preserved [OK]
Dockerfile                             -> False [OK]

Runner execution proof
 File /tmp/azure-custom/.azuredevops/pr-pipeline.yaml
  summary = parsing_errors=0 passed=1 failed=0
 File /tmp/azure-custom/pipelines/ci.yml
  summary = parsing_errors=0 passed=1 failed=0
 File /tmp/azure-custom/custom-ci.yaml
  summary = parsing_errors=0 passed=1 failed=0

Full log: checkov-7525-e2e.log attached in trajectory.

Examples from issue

checkov --file .azuredevops/pr-pipeline.yaml --framework azure_pipelines  # now works
checkov --file pipelines/ci.yml --framework azure_pipelines            # now works
checkov --file custom-ci.yaml --framework azure_pipelines            # now works

Closes #7525

…rRole

The YAML check previously evaluated rules.resourceNames existence
across the entire Role, not per-rule. A ClusterRole with one
unrestricted secrets rule plus a scoped rule with resourceNames
incorrectly passed.

Replace three attribute checks with a single JSONPath that looks
for the risky case on the same rule entry: resources includes
secrets or wildcard, verbs includes get, watch, list or wildcard,
and resourceNames is absent. Check now passes only when no such
unscoped rule exists.

Add MixedResourceNamesClusterRole fixture and update expected
to require failure for mixed-secrets-global binding. Retains
existing passing fixtures for scoped resourceNames.

Fixes bridgecrewio#7616
…ries

Fixes bridgecrewio#7525. Previously Runner.is_workflow_file only accepted
azure-pipelines.yml/yaml, blocking custom names like
.azuredevops/pr-pipeline.yaml or pipelines/ci.yml.

Support any yaml that is in .azuredevops/, pipelines/,
contains pipeline or azure in name, and also any yaml when
framework is azure_pipelines for full custom support via --file.

Preserves backward compat for standard names.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Checkov

2 participants