|
19 | 19 | - name: Login to Docker Hub |
20 | 20 | uses: docker/login-action@v3 |
21 | 21 | with: |
22 | | - username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 22 | + username: 'vxcontrol' |
23 | 23 | password: ${{ secrets.DOCKERHUB_TOKEN }} |
24 | 24 |
|
25 | 25 | - name: Extract metadata |
@@ -116,23 +116,37 @@ jobs: |
116 | 116 | runs-on: self-hosted |
117 | 117 |
|
118 | 118 | steps: |
119 | | - - name: Run Trivy vulnerability scanner |
120 | | - uses: aquasecurity/trivy-action@master |
121 | | - with: |
122 | | - image-ref: 'vxcontrol/kali-linux:latest' |
123 | | - format: 'sarif' |
124 | | - output: 'trivy-results.sarif' |
125 | | - # Optimize scanning for large images |
126 | | - scanners: 'vuln' |
127 | | - timeout: '60m' |
128 | | - # Skip problematic files |
129 | | - skip-files: '**/*.dll,**/*.exe,**/libstdc++-6.dll' |
130 | | - # Additional optimizations |
131 | | - severity: 'CRITICAL,HIGH' |
132 | | - skip-dirs: '/usr/lib/gcc,/usr/share/doc' |
133 | | - env: |
134 | | - # Stability improvements via environment variables |
135 | | - TRIVY_PARALLEL: '4' |
| 119 | + - name: Pull target image locally to avoid streaming issues |
| 120 | + run: | |
| 121 | + echo "Pre-pulling target image for stable scanning..." |
| 122 | + docker pull vxcontrol/kali-linux:latest |
| 123 | + echo "✅ Target image available locally" |
| 124 | + |
| 125 | + - name: Run Trivy vulnerability scanner via Docker (stable approach) |
| 126 | + run: | |
| 127 | + echo "Running Trivy scan using Docker with docker.sock access..." |
| 128 | + |
| 129 | + # Simplified approach without host cache mapping (ephemeral scan) |
| 130 | + docker run --rm \ |
| 131 | + -v /var/run/docker.sock:/var/run/docker.sock \ |
| 132 | + -v "$(pwd):$(pwd)" \ |
| 133 | + -w "$(pwd)" \ |
| 134 | + --memory=4g \ |
| 135 | + --memory-swap=8g \ |
| 136 | + -e TRIVY_PARALLEL=4 \ |
| 137 | + aquasec/trivy:0.63.0 \ |
| 138 | + image \ |
| 139 | + --format sarif \ |
| 140 | + --output trivy-results.sarif \ |
| 141 | + --scanners vuln \ |
| 142 | + --timeout 60m \ |
| 143 | + --severity CRITICAL,HIGH \ |
| 144 | + --skip-files '**/*.dll,**/*.exe,**/libstdc++-6.dll' \ |
| 145 | + --skip-dirs '/usr/lib/gcc,/usr/share/doc' \ |
| 146 | + --quiet \ |
| 147 | + vxcontrol/kali-linux:latest |
| 148 | + |
| 149 | + echo "✅ Trivy scan completed" |
136 | 150 | continue-on-error: true |
137 | 151 |
|
138 | 152 | - name: Verify SARIF file exists |
@@ -186,3 +200,11 @@ jobs: |
186 | 200 | echo "- 🔍 **Check logs** above for timeout or scanning errors" >> $GITHUB_STEP_SUMMARY |
187 | 201 | echo "- 💡 **Tip:** Large images may require scanning optimization" >> $GITHUB_STEP_SUMMARY |
188 | 202 | fi |
| 203 | +
|
| 204 | + - name: Cleanup local resources |
| 205 | + if: always() |
| 206 | + run: | |
| 207 | + echo "Cleaning up local resources..." |
| 208 | + docker rmi vxcontrol/kali-linux:latest 2>/dev/null || echo "Target image not found" |
| 209 | + docker rmi aquasec/trivy:0.63.0 2>/dev/null || echo "Trivy image not found" |
| 210 | + echo "✅ Cleanup completed" |
0 commit comments