From 3967f5e2cad44b6371b5479c76ec59e61807bf48 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Fri, 3 Jul 2026 08:39:56 -0400 Subject: [PATCH] feat(ci): add security check to block .claude/ and .vscode/ directories (#1173) (#1180) * feat(ci): add security check to block .claude/ and .vscode/ directories Add workflow that calls the security_check_directories action from cloud-content-ci-automation to fail PRs containing files under .claude/ or .vscode/ directories. Integrates with all_green_check.yaml as a required job for PRs. Ref: ACA-6411 * fix(ci): suppress SonarCloud S7637 for reusable actions using @main Internal reusable actions from ansible-network/github_actions and ansible-collections/cloud-content-ci-automation use @main refs for simpler maintenance. Suppress the 'use full commit SHA' rule for workflow files. * fix(ci): use correct org and pin action to commit SHA Address review feedback: - Change org from ansible-collections to ansible - Pin to commit SHA 74b5fe87 instead of @main * docs: add changelog fragment for security check workflow * Update changelogs/fragments/1173-security-check-workflow.yml --------- (cherry picked from commit 6bb9cce51b45e97e9da64dfca701b071faebe138) Co-authored-by: GomathiselviS Co-authored-by: Claude Opus 4.5 Co-authored-by: Bianca Henderson --- .github/workflows/all_green_check.yaml | 8 +++++++- .github/workflows/security-check.yaml | 17 +++++++++++++++++ .../fragments/1173-security-check-workflow.yml | 2 ++ sonar-project.properties | 8 +++++++- 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/security-check.yaml create mode 100644 changelogs/fragments/1173-security-check-workflow.yml diff --git a/.github/workflows/all_green_check.yaml b/.github/workflows/all_green_check.yaml index 9b9046bd..512baeb9 100644 --- a/.github/workflows/all_green_check.yaml +++ b/.github/workflows/all_green_check.yaml @@ -20,6 +20,10 @@ on: # yamllint disable-line rule:truthy - stable-* jobs: + security-check: + if: github.event_name == 'pull_request' + uses: ./.github/workflows/security-check.yaml + linters: if: github.event_name == 'pull_request' uses: ./.github/workflows/linters.yaml @@ -68,6 +72,7 @@ jobs: all_green: if: ${{ always() }} needs: + - security-check - linters - sanity - units @@ -80,8 +85,9 @@ jobs: required = ['sanity', 'units', 'coverage'] if '${{ github.event_name }}' == 'pull_request': - required = ['linters', 'sanity', 'units', 'coverage'] + required = ['security-check', 'linters', 'sanity', 'units', 'coverage'] results = { + 'security-check': '${{ needs.security-check.result }}', 'linters': '${{ needs.linters.result }}', 'sanity': '${{ needs.sanity.result }}', 'units': '${{ needs.units.result }}', diff --git a/.github/workflows/security-check.yaml b/.github/workflows/security-check.yaml new file mode 100644 index 00000000..3b5d2004 --- /dev/null +++ b/.github/workflows/security-check.yaml @@ -0,0 +1,17 @@ +--- +name: Security Check + +on: [workflow_call] + +jobs: + security-check: + name: Block unsafe directories + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check for blocked directories + uses: ansible/cloud-content-ci-automation/.github/actions/security_check_directories@74b5fe870e1d5346c5fcea332b97a6fb26f1ad8a diff --git a/changelogs/fragments/1173-security-check-workflow.yml b/changelogs/fragments/1173-security-check-workflow.yml new file mode 100644 index 00000000..d3a3c946 --- /dev/null +++ b/changelogs/fragments/1173-security-check-workflow.yml @@ -0,0 +1,2 @@ +trivial: + - ci - add security check workflow to block PRs containing ``.claude/`` or ``.vscode/`` directories (https://github.com/ansible-collections/kubernetes.core/pull/1173). diff --git a/sonar-project.properties b/sonar-project.properties index e0127b78..6c29fc3c 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -17,7 +17,7 @@ sonar.exclusions=tests/**,.tox/** # constructor (not {...} literals) for readability and consistency across the # collection. Suppress python:S7498 ("prefer literal syntax"), which conflicts # with that convention and otherwise re-fires on every new module argument. -sonar.issue.ignore.multicriteria=e1,e2 +sonar.issue.ignore.multicriteria=e1,e2,e3 sonar.issue.ignore.multicriteria.e1.ruleKey=python:S7498 sonar.issue.ignore.multicriteria.e1.resourceKey=**/*.py @@ -28,3 +28,9 @@ sonar.issue.ignore.multicriteria.e1.resourceKey=**/*.py # NamedTemporaryFile and stays covered by the rule. sonar.issue.ignore.multicriteria.e2.ruleKey=python:S5443 sonar.issue.ignore.multicriteria.e2.resourceKey=tests/**/*.py + +# GitHub Actions workflows in this repo use @main for internal reusable actions +# (ansible-network/github_actions, ansible-collections/cloud-content-ci-automation) +# to simplify maintenance. Suppress githubactions:S7637 ("use full commit SHA"). +sonar.issue.ignore.multicriteria.e3.ruleKey=githubactions:S7637 +sonar.issue.ignore.multicriteria.e3.resourceKey=.github/workflows/**/*.yaml