Skip to content

Commit a88bc97

Browse files
committed
feat(ci): add security-scan workflow to scan for vulnerabilities in dependencies for ATP playwright
Related issue: Netcracker/.github#211, Netcracker/.github#223
1 parent b97f31d commit a88bc97

1 file changed

Lines changed: 20 additions & 26 deletions

File tree

.github/workflows/security-scan.yml

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ on:
1616
required: false
1717
default: ""
1818
type: string
19+
tag:
20+
description: "Tag of the image to scan. By default 'latest'"
21+
required: false
22+
default: "latest"
23+
type: string
1924
only-high-critical:
2025
description: "Scope only HIGH + CRITICAL"
2126
required: false
@@ -50,51 +55,40 @@ jobs:
5055
permissions:
5156
packages: read
5257
outputs:
53-
ghcr-packages: ${{ steps.pkgs.outputs.ghcr-packages }}
58+
packages: ${{ steps.ghcr.outputs.packages }}
59+
has-packages: ${{ steps.ghcr.outputs.has-packages }}
5460
steps:
55-
- name: Show raw GHCR response
56-
id: pkgs
61+
- name: List GHCR packages for this repo
62+
id: ghcr
63+
uses: Netcracker/qubership-workflow-hub/actions/ghcr-discover-repo-packages@v2.0.3
5764
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")
65+
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
6866

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-
')
67+
- name: Print packages
68+
run: echo '${{ steps.ghcr.outputs.packages }}' | jq '.'
7569

76-
echo "ghcr-packages=$packages" >> "$GITHUB_OUTPUT"
77-
echo "Raw response:"
78-
echo "$packages"
70+
- name: Continue only if repo has GHCR packages
71+
if: ${{ steps.ghcr.outputs.has-packages == 'true' }}
72+
run: echo "Packages found!"
7973

8074
security-scan-matrix:
8175
needs: debug-packages
8276
if: ${{ inputs.image == '' || inputs.image == null }}
8377
strategy:
8478
matrix:
85-
package: ${{ fromJson(needs.debug-packages.outputs.ghcr-packages) }}
79+
package: ${{ fromJson(needs.debug-packages.outputs.packages) }}
8680

8781
name: "Run Security Scan (matrix)"
88-
uses: netcracker/qubership-workflow-hub/.github/workflows/re-security-scan.yml@main
82+
uses: netcracker/qubership-workflow-hub/.github/workflows/re-security-scan.yml@v2.0.3
8983
with:
9084
target: ${{ inputs.target || 'docker' }}
91-
image: ${{ format('{0}:main', matrix.package.path) }}
85+
image: ${{ format('{0}:{1}', matrix.package.path, inputs.tag || 'latest') }}
9286

9387
security-scan-single:
9488
needs: debug-packages
9589
if: ${{ inputs.image != '' && inputs.image != null }}
9690
name: "Run Security Scan (single image)"
97-
uses: netcracker/qubership-workflow-hub/.github/workflows/re-security-scan.yml@main
91+
uses: netcracker/qubership-workflow-hub/.github/workflows/re-security-scan.yml@v2.0.3
9892
with:
9993
target: ${{ inputs.target || 'docker' }}
10094
image: ${{ inputs.image }}

0 commit comments

Comments
 (0)