|
| 1 | +name: Run OWASP Maven Dependency Check |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + inputs: |
| 5 | + runner-os: |
| 6 | + description: 'The OS to run the check on.' |
| 7 | + default: 'ubuntu-latest' |
| 8 | + required: false |
| 9 | + type: string |
| 10 | + java-distribution: |
| 11 | + description: 'The java distribution to run the check with.' |
| 12 | + default: 'temurin' |
| 13 | + required: false |
| 14 | + type: string |
| 15 | + java-version: |
| 16 | + description: 'The java version to run the check with.' |
| 17 | + default: 21 |
| 18 | + required: false |
| 19 | + type: number |
| 20 | + check-command: |
| 21 | + description: 'The command used to generate the report.' |
| 22 | + default: 'mvn -B validate -Pdependency-check' |
| 23 | + required: false |
| 24 | + type: string |
| 25 | + secrets: |
| 26 | + nvd-api-key: |
| 27 | + description: 'The NVD API Key used to fetch the NVD database.' |
| 28 | + required: true |
| 29 | + slack-webhook-url: |
| 30 | + description: 'The Slack webhook used for publishing the results.' |
| 31 | + required: true |
| 32 | + |
| 33 | + |
| 34 | +jobs: |
| 35 | + check-dependencies: |
| 36 | + name: Check dependencies |
| 37 | + runs-on: ${{ inputs.runner-os }} |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v4 |
| 40 | + with: |
| 41 | + show-progress: false |
| 42 | + - name: Setup Java |
| 43 | + uses: actions/setup-java@v4 |
| 44 | + with: |
| 45 | + distribution: ${{ inputs.java-distribution }} |
| 46 | + java-version: ${{ inputs.java-version }} |
| 47 | + cache: 'maven' |
| 48 | + - name: Cache NVD DB |
| 49 | + uses: actions/cache@v3 |
| 50 | + with: |
| 51 | + path: ~/.m2/repository/org/owasp/dependency-check-data/ |
| 52 | + key: dependency-check-${{ github.run_id }} |
| 53 | + restore-keys: | |
| 54 | + dependency-check |
| 55 | + env: |
| 56 | + SEGMENT_DOWNLOAD_TIMEOUT_MINS: 5 |
| 57 | + - name: Run org.owasp:dependency-check plugin |
| 58 | + id: dependency-check |
| 59 | + continue-on-error: true |
| 60 | + run: ${{ inputs.check-command }} |
| 61 | + env: |
| 62 | + NVD_API_KEY: ${{ secrets.nvd-api-key }} |
| 63 | + - name: Upload report on failure |
| 64 | + if: steps.dependency-check.outcome == 'failure' |
| 65 | + uses: actions/upload-artifact@v4 |
| 66 | + with: |
| 67 | + name: dependency-check-report |
| 68 | + path: target/dependency-check-report.html |
| 69 | + if-no-files-found: error |
| 70 | + - name: Slack Notification on regular check |
| 71 | + if: github.event_name == 'schedule' && steps.dependency-check.outcome == 'failure' |
| 72 | + uses: rtCamp/action-slack-notify@v2 |
| 73 | + env: |
| 74 | + SLACK_WEBHOOK: ${{ secrets.slack-webhook-url }} |
| 75 | + SLACK_USERNAME: 'Cryptobot' |
| 76 | + SLACK_ICON: false |
| 77 | + SLACK_ICON_EMOJI: ':bot:' |
| 78 | + SLACK_CHANNEL: 'cryptomator-desktop' |
| 79 | + SLACK_TITLE: "Vulnerabilities in ${{ github.event.repository.name }} detected." |
| 80 | + SLACK_MESSAGE: "Download the <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|report> for more details." |
| 81 | + SLACK_FOOTER: false |
| 82 | + MSG_MINIMAL: true |
| 83 | + - name: Failing workflow on release branch |
| 84 | + if: github.event_name == 'push' && steps.dependency-check.outcome == 'failure' |
| 85 | + shell: bash |
| 86 | + run: exit 1 |
0 commit comments