|
| 1 | +--- |
| 2 | +name: Mend SCA Security Scan |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + paths-ignore: |
| 7 | + - .github/** |
| 8 | + - assets/** |
| 9 | + - docs/** |
| 10 | + - .yamlfmt |
| 11 | + - .yamllint |
| 12 | + push: |
| 13 | + branches: |
| 14 | + - main |
| 15 | + paths-ignore: |
| 16 | + - .github/** |
| 17 | + - assets/** |
| 18 | + - docs/** |
| 19 | + - .yamlfmt |
| 20 | + - .yamllint |
| 21 | +permissions: read-all |
| 22 | +jobs: |
| 23 | + mend-sca: |
| 24 | + name: Mend dependency scan |
| 25 | + runs-on: ubuntu-latest |
| 26 | + permissions: |
| 27 | + contents: read |
| 28 | + security-events: write |
| 29 | + env: |
| 30 | + MEND_EMAIL: ${{ secrets.MEND_EMAIL }} |
| 31 | + MEND_USER_KEY: ${{ secrets.MEND_USER_KEY }} |
| 32 | + MEND_URL: ${{ secrets.MEND_URL }} |
| 33 | + steps: |
| 34 | + - name: Checkout code |
| 35 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 36 | + |
| 37 | + - name: Set up Python 3.11 |
| 38 | + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 39 | + with: |
| 40 | + python-version: "3.11" |
| 41 | + |
| 42 | + - name: Install Python dependencies |
| 43 | + run: | |
| 44 | + python -m pip install --upgrade pip |
| 45 | + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
| 46 | +
|
| 47 | + - name: Download and install Mend CLI |
| 48 | + run: | |
| 49 | + curl -fsSL https://downloads.mend.io/cli/linux_amd64/mend -o /usr/local/bin/mend |
| 50 | + chmod +x /usr/local/bin/mend |
| 51 | + mend version |
| 52 | +
|
| 53 | + - name: Run Mend dependency scan |
| 54 | + id: mend_scan |
| 55 | + continue-on-error: true |
| 56 | + run: | |
| 57 | + mend dep --dir . --scope "ansible-collection-netscaleradc" --non-interactive --export-results mend-results.json |
| 58 | +
|
| 59 | + - name: Convert results to SARIF |
| 60 | + if: always() && steps.mend_scan.outcome != 'skipped' |
| 61 | + continue-on-error: true |
| 62 | + run: | |
| 63 | + mend dep --dir . --scope "ansible-collection-netscaleradc" --non-interactive --format sarif --filename mend-output.sarif || true |
| 64 | +
|
| 65 | + - name: Upload Mend SARIF to GitHub Security tab |
| 66 | + if: always() && hashFiles('mend-output.sarif') != '' |
| 67 | + uses: github/codeql-action/upload-sarif@256d634097be96e792d6764f9edaefc4320557b1 # v4 |
| 68 | + with: |
| 69 | + sarif_file: mend-output.sarif |
| 70 | + |
| 71 | + - name: Upload scan results as artifact |
| 72 | + if: always() |
| 73 | + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| 74 | + with: |
| 75 | + name: mend-scan-results |
| 76 | + path: | |
| 77 | + mend-results.json |
| 78 | + mend-output.sarif |
| 79 | + retention-days: 30 |
| 80 | + |
| 81 | + - name: Fail on scan errors |
| 82 | + if: steps.mend_scan.outcome == 'failure' |
| 83 | + run: | |
| 84 | + echo "::error::Mend dependency scan found vulnerabilities or encountered errors." |
| 85 | + exit 1 |
0 commit comments