Skip to content

Commit 86fd5a3

Browse files
committed
feat(ci): add security-scan workflow to scan for vulnerabilities in dependencies for ATP playwright
Related issue: Netcracker/.github#211
1 parent 0aeb426 commit 86fd5a3

1 file changed

Lines changed: 67 additions & 25 deletions

File tree

Lines changed: 67 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1-
name: Security Scan
1+
name: Security Scan Docker Packages
2+
run-name: >
3+
Security Scan #${{ github.run_number }} for ${{ inputs.image != '' && inputs.image != null && inputs.image || 'all repository docker images' }}
24
on:
35
workflow_dispatch:
46
inputs:
57
target:
6-
description: "Scan part"
7-
required: true
8-
default: "docker"
8+
description: "Target type for the scan (docker, etc.)"
9+
required: false
910
type: choice
1011
options:
1112
- docker
1213
- source
1314
image:
14-
description: "Docker image (for 'docker' target). By default ghcr.io/<owner>/<repo>:latest"
15+
description: "Docker image (for docker). By default ghcr.io/<owner>/<repo>:latest"
1516
required: false
1617
default: ""
18+
type: string
1719
only-high-critical:
18-
description: "Scan only HIGH + CRITICAL"
20+
description: "Scope only HIGH + CRITICAL"
1921
required: false
2022
default: true
2123
type: boolean
2224
trivy-scan:
23-
description: "Run Trivy scan"
25+
description: "Trivy scan"
2426
required: false
2527
default: true
2628
type: boolean
2729
grype-scan:
28-
description: "Run Grype scan"
30+
description: "Grype scan"
2931
required: false
3032
default: true
3133
type: boolean
@@ -35,29 +37,69 @@ on:
3537
default: true
3638
type: boolean
3739
only-fixed:
38-
description: "Show only fixable vulnerabilities"
40+
description: "Ignore unfixed vulnerabilities"
3941
required: false
4042
default: true
4143
type: boolean
42-
4344
schedule:
4445
- cron: "0 3 * * 0" # every Sunday at 03:00 UTC
4546

46-
permissions:
47-
contents: read
48-
security-events: write
49-
actions: read
50-
packages: read
51-
5247
jobs:
53-
security-scan:
54-
name: "Run Security Scan"
48+
debug-packages:
49+
runs-on: ubuntu-latest
50+
permissions:
51+
packages: read
52+
outputs:
53+
ghcr-packages: ${{ steps.pkgs.outputs.ghcr-packages }}
54+
steps:
55+
- name: Show raw GHCR response
56+
id: pkgs
57+
env:
58+
GH_TOKEN: ${{ secrets.GH_PAT_PACKAGES }}
59+
OWNER: ${{ github.repository_owner }}
60+
run: |
61+
api_url="https://api.github.com/users/${OWNER}/packages?package_type=container"
62+
echo "Request: $api_url"
63+
64+
response=$(curl -sS \
65+
-H "Authorization: Bearer $GH_TOKEN" \
66+
-H "Accept: application/vnd.github+json" \
67+
"$api_url")
68+
69+
packages=$(echo "$response" | jq -c --arg owner "$OWNER" '
70+
[.[]
71+
| select(.repository.full_name == "nookyo/qubership-monitoring-operator")
72+
| { name: .name, repository: .repository.name, full_name: .repository.full_name, path: "ghcr.io/\($owner)/\(.name)" }
73+
]
74+
')
75+
76+
echo "ghcr-packages=$packages" >> "$GITHUB_OUTPUT"
77+
echo "Raw response:"
78+
echo "$packages"
79+
80+
security-scan-matrix:
81+
needs: debug-packages
82+
if: ${{ inputs.image == '' || inputs.image == null }}
83+
strategy:
84+
matrix:
85+
package: ${{ fromJson(needs.debug-packages.outputs.ghcr-packages) }}
86+
87+
name: "Run Security Scan (matrix)"
88+
uses: netcracker/qubership-workflow-hub/.github/workflows/re-security-scan.yml@main
89+
with:
90+
target: ${{ inputs.target || 'docker' }}
91+
image: ${{ format('{0}:main', matrix.package.path) }}
92+
93+
security-scan-single:
94+
needs: debug-packages
95+
if: ${{ inputs.image != '' && inputs.image != null }}
96+
name: "Run Security Scan (single image)"
5597
uses: netcracker/qubership-workflow-hub/.github/workflows/re-security-scan.yml@main
5698
with:
57-
target: ${{ github.event.inputs.target || 'docker' }}
58-
image: ${{ github.event.inputs.image || format('ghcr.io/{0}:latest', github.repository) }}
59-
only-high-critical: ${{ github.event.inputs.only-high-critical || true }}
60-
trivy-scan: ${{ github.event.inputs.trivy-scan || true }}
61-
grype-scan: ${{ github.event.inputs.grype-scan || true }}
62-
only-fixed: ${{ github.event.inputs.only-fixed || true }}
63-
continue-on-error: ${{ github.event.inputs.continue-on-error || true }}
99+
target: ${{ inputs.target || 'docker' }}
100+
image: ${{ inputs.image }}
101+
only-high-critical: ${{ inputs.only-high-critical || true }}
102+
trivy-scan: ${{ inputs.trivy-scan || true }}
103+
grype-scan: ${{ inputs.grype-scan || true }}
104+
only-fixed: ${{ inputs.only-fixed || true }}
105+
continue-on-error: ${{ inputs.continue-on-error || true }}

0 commit comments

Comments
 (0)