|
196 | 196 | required: false |
197 | 197 | type: string |
198 | 198 | default: 'stable' |
| 199 | + grype-hab-path: |
| 200 | + description: "Path to built Habitat package (used if build_package is true, overrides hab_origin/hab_package inputs)" |
| 201 | + required: false |
| 202 | + type: string |
199 | 203 | grype-hab-scan-linux: |
200 | 204 | description: 'Scan Linux (x86_64-linux) Habitat package' |
201 | 205 | required: false |
@@ -895,20 +899,31 @@ jobs: |
895 | 899 | echo "level=none" >> $GITHUB_OUTPUT |
896 | 900 | fi |
897 | 901 |
|
| 902 | + - name: Install Grype and update database |
| 903 | + run: | |
| 904 | + curl -sSfL https://get.anchore.io/grype | sh -s -- -b /usr/local/bin |
| 905 | + grype db update |
| 906 | + grype version |
| 907 | + |
| 908 | + - name: Generate Artifact Name |
| 909 | + run: | |
| 910 | + TIMESTAMP=$(date +%Y%m%d-%H%M%S) |
| 911 | + ARTIFACT_NAME=$(echo "grype-scan-${{ github.event.repository.name }}-${TIMESTAMP}" | sed 's|/|-|g') |
| 912 | + echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV |
| 913 | +
|
898 | 914 | - name: Run Grype scan on repo |
899 | 915 | id: scan |
900 | | - uses: anchore/scan-action@v3 |
901 | | - with: |
902 | | - path: . |
903 | | - fail-build: true |
904 | | - severity-cutoff: ${{ steps.severity.outputs.level }} |
905 | | - output-format: json |
| 916 | + run: | |
| 917 | + # Run grype with only-fixed flag and output to JSON for analysis |
| 918 | + grype dir:. --only-fixed -o json > grype-scan.json |
| 919 | + grype dir:. --only-fixed --only-fixed --output table >> grype-scan.log || true |
| 920 | + echo "✅ Grype scan completed successfully" |
906 | 921 | |
907 | 922 |
|
908 | 923 | - name: Check Grype results and fail if vulnerabilities found |
909 | 924 | if: always() |
910 | 925 | run: | |
911 | | - JSON_FILE="./results.json" |
| 926 | + JSON_FILE="./grype-scan.json" |
912 | 927 | |
913 | 928 | if [ ! -f "$JSON_FILE" ] || [ -z "$JSON_FILE" ]; then |
914 | 929 | echo "⚠️ Grype JSON output not found" |
@@ -949,9 +964,10 @@ jobs: |
949 | 964 | if: always() |
950 | 965 | uses: actions/upload-artifact@v4 |
951 | 966 | with: |
952 | | - name: grype-results |
953 | | - path: ./results.json |
954 | | - retention-days: 30 |
| 967 | + name: ${{ env.ARTIFACT_NAME }} |
| 968 | + path: | |
| 969 | + grype-scan.json |
| 970 | + grype-scan.log |
955 | 971 |
|
956 | 972 | # - name: Run Grype scan on repo |
957 | 973 | # uses: anchore/scan-action@v3 |
@@ -984,6 +1000,7 @@ jobs: |
984 | 1000 | hab_version: ${{ inputs.grype-hab-version }} |
985 | 1001 | hab_release: ${{ inputs.grype-hab-release }} |
986 | 1002 | hab_channel: ${{ inputs.grype-hab-channel }} |
| 1003 | + hab_path: ${{ inputs.grype-hab-path }} |
987 | 1004 | scan-linux: ${{ inputs.grype-hab-scan-linux }} |
988 | 1005 | scan-windows: ${{ inputs.grype-hab-scan-windows }} |
989 | 1006 | scan-macos: ${{ inputs.grype-hab-scan-macos }} |
|
0 commit comments