|
| 1 | +name: DevSecOps Pipeline |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + secrets-scanning: |
| 12 | + name: Secrets Scanning |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Checkout code |
| 16 | + uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - name: TruffleHog OSS |
| 21 | + uses: trufflesecurity/trufflehog@v3.63.7 |
| 22 | + with: |
| 23 | + path: ./ |
| 24 | + base: ${{ github.event.repository.default_branch }} |
| 25 | + head: HEAD |
| 26 | + extra_args: --debug --only-verified |
| 27 | + |
| 28 | + sast-scanning: |
| 29 | + name: Static Application Security Testing |
| 30 | + runs-on: ubuntu-latest |
| 31 | + needs: secrets-scanning |
| 32 | + steps: |
| 33 | + - name: Checkout code |
| 34 | + uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Semgrep scan |
| 37 | + uses: semgrep/semgrep-action@v1 |
| 38 | + with: |
| 39 | + config: >- |
| 40 | + p/javascript |
| 41 | + p/angular |
| 42 | + p/nodejsscan |
| 43 | + ./xss/semgrep.yaml |
| 44 | + ./semgrep-custom-rules.yaml |
| 45 | + output: semgrep-results.sarif |
| 46 | + |
| 47 | + - name: Upload SARIF file |
| 48 | + uses: github/codeql-action/upload-sarif@v2 |
| 49 | + if: always() |
| 50 | + with: |
| 51 | + sarif_file: semgrep-results.sarif |
| 52 | + |
| 53 | + sca-scanning: |
| 54 | + name: Software Composition Analysis |
| 55 | + runs-on: ubuntu-latest |
| 56 | + needs: sast-scanning |
| 57 | + steps: |
| 58 | + - name: Checkout code |
| 59 | + uses: actions/checkout@v4 |
| 60 | + |
| 61 | + - name: OWASP Dependency-Check Scan - Backend |
| 62 | + uses: dependency-check/Dependency-Check_Action@main |
| 63 | + with: |
| 64 | + project: 'Angular-XSS-Backend' |
| 65 | + path: './xss/api' |
| 66 | + format: 'SARIF' |
| 67 | + out: './reports' |
| 68 | + args: >- |
| 69 | + --suppression ./dependency-check-suppressions.xml |
| 70 | + --scan-config ./dependency-check-config.json |
| 71 | + |
| 72 | + - name: OWASP Dependency-Check Scan - Frontend |
| 73 | + uses: dependency-check/Dependency-Check_Action@main |
| 74 | + with: |
| 75 | + project: 'Angular-XSS-Frontend' |
| 76 | + path: './xss/frontend' |
| 77 | + format: 'SARIF' |
| 78 | + out: './reports' |
| 79 | + args: >- |
| 80 | + --suppression ./dependency-check-suppressions.xml |
| 81 | + --scan-config ./dependency-check-config.json |
| 82 | + |
| 83 | + - name: Upload SARIF files |
| 84 | + uses: github/codeql-action/upload-sarif@v2 |
| 85 | + if: always() |
| 86 | + with: |
| 87 | + sarif_file: './reports/' |
| 88 | + |
| 89 | + sbom-generation: |
| 90 | + name: Software Bill of Materials |
| 91 | + runs-on: ubuntu-latest |
| 92 | + needs: sca-scanning |
| 93 | + steps: |
| 94 | + - name: Checkout code |
| 95 | + uses: actions/checkout@v4 |
| 96 | + |
| 97 | + - name: Generate SBOM with CycloneDX |
| 98 | + uses: CycloneDX/gh-node-module-generatebom@master |
| 99 | + with: |
| 100 | + path: './xss' |
| 101 | + output: './angular-xss-sbom.json' |
| 102 | + |
| 103 | + - name: Upload SBOM as artifact |
| 104 | + uses: actions/upload-artifact@v3 |
| 105 | + with: |
| 106 | + name: angular-xss-sbom |
| 107 | + path: './angular-xss-sbom.json' |
| 108 | + |
| 109 | + dast-scanning: |
| 110 | + name: Dynamic Application Security Testing |
| 111 | + runs-on: ubuntu-latest |
| 112 | + needs: sbom-generation |
| 113 | + steps: |
| 114 | + - name: Checkout code |
| 115 | + uses: actions/checkout@v4 |
| 116 | + |
| 117 | + - name: Start Angular XSS application with Docker Compose |
| 118 | + run: | |
| 119 | + cd ./xss |
| 120 | + docker-compose build |
| 121 | + docker-compose up -d |
| 122 | + # Wait for application to be ready |
| 123 | + sleep 60 |
| 124 | + |
| 125 | + - name: ZAP Baseline Scan |
| 126 | + uses: zaproxy/action-baseline@v0.11.0 |
| 127 | + with: |
| 128 | + target: 'http://localhost:4200' |
| 129 | + allow_issue_writing: true |
| 130 | + cmd_options: '-a -j -T 10' |
| 131 | + rules_file_name: './zap-rules.tsv' |
| 132 | + issue_title: 'ZAP Baseline Scan Report' |
| 133 | + markdown_report: true |
| 134 | + |
| 135 | + - name: ZAP Full Scan |
| 136 | + uses: zaproxy/action-full-scan@v0.8.0 |
| 137 | + with: |
| 138 | + target: 'http://localhost:4200' |
| 139 | + allow_issue_writing: true |
| 140 | + cmd_options: '-a -j -T 10' |
| 141 | + rules_file_name: './zap-rules.tsv' |
| 142 | + issue_title: 'ZAP Full Scan Report' |
| 143 | + markdown_report: true |
| 144 | + |
| 145 | + - name: Upload ZAP Report |
| 146 | + uses: actions/upload-artifact@v3 |
| 147 | + if: always() |
| 148 | + with: |
| 149 | + name: zap-reports |
| 150 | + path: | |
| 151 | + baseline-report.md |
| 152 | + full-scan-report.md |
| 153 | + |
| 154 | + - name: Stop Docker Containers |
| 155 | + if: always() |
| 156 | + run: | |
| 157 | + cd ./xss |
| 158 | + docker-compose down |
| 159 | + |
| 160 | + defectdojo-import: |
| 161 | + name: Import Results to DefectDojo |
| 162 | + runs-on: ubuntu-latest |
| 163 | + needs: [secrets-scanning, sast-scanning, sca-scanning, sbom-generation, dast-scanning] |
| 164 | + steps: |
| 165 | + - name: Checkout code |
| 166 | + uses: actions/checkout@v4 |
| 167 | + |
| 168 | + - name: Download all artifacts |
| 169 | + uses: actions/download-artifact@v3 |
| 170 | + with: |
| 171 | + path: ./artifacts |
| 172 | + |
| 173 | + - name: Import to DefectDojo |
| 174 | + run: | |
| 175 | + chmod +x ./defectdojo/import-results.sh |
| 176 | + ./defectdojo/import-results.sh ${{ secrets.DEFECTDOJO_URL }} ${{ secrets.DEFECTDOJO_API_KEY }} ${{ secrets.DEFECTDOJO_ENGAGEMENT_ID }} |
| 177 | + env: |
| 178 | + DEFECTDOJO_URL: ${{ secrets.DEFECTDOJO_URL }} |
| 179 | + DEFECTDOJO_API_KEY: ${{ secrets.DEFECTDOJO_API_KEY }} |
| 180 | + DEFECTDOJO_ENGAGEMENT_ID: ${{ secrets.DEFECTDOJO_ENGAGEMENT_ID }} |
0 commit comments