|
7 | 7 | workflow_dispatch: |
8 | 8 |
|
9 | 9 | jobs: |
10 | | - SAST_caller: |
11 | | - uses: eu-digital-identity-wallet/eudi-infra-ci/.github/workflows/sast_bt_testDebugUnitTestCoverage.yml@main |
12 | | - secrets: |
| 10 | + check-secrets: |
| 11 | + name: Check secrets presence |
| 12 | + env: |
13 | 13 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
14 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
15 | | - DOJO_TOKEN: ${{ secrets.DOJO_TOKEN }} |
16 | | - DOJO_URL: ${{ secrets.DOJO_URL }} |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - run: if [[ -z "$SONAR_TOKEN" ]]; then exit 1; fi |
| 17 | + |
| 18 | + analysis: |
| 19 | + name: Analysis |
| 20 | + needs: check-secrets |
| 21 | + env: |
| 22 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 23 | + DEFECT_DOJO_TOKEN: ${{ secrets.DOJO_TOKEN }} |
| 24 | + DEFECT_DOJO_URL: ${{ secrets.DOJO_URL }} |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - run: echo "ORGANIZATION=${{ github.repository_owner}}" >> $GITHUB_ENV |
| 28 | + - run: echo "PROJECT_KEY=${{ github.repository_owner}}_$(echo ${{ github.repository }} | sed 's/.*\///')" >> $GITHUB_ENV |
| 29 | + - run: echo "SCAN_DATE=$(TZ='EET' date '+%Y-%m-%d')" >> $GITHUB_ENV |
| 30 | + - uses: actions/checkout@v5 |
| 31 | + with: |
| 32 | + fetch-depth: 0 |
| 33 | + - uses: actions/setup-java@v5 |
| 34 | + with: |
| 35 | + distribution: temurin |
| 36 | + java-version: '17' |
| 37 | + - uses: gradle/actions/wrapper-validation@v5 |
| 38 | + - uses: gradle/actions/setup-gradle@v5 |
| 39 | + - run: ./gradlew clean test koverXmlReport |
| 40 | + - uses: sonarsource/[email protected] |
| 41 | + if: (github.event_name == 'push'|| github.event_name == 'workflow_dispatch') |
| 42 | + with: |
| 43 | + projectBaseDir: ${{ github.workspace }} |
| 44 | + args: > |
| 45 | + -Dsonar.organization=${{ env.ORGANIZATION }} |
| 46 | + -Dsonar.projectKey=${{ env.PROJECT_KEY }} |
| 47 | + -Dsonar.scanner.skipJreProvisioning=true |
| 48 | + -Dsonar.language=kotlin |
| 49 | + -Dsonar.coverage.jacoco.xmlReportPaths=document-manager/build/reports/kover/report.xml |
| 50 | + -Dsonar.kotlin.coverage.reportPaths=document-manager/build/reports/kover/report.xml |
| 51 | + -Dsonar.kotlin.multiplatform.reportPaths=document-manager/build/reports/kover/report.xml |
| 52 | + -Dsonar.sources=document-manager/src/main |
| 53 | + -Dsonar.tests=document-manager/src/test |
| 54 | + -Dsonar.java.binaries=document-manager/build/classes/kotlin/main |
| 55 | + -Dsonar.kotlin.binaries=document-manager/build/classes/kotlin/main |
| 56 | + - uses: sonarsource/[email protected] |
| 57 | + if: (github.event_name == 'pull_request_target') |
| 58 | + with: |
| 59 | + projectBaseDir: ${{ github.workspace }} |
| 60 | + args: > |
| 61 | + -Dsonar.organization=${{ env.ORGANIZATION }} |
| 62 | + -Dsonar.projectKey=${{ env.PROJECT_KEY }} |
| 63 | + -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} |
| 64 | + -Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }} |
| 65 | + -Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} |
| 66 | + -Dsonar.scanner.skipJreProvisioning=true |
| 67 | + -Dsonar.language=kotlin |
| 68 | + -Dsonar.coverage.jacoco.xmlReportPaths=document-manager/build/reports/kover/report.xml |
| 69 | + -Dsonar.kotlin.coverage.reportPaths=document-manager/build/reports/kover/report.xml |
| 70 | + -Dsonar.kotlin.multiplatform.reportPaths=document-manager/build/reports/kover/report.xml |
| 71 | + -Dsonar.sources=document-manager/src/main |
| 72 | + -Dsonar.tests=document-manager/src/test |
| 73 | + -Dsonar.java.binaries=document-manager/build/classes/kotlin/main |
| 74 | + -Dsonar.kotlin.binaries=document-manager/build/classes/kotlin/main |
| 75 | + - uses: actions/setup-node@v6 |
| 76 | + if: (github.repository_owner == 'eu-digital-identity-wallet' && github.ref_name == 'main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')) |
| 77 | + with: |
| 78 | + node-version: 18 |
| 79 | + - name: Publish Sonar Report |
| 80 | + if: (github.repository_owner == 'eu-digital-identity-wallet' && github.ref_name == 'main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')) |
| 81 | + run: | |
| 82 | + npm cache clean --force |
| 83 | + |
| 84 | + sonar-report \ |
| 85 | + --sonarurl="https://sonarcloud.io" \ |
| 86 | + --sonarorganization="${{ env.ORGANIZATION }}" \ |
| 87 | + --branch="${{ github.ref_name }}" \ |
| 88 | + --sonartoken="${{ secrets.SONAR_TOKEN }}" \ |
| 89 | + --output sonarreport.html \ |
| 90 | + --application="${{ env.PROJECT_KEY }}" \ |
| 91 | + --sonarcomponent="${{ env.PROJECT_KEY }}" |
| 92 | + curl -X POST "${{ env.DEFECT_DOJO_URL }}/api/v2/reimport-scan/" \ |
| 93 | + -H "Authorization: Token $DEFECT_DOJO_TOKEN" \ |
| 94 | + -F "active=true" \ |
| 95 | + -F "scan_type=SonarQube Scan detailed" \ |
| 96 | + -F "minimum_severity=Info" \ |
| 97 | + -F "skip_duplicates=true" \ |
| 98 | + -F "close_old_findings=true" \ |
| 99 | + |
| 100 | + -F "scan_date=${{ env.SCAN_DATE }}" \ |
| 101 | + -F "auto_create_context=True" \ |
| 102 | + -F "product_name=${{ github.repository }}-${{ github.ref_name }}" \ |
| 103 | + -F "engagement_name=Static Application Security Testing - ${{ github.repository }}-${{ github.ref_name }}" |
0 commit comments