|
| 1 | +# Example workflow for using MobScan from a PRIVATE repository |
| 2 | +# Rename this file to main.yml if you want to use this approach |
| 3 | + |
| 4 | +name: MobScan Security Check (Private Repo) |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: [main, master] |
| 9 | + pull_request: |
| 10 | + |
| 11 | +env: |
| 12 | + # Set scan profile: 'baseline' for standard apps, 'financial' for banking/payment apps |
| 13 | + SCAN_PROFILE: baseline |
| 14 | + |
| 15 | +jobs: |
| 16 | + security-scan: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + security-events: write |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout code |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Set up Python |
| 28 | + uses: actions/setup-python@v4 |
| 29 | + with: |
| 30 | + python-version: '3.9' |
| 31 | + |
| 32 | + - name: Install MobScan from Private Repo |
| 33 | + run: | |
| 34 | + pip install semgrep |
| 35 | + # Install from private GitHub repo using Personal Access Token |
| 36 | + pip install git+https://${{ secrets.GH_PAT }}@github.com/XavLimSG/MobScan.git |
| 37 | + env: |
| 38 | + GH_PAT: ${{ secrets.GH_PAT }} |
| 39 | + |
| 40 | + - name: List available profiles |
| 41 | + run: | |
| 42 | + mobscan profiles |
| 43 | + |
| 44 | + - name: Run MobScan with Compliance Mapping |
| 45 | + run: | |
| 46 | + mobscan scan . \ |
| 47 | + --profile ${{ env.SCAN_PROFILE }} \ |
| 48 | + --format sarif \ |
| 49 | + --output mobscan.sarif \ |
| 50 | + --show-compliance |
| 51 | + continue-on-error: true |
| 52 | + |
| 53 | + - name: Generate Compliance Report |
| 54 | + run: | |
| 55 | + mobscan compliance-report . \ |
| 56 | + --profile ${{ env.SCAN_PROFILE }} \ |
| 57 | + --output compliance-report.txt |
| 58 | + continue-on-error: true |
| 59 | + |
| 60 | + - name: Generate JSON Report with Compliance |
| 61 | + run: | |
| 62 | + mobscan scan . \ |
| 63 | + --profile ${{ env.SCAN_PROFILE }} \ |
| 64 | + --format json \ |
| 65 | + --output mobscan-compliance.json |
| 66 | + continue-on-error: true |
| 67 | + |
| 68 | + - name: Upload SARIF to GitHub Security |
| 69 | + uses: github/codeql-action/upload-sarif@v3 |
| 70 | + if: always() |
| 71 | + with: |
| 72 | + sarif_file: mobscan.sarif |
| 73 | + |
| 74 | + - name: Upload Compliance Reports as Artifacts |
| 75 | + uses: actions/upload-artifact@v4 |
| 76 | + if: always() |
| 77 | + with: |
| 78 | + name: compliance-reports |
| 79 | + path: | |
| 80 | + compliance-report.txt |
| 81 | + mobscan-compliance.json |
| 82 | + mobscan.sarif |
| 83 | + retention-days: 90 |
| 84 | + |
| 85 | + - name: Display Compliance Summary |
| 86 | + if: always() |
| 87 | + run: | |
| 88 | + echo "===================================================================" |
| 89 | + echo "COMPLIANCE SCAN SUMMARY" |
| 90 | + echo "===================================================================" |
| 91 | + echo "Profile: ${{ env.SCAN_PROFILE }}" |
| 92 | + if [ "${{ env.SCAN_PROFILE }}" == "baseline" ]; then |
| 93 | + echo "Standards: CSA SAS 2.0, OWASP MASVS 2.1" |
| 94 | + else |
| 95 | + echo "Standards: CSA SAS 2.0, OWASP MASVS 2.1, MAS TRM" |
| 96 | + fi |
| 97 | + echo "" |
| 98 | + cat compliance-report.txt || echo "No compliance report generated" |
| 99 | + echo "===================================================================" |
| 100 | + |
| 101 | + - name: Fail on security threshold |
| 102 | + run: | |
| 103 | + # Baseline profile: fail on high severity |
| 104 | + # Financial profile: fail on medium severity |
| 105 | + if [ "${{ env.SCAN_PROFILE }}" == "financial" ]; then |
| 106 | + mobscan scan . --profile financial --fail-on medium |
| 107 | + else |
| 108 | + mobscan scan . --profile baseline |
| 109 | + fi |
0 commit comments