feat(azure_pipelines): allow custom file names via CHECKOV_AZURE_PIPELINES_FILE_NAMES (#7525)#7533
Open
ChrisJr404 wants to merge 1 commit into
Open
Conversation
…wio#7525) Azure Pipelines runner only recognized 'azure-pipelines.yml' / 'azure-pipelines.yaml'. Teams that store pipelines under custom names (ci.yml, pr-pipeline.yaml, .azuredevops/, etc.) had no way to scan them. This adds an opt-in CHECKOV_AZURE_PIPELINES_FILE_NAMES environment variable: a comma- or whitespace-separated list of additional file-name suffixes that the runner treats as Azure Pipelines configs. Defaults are unchanged when the env var is unset. Closes bridgecrewio#7525 Signed-off-by: Chris (ChrisJr404) <11917633+ChrisJr404@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #7525.
Why
The Azure Pipelines runner currently only recognizes the canonical names `azure-pipelines.yml` / `azure-pipelines.yaml`. Teams in the field (and the issue reporter @julianterenol) keep their pipelines under custom names — `ci.yml`, `pr-pipeline.yaml`, `/pipelines/`, `.azuredevops/` — and there's no way to make the runner scan them. Forcing `--framework azure_pipelines` doesn't help because `is_workflow_file()` rejects the file before the runner even reads it.
What
New opt-in environment variable:
(Comma- or whitespace-separated. With or without leading dot.)
When the variable is set, those suffixes are appended to the default set in
Runner.is_workflow_file(). Unset (the default) preserves today's behavior exactly.Tests
7 new unit tests in `tests/azure_pipelines/test_is_workflow_file.py` covering: defaults still recognised; unrelated YAMLs still rejected; comma separator; whitespace separator; empty env var; env var with only separators; env var doesn't leak across unset.
Existing test suite (`tests/azure_pipelines/`) — 17 tests — still passes:
```
$ pytest tests/azure_pipelines/ -v
======================== 17 passed, 6 warnings in 2.91s ========================
```
(My 7 new ones are inside that 17 total — the suite previously had 10.)
End-to-end
```
$ cat /tmp/checkov-e2e/pr-pipeline.yaml
trigger:
jobs:
pool:
vmImage: 'ubuntu-18.04'
container: 'ubuntu:latest'
steps:
Without the env var: 0 findings (file silently skipped)
$ checkov --file /tmp/checkov-e2e/pr-pipeline.yaml --framework azure_pipelines -o json | head -3
{
"passed": 0,
"failed": 0,
With it: full Azure Pipelines scan, CKV_AZUREPIPELINES_* checks fire
$ CHECKOV_AZURE_PIPELINES_FILE_NAMES="pr-pipeline.yaml" checkov --file /tmp/checkov-e2e/pr-pipeline.yaml --framework azure_pipelines -o json | head -10
{
"check_type": "azure_pipelines",
"results": {
"passed_checks": [...]
}
}
```
Notes