Skip to content

Commit 9d6aa78

Browse files
authored
Merge pull request #154 from SpecterOps/BED-6803
chores: Add a step to scan AzureHound Build Image
2 parents 267ed0d + a1e8633 commit 9d6aa78

File tree

2 files changed

+88
-1
lines changed

2 files changed

+88
-1
lines changed

.github/workflows/build.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,95 @@ jobs:
6666
tags: |
6767
type=edge,branch=main
6868
type=sha,prefix=edge-,format=short
69+
70+
- name: Set up QEMU
71+
uses: docker/setup-qemu-action@v3
72+
73+
- name: Set up buildx
74+
uses: docker/setup-buildx-action@v3
6975

7076
- name: Build Container Image
77+
uses: docker/build-push-action@v6
78+
with:
79+
context: .
80+
build-args: VERSION=v0.0.0-rolling+${{ github.sha }}
81+
tags: azurehound # temporary tag to simplify oci conversion
82+
labels: ${{ steps.meta.outputs.labels }}
83+
push: false
84+
secrets: |
85+
GIT_AUTH_TOKEN=${{ secrets.PACKAGE_SCOPE }}
86+
# Multi-plaform builds can not be loaded into local Docker Daemon
87+
# Must use an Open Container Image to scan for vulnerabilities.
88+
outputs: type=oci,dest=/tmp/oci-image.tar
89+
90+
- name: Upload OCI tarball
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: oci-image-tar
94+
path: /tmp/oci-image.tar
95+
96+
# Convert OCI Directory to Docker-compatible tar for amd64
97+
- name: Convert OCI to Docker tarball
98+
run: |
99+
set -euo pipefail
100+
echo "Converting amd64 image..."
101+
102+
if ! skopeo copy \
103+
--override-arch=amd64 --override-os=linux \
104+
oci-archive:/tmp/oci-image.tar \
105+
docker-archive:/tmp/converted-amd64.tar; then
106+
echo "skopeo copy failed for amd64"
107+
exit 1
108+
fi
109+
110+
- name: Trivy scan for vulnerabilities (AMD64)
111+
id: trivy_amd64
112+
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # 0.33.1
113+
with:
114+
input: /tmp/converted-amd64.tar
115+
format: "json"
116+
severity: "HIGH,CRITICAL"
117+
ignore-unfixed: true
118+
cache-dir: /tmp/trivy-cache
119+
output: /tmp/trivy-report-amd64.json
120+
121+
- name: Upload Trivy scan reports
122+
uses: actions/upload-artifact@v4
123+
with:
124+
name: trivy-scan-reports
125+
path: /tmp/trivy-report-amd64.json
126+
127+
- name: Check Trivy Report for HIGH/CRITICAL vulnerabilities (amd64 only)
128+
env:
129+
GITHUB_EVENT_NAME: ${{ github.event_name }}
130+
run: |
131+
echo "Checking Trivy report for HIGH/CRITICAL vulnerabilities (amd64 only)..."
132+
133+
# Ensure report exists
134+
if [ ! -f /tmp/trivy-report-amd64.json ]; then
135+
echo "Error: /tmp/trivy-report-amd64.json not found!"
136+
exit 1
137+
fi
138+
139+
# Count vulnerabilities from amd64 report
140+
total_vulns=$(jq '[.Results[].Vulnerabilities[]? | select(.Severity=="HIGH" or .Severity=="CRITICAL")] | length' /tmp/trivy-report-amd64.json)
141+
142+
echo "Event: $GITHUB_EVENT_NAME"
143+
echo "Total HIGH/CRITICAL vulnerabilities: $total_vulns"
144+
145+
if [ "$total_vulns" -gt 0 ]; then
146+
# Fail only on push events
147+
if [ "$GITHUB_EVENT_NAME" = "push" ]; then
148+
echo "Push event detected. Failing the job to block image push."
149+
exit 1
150+
else
151+
echo "Pull request event. Vulnerabilities found, but continuing (non-blocking)."
152+
fi
153+
else
154+
echo "No HIGH/CRITICAL vulnerabilities found. Safe to proceed."
155+
fi
156+
157+
- name: Push Image
71158
uses: docker/build-push-action@v6
72159
with:
73160
context: .

.github/workflows/vuln-scan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
uses: actions/checkout@v3
1616

1717
- name: Run vulnerability scanner
18-
uses: aquasecurity/trivy-action@0.28.0
18+
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # 0.33.1
1919
with:
2020
scan-type: 'repo'
2121
scan-ref: './'

0 commit comments

Comments
 (0)