|
| 1 | +## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +## SPDX-License-Identifier: Apache-2.0 |
| 3 | +# Performs a daily scan of: |
| 4 | +# * The latest released ADOT Java image, using Trivy |
| 5 | +# * Project dependencies, using DependencyCheck |
| 6 | +# |
| 7 | +# Publishes results to CloudWatch Metrics. |
| 8 | +name: Daily scan |
1 | 9 |
|
2 |
| -name: Daily scan for dependencies |
3 | 10 | on:
|
4 | 11 | schedule:
|
5 |
| - - cron: "22 3 * * *" |
6 |
| - workflow_dispatch: |
| 12 | + - cron: '0 18 * * *' # scheduled to run at 18:00 UTC every day |
| 13 | + workflow_dispatch: # be able to run the workflow on demand |
| 14 | + |
| 15 | +env: |
| 16 | + AWS_DEFAULT_REGION: us-east-1 |
7 | 17 |
|
8 | 18 | permissions:
|
9 | 19 | id-token: write
|
10 | 20 | contents: read
|
11 | 21 |
|
12 | 22 | jobs:
|
13 |
| - check-dependencies-adot-java: |
| 23 | + scan_and_report: |
14 | 24 | runs-on: ubuntu-latest
|
15 | 25 | steps:
|
16 |
| - - uses: actions/checkout@v4 |
| 26 | + - name: Checkout repo for dependency scan |
| 27 | + uses: actions/checkout@v4 |
17 | 28 | with:
|
18 | 29 | fetch-depth: 0
|
19 |
| - - uses: actions/setup-java@v4 |
| 30 | + |
| 31 | + - name: Set up Java for dependency scan |
| 32 | + uses: actions/setup-java@v4 |
20 | 33 | with:
|
21 | 34 | java-version: 17
|
22 | 35 | distribution: 'temurin'
|
23 |
| - - name: Build snapshot with Gradle |
24 |
| - uses: gradle/gradle-build-action@v3 |
| 36 | + |
| 37 | + - name: Configure AWS credentials for dependency scan |
| 38 | + uses: aws-actions/configure-aws-credentials@v4 |
25 | 39 | with:
|
26 |
| - arguments: ":otelagent:dependencyCheckAnalyze" |
27 |
| - - name: Upload report |
28 |
| - if: ${{ always() }} |
29 |
| - uses: actions/upload-artifact@v3 |
| 40 | + role-to-assume: ${{ secrets.SECRET_MANAGER_ROLE_ARN }} |
| 41 | + aws-region: ${{ env.AWS_DEFAULT_REGION }} |
| 42 | + |
| 43 | + - name: Get NVD API key for dependency scan |
| 44 | + uses: aws-actions/aws-secretsmanager-get-secrets@v1 |
| 45 | + id: nvd_api_key |
30 | 46 | with:
|
31 |
| - name: adot-dependencies |
32 |
| - path: otelagent/build/reports |
| 47 | + secret-ids: ${{ secrets.NVD_API_KEY_SECRET_ARN }} |
| 48 | + parse-json-secrets: true |
33 | 49 |
|
34 |
| - check-dependencies-otel-java: |
35 |
| - runs-on: ubuntu-latest |
36 |
| - steps: |
37 |
| - - uses: actions/checkout@v4 |
| 50 | + - name: Publish patched dependencies to maven local |
| 51 | + uses: ./.github/actions/patch-dependencies |
| 52 | + |
| 53 | + - name: Build JAR |
| 54 | + uses: gradle/gradle-build-action@v3 |
38 | 55 | with:
|
39 |
| - repository: "open-telemetry/opentelemetry-java-instrumentation" |
40 |
| - fetch-depth: 0 |
41 |
| - - uses: actions/setup-java@v4 |
| 56 | + arguments: assemble -PlocalDocker=true |
| 57 | + |
| 58 | + # See http://jeremylong.github.io/DependencyCheck/dependency-check-cli/ for installation explanation |
| 59 | + - name: Install and run dependency scan |
| 60 | + id: dep_scan |
| 61 | + if: always() |
| 62 | + run: | |
| 63 | + gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 259A55407DD6C00299E6607EFFDE55BE73A2D1ED |
| 64 | + VERSION=$(curl -s https://jeremylong.github.io/DependencyCheck/current.txt) |
| 65 | + curl -Ls "https://github.com/jeremylong/DependencyCheck/releases/download/v$VERSION/dependency-check-$VERSION-release.zip" --output dependency-check.zip |
| 66 | + curl -Ls "https://github.com/jeremylong/DependencyCheck/releases/download/v$VERSION/dependency-check-$VERSION-release.zip.asc" --output dependency-check.zip.asc |
| 67 | + gpg --verify dependency-check.zip.asc |
| 68 | + unzip dependency-check.zip |
| 69 | + ./dependency-check/bin/dependency-check.sh --failOnCVSS 0 --nvdApiKey ${{ env.NVD_API_KEY_NVD_API_KEY }} -s 'otelagent/build/libs/aws-opentelemetry-agent-*-SNAPSHOT.jar' |
| 70 | +
|
| 71 | + - name: Print dependency scan results on failure |
| 72 | + if: ${{ steps.dep_scan.outcome != 'success' }} |
| 73 | + run: less dependency-check-report.html |
| 74 | + |
| 75 | + - name: Perform high image scan |
| 76 | + if: always() |
| 77 | + id: high_scan |
| 78 | + uses: ./.github/actions/image_scan |
42 | 79 | with:
|
43 |
| - java-version: 17 |
44 |
| - distribution: 'temurin' |
45 |
| - - name: Build snapshot with Gradle |
46 |
| - uses: gradle/gradle-build-action@v3 |
| 80 | + image-ref: "public.ecr.aws/aws-observability/adot-autoinstrumentation-java:v1.32.3" |
| 81 | + severity: 'CRITICAL,HIGH' |
| 82 | + |
| 83 | + - name: Perform low image scan |
| 84 | + if: always() |
| 85 | + id: low_scan |
| 86 | + uses: ./.github/actions/image_scan |
47 | 87 | with:
|
48 |
| - arguments: ":javaagent:dependencyCheckAnalyze" |
49 |
| - - name: Upload report |
50 |
| - if: ${{ always() }} |
51 |
| - uses: actions/upload-artifact@v3 |
| 88 | + image-ref: "public.ecr.aws/aws-observability/adot-autoinstrumentation-java:v1.32.3" |
| 89 | + severity: 'MEDIUM,LOW,UNKNOWN' |
| 90 | + |
| 91 | + - name: Configure AWS Credentials for emitting metrics |
| 92 | + if: always() |
| 93 | + uses: aws-actions/configure-aws-credentials@v4 |
52 | 94 | with:
|
53 |
| - name: otel-dependencies |
54 |
| - path: javaagent/build/reports |
55 |
| - |
56 |
| - publish-status: |
57 |
| - needs: ["check-dependencies-adot-java", "check-dependencies-otel-java"] |
58 |
| - if: ${{ always() }} |
59 |
| - uses: ./.github/workflows/publish-status.yml |
60 |
| - with: |
61 |
| - namespace: 'ADOT/GitHubActions' |
62 |
| - repository: ${{ github.repository }} |
63 |
| - branch: ${{ github.ref_name }} |
64 |
| - workflow: owasp |
65 |
| - success: ${{ needs.check-dependencies-adot-java.result == 'success' && |
66 |
| - needs.check-dependencies-otel-java.result == 'success'}} |
67 |
| - region: us-east-1 |
68 |
| - secrets: |
69 |
| - roleArn: ${{ secrets.METRICS_ROLE_ARN }} |
| 95 | + role-to-assume: ${{ secrets.METRICS_ROLE_ARN }} |
| 96 | + aws-region: ${{ env.AWS_DEFAULT_REGION }} |
| 97 | + |
| 98 | + - name: Publish high scan status |
| 99 | + if: always() |
| 100 | + run: | |
| 101 | + value="${{ steps.high_scan.outcome == 'success' && '1.0' || '0.0' }}" |
| 102 | + aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \ |
| 103 | + --metric-name Success \ |
| 104 | + --dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=daily_scan_high \ |
| 105 | + --value $value |
70 | 106 |
|
| 107 | + - name: Publish low scan status |
| 108 | + if: always() |
| 109 | + run: | |
| 110 | + value="${{ steps.low_scan.outcome == 'success' && steps.dep_scan.outcome == 'success' && '1.0' || '0.0'}}" |
| 111 | + aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \ |
| 112 | + --metric-name Success \ |
| 113 | + --dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=daily_scan_low \ |
| 114 | + --value $value |
0 commit comments