@@ -148,14 +148,16 @@ jobs:
148148 category : ' trivy-lrm-client-dependencies'
149149
150150 - name : Run Trivy vulnerability scanner - Dockerfile
151+ id : trivy-dockerfile
151152 uses : aquasecurity/trivy-action@0.24.0
152153 with :
153154 scan-type : ' config'
154155 scan-ref : ' web/lrm/client/Dockerfile'
155156 format : ' sarif'
156157 output : ' trivy-dockerfile.sarif'
157- severity : ' HIGH,CRITICAL'
158- exit-code : ' 0'
158+ severity : ' LOW,MEDIUM,HIGH,CRITICAL'
159+ exit-code : ' 1'
160+ scanners : ' config,secret'
159161 continue-on-error : true
160162
161163 - name : Fix Dockerfile SARIF file paths for GitHub Security tab
@@ -165,17 +167,78 @@ jobs:
165167 sarif-file : ' trivy-dockerfile.sarif'
166168 scan-path : ' web/lrm/client'
167169
168- - name : Check if dockerfile SARIF file exists
170+ - name : Debug Dockerfile scan and analyze results
169171 if : always()
170172 run : |
173+ echo "🐳 === Dockerfile Scan Debug Information ==="
174+ echo "Trivy Dockerfile scan outcome: ${{ steps.trivy-dockerfile.outcome }}"
175+ echo ""
176+
177+ # Check if Dockerfile exists
178+ if [ -f "web/lrm/client/Dockerfile" ]; then
179+ echo "✅ Dockerfile found at web/lrm/client/Dockerfile"
180+ echo "📄 Dockerfile size: $(du -h web/lrm/client/Dockerfile)"
181+ echo ""
182+ echo "🔍 Dockerfile content preview:"
183+ head -10 web/lrm/client/Dockerfile
184+ else
185+ echo "❌ Dockerfile not found at web/lrm/client/Dockerfile"
186+ fi
187+
188+ echo ""
189+ echo "📊 === SARIF File Analysis ==="
171190 if [ -f "trivy-dockerfile.sarif" ]; then
172- echo "✅ Dockerfile SARIF file found"
173- echo "File size: $(du -h trivy-dockerfile.sarif)"
174- echo "First few lines:"
175- head -10 trivy-dockerfile.sarif
191+ echo "✅ Dockerfile SARIF file generated"
192+ echo "📄 File size: $(du -h trivy-dockerfile.sarif)"
193+
194+ # Check if jq is available for better analysis
195+ if command -v jq > /dev/null 2>&1; then
196+ echo ""
197+ echo "🔍 SARIF Content Analysis:"
198+
199+ # Count total results
200+ TOTAL_RESULTS=$(jq '[.runs[]?.results[]?] | length' trivy-dockerfile.sarif 2>/dev/null || echo "0")
201+ echo " • Total issues found: $TOTAL_RESULTS"
202+
203+ # Count by severity
204+ HIGH_CRITICAL=$(jq '[.runs[]?.results[]? | select(.level == "error")] | length' trivy-dockerfile.sarif 2>/dev/null || echo "0")
205+ MEDIUM_LOW=$(jq '[.runs[]?.results[]? | select(.level == "warning" or .level == "info")] | length' trivy-dockerfile.sarif 2>/dev/null || echo "0")
206+ echo " • High/Critical issues: $HIGH_CRITICAL"
207+ echo " • Medium/Low issues: $MEDIUM_LOW"
208+
209+ if [ "$TOTAL_RESULTS" -gt 0 ]; then
210+ echo ""
211+ echo "🚨 Issues detected:"
212+ jq -r '.runs[]?.results[]? | " • " + (.ruleId // "Unknown") + ": " + .message.text' trivy-dockerfile.sarif 2>/dev/null | head -10
213+ else
214+ echo ""
215+ echo "ℹ️ No configuration issues detected in SARIF"
216+ fi
217+ else
218+ echo "ℹ️ jq not available for detailed analysis"
219+ echo ""
220+ echo "📄 Raw SARIF preview (first 20 lines):"
221+ head -20 trivy-dockerfile.sarif
222+ fi
176223 else
177224 echo "❌ Dockerfile SARIF file not found"
178225 fi
226+
227+ echo ""
228+ echo "🛠️ === Manual Trivy Test ==="
229+ echo "Running manual Trivy scan for comparison..."
230+
231+ # Install trivy if not available
232+ if ! command -v trivy > /dev/null 2>&1; then
233+ sudo apt-get update && sudo apt-get install -y wget apt-transport-https gnupg lsb-release
234+ wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
235+ echo "deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list.d/trivy.list
236+ sudo apt-get update && sudo apt-get install -y trivy
237+ fi
238+
239+ # Run manual config scan
240+ echo "Running: trivy config --format table --severity LOW,MEDIUM,HIGH,CRITICAL web/lrm/client/Dockerfile"
241+ trivy config --format table --severity LOW,MEDIUM,HIGH,CRITICAL web/lrm/client/Dockerfile || echo "Manual scan failed"
179242
180243 - name : Upload Trivy scan results to GitHub Security tab - Dockerfile
181244 if : always() && hashFiles('trivy-dockerfile.sarif') != ''
0 commit comments