|
8 | 8 |
|
9 | 9 | permissions: |
10 | 10 | contents: read |
11 | | - security-events: write |
12 | 11 | actions: read |
13 | 12 |
|
14 | 13 | jobs: |
15 | 14 | # ============================================================================ |
16 | | - # CodeQL Security Analysis |
| 15 | + # Bandit Python Security Scanner |
17 | 16 | # ============================================================================ |
18 | | - codeql: |
19 | | - name: CodeQL Analysis |
| 17 | + bandit: |
| 18 | + name: Bandit Security Scan |
20 | 19 | runs-on: ubuntu-latest |
21 | 20 |
|
22 | | - strategy: |
23 | | - fail-fast: false |
24 | | - matrix: |
25 | | - language: ['python', 'javascript'] |
26 | | - |
27 | 21 | steps: |
28 | 22 | - name: Checkout repository |
29 | 23 | uses: actions/checkout@v6 |
30 | 24 |
|
31 | | - - name: Initialize CodeQL |
32 | | - uses: github/codeql-action/init@v4 |
| 25 | + - name: Set up Python |
| 26 | + uses: actions/setup-python@v6 |
33 | 27 | with: |
34 | | - languages: ${{ matrix.language }} |
35 | | - queries: +security-extended,security-and-quality |
| 28 | + python-version: "3.12" |
| 29 | + |
| 30 | + - name: Install Bandit |
| 31 | + run: pip install bandit[toml] |
36 | 32 |
|
37 | | - - name: Autobuild |
38 | | - uses: github/codeql-action/autobuild@v4 |
| 33 | + - name: Run Bandit |
| 34 | + run: | |
| 35 | + bandit -r src/ -f json -o bandit-results.json || true |
| 36 | + bandit -r src/ -f txt -o bandit-results.txt || true |
39 | 37 |
|
40 | | - - name: Perform CodeQL Analysis |
41 | | - uses: github/codeql-action/analyze@v4 |
| 38 | + - name: Upload Bandit results |
| 39 | + uses: actions/upload-artifact@v4 |
42 | 40 | with: |
43 | | - category: "/language:${{matrix.language}}" |
44 | | - upload: true # Upload results to Security tab |
| 41 | + name: bandit-results |
| 42 | + path: | |
| 43 | + bandit-results.json |
| 44 | + bandit-results.txt |
45 | 45 |
|
46 | 46 | # ============================================================================ |
47 | | - # SonarCloud Quality Gate |
| 47 | + # Semgrep Security Scanner |
48 | 48 | # ============================================================================ |
49 | | - sonarcloud: |
50 | | - name: SonarCloud Analysis |
| 49 | + semgrep: |
| 50 | + name: Semgrep Security Scan |
51 | 51 | runs-on: ubuntu-latest |
52 | 52 |
|
53 | 53 | steps: |
54 | | - - uses: actions/checkout@v6 |
55 | | - with: |
56 | | - fetch-depth: 0 # Shallow clones disabled for better analysis |
| 54 | + - name: Checkout repository |
| 55 | + uses: actions/checkout@v6 |
57 | 56 |
|
58 | | - - name: Set up Python |
59 | | - uses: actions/setup-python@v6 |
| 57 | + - name: Run Semgrep |
| 58 | + uses: returntocorp/semgrep-action@v1 |
60 | 59 | with: |
61 | | - python-version: "3.12" |
62 | | - |
63 | | - - name: Install dependencies |
64 | | - run: | |
65 | | - python -m pip install --upgrade pip |
66 | | - pip install -e .[dev] |
67 | | -
|
68 | | - - name: Run tests with coverage |
69 | | - run: | |
70 | | - pytest \ |
71 | | - --cov=src/arbitrium \ |
72 | | - --cov-report=xml \ |
73 | | - --cov-branch \ |
74 | | - --junitxml=test-results.xml \ |
75 | | - -n auto |
76 | | -
|
77 | | - - name: SonarCloud Scan |
78 | | - uses: SonarSource/sonarqube-scan-action@v6 |
79 | | - env: |
80 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
81 | | - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 60 | + config: >- |
| 61 | + p/python |
| 62 | + p/javascript |
| 63 | + p/typescript |
| 64 | + p/security-audit |
| 65 | + generateSarif: false |
82 | 66 |
|
83 | 67 | # ============================================================================ |
84 | 68 | # Trivy Container Scanning |
@@ -110,12 +94,19 @@ jobs: |
110 | 94 | uses: aquasecurity/[email protected] |
111 | 95 | with: |
112 | 96 | image-ref: 'arbitrium-backend:scan' |
113 | | - format: 'sarif' |
114 | | - output: 'trivy-results.sarif' |
| 97 | + format: 'table' |
| 98 | + severity: 'CRITICAL,HIGH,MEDIUM' |
| 99 | + |
| 100 | + - name: Run Trivy (JSON output) |
| 101 | + uses: aquasecurity/[email protected] |
| 102 | + with: |
| 103 | + image-ref: 'arbitrium-backend:scan' |
| 104 | + format: 'json' |
| 105 | + output: 'trivy-results.json' |
115 | 106 | severity: 'CRITICAL,HIGH,MEDIUM' |
116 | 107 |
|
117 | | - - name: Upload Trivy results to GitHub Security |
118 | | - uses: github/codeql-action/upload-sarif@v4 |
| 108 | + - name: Upload Trivy results |
| 109 | + uses: actions/upload-artifact@v4 |
119 | 110 | with: |
120 | | - sarif_file: 'trivy-results.sarif' |
121 | | - category: 'container-security' |
| 111 | + name: trivy-results |
| 112 | + path: trivy-results.json |
0 commit comments