Skip to content

Commit a1110d8

Browse files
authored
Refactor advanced security workflow for clarity
1 parent be6294a commit a1110d8

File tree

1 file changed

+29
-35
lines changed

1 file changed

+29
-35
lines changed

.github/workflows/advanced-security.yml

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ on:
77
types: [opened, synchronize, reopened]
88

99
env:
10-
PHP_VERSION: '8.0' # Adjust to 8.2 if you want
10+
PHP_VERSION: '8.0' # Adjust if you prefer 8.2 or 8.3
1111

1212
jobs:
1313
prepare:
14-
name: Prepare repo & PHP
14+
name: Prepare PHP & Repo
1515
runs-on: ubuntu-latest
1616
outputs:
1717
has-composer: ${{ steps.check.outputs.has_composer }}
@@ -24,7 +24,6 @@ jobs:
2424
with:
2525
php-version: ${{ env.PHP_VERSION }}
2626
extensions: mbstring, intl, pdo, pdo_mysql, ftp
27-
coverage: none
2827

2928
- name: Check for composer.json
3029
id: check
@@ -35,68 +34,63 @@ jobs:
3534
echo "has_composer=false" >> $GITHUB_OUTPUT
3635
fi
3736
38-
- name: Install composer deps (if composer.json)
37+
- name: Install composer deps
3938
if: steps.check.outputs.has_composer == 'true'
40-
run: |
41-
composer install --no-interaction --prefer-dist || true
42-
timeout-minutes: 20
39+
run: composer install --no-interaction --prefer-dist || true
4340

4441
dependency-audit:
45-
name: Composer / Dependency checks
42+
name: Composer Dependency Audit
4643
runs-on: ubuntu-latest
4744
needs: prepare
4845
if: needs.prepare.outputs.has-composer == 'true'
4946
steps:
5047
- uses: actions/checkout@v4
51-
- name: Setup PHP for audit
48+
49+
- name: Setup PHP
5250
uses: shivammathur/setup-php@v4
5351
with:
5452
php-version: ${{ env.PHP_VERSION }}
5553

56-
- name: Composer - show version
57-
run: composer --version || true
54+
- name: Composer audit
55+
run: composer audit --format=json > composer-audit.json || true
5856

59-
- name: Composer audit (Composer >= 2.4)
60-
run: |
61-
composer audit --format=json > composer-audit.json || true
62-
63-
- name: Upload composer audit
57+
- name: Upload composer audit report
6458
if: always()
6559
uses: actions/upload-artifact@v4
6660
with:
6761
name: composer-audit
6862
path: composer-audit.json
6963

70-
- name: Add Roave advisory (optional)
64+
- name: Add Roave security advisory
7165
run: composer require --dev roave/security-advisories:^1 || true
7266

7367
semgrep:
74-
name: Semgrep SAST
68+
name: Semgrep SAST Scan
7569
runs-on: ubuntu-latest
7670
needs: prepare
7771
steps:
7872
- uses: actions/checkout@v4
7973

80-
- name: Install semgrep
74+
- name: Install Semgrep
8175
run: |
8276
python3 -m pip install --user semgrep
8377
export PATH="$HOME/.local/bin:$PATH"
8478
semgrep --version
8579
86-
- name: Run semgrep scan
80+
- name: Run Semgrep scan
8781
run: |
8882
export PATH="$HOME/.local/bin:$PATH"
8983
semgrep --config p/php --json --output semgrep-report.json || true
9084
91-
- name: Upload semgrep report
85+
- name: Upload Semgrep report
9286
if: always()
9387
uses: actions/upload-artifact@v4
9488
with:
9589
name: semgrep-report
9690
path: semgrep-report.json
9791

9892
sast-php:
99-
name: Optional PHP SAST (PHPStan / Psalm)
93+
name: PHP SAST (PHPStan / Psalm)
10094
runs-on: ubuntu-latest
10195
needs: prepare
10296
if: needs.prepare.outputs.has-composer == 'true'
@@ -118,7 +112,7 @@ jobs:
118112
echo "phpstan not found, skipping"
119113
fi
120114
121-
- name: Run Psalm (taint) if present
115+
- name: Run Psalm if present
122116
run: |
123117
if [ -x vendor/bin/psalm ]; then
124118
vendor/bin/psalm --show-info=false --taint-analysis --report=psalm-security-report.xml || true
@@ -134,52 +128,52 @@ jobs:
134128
path: psalm-security-report.xml
135129

136130
secret-scan:
137-
name: Secret scanning (Gitleaks)
131+
name: Secret Scanning (Gitleaks)
138132
runs-on: ubuntu-latest
139133
steps:
140134
- uses: actions/checkout@v4
141-
- name: Run gitleaks
135+
- name: Run Gitleaks
142136
uses: zricethezav/gitleaks-action@v2
143137
with:
144138
args: detect --source . --report-format json --report-path gitleaks-report.json || true
145-
- name: Upload gitleaks report
139+
- name: Upload Gitleaks report
146140
if: always()
147141
uses: actions/upload-artifact@v4
148142
with:
149143
name: gitleaks-report
150144
path: gitleaks-report.json
151145

152146
dast-zap:
153-
name: DAST - OWASP ZAP baseline (staging only)
147+
name: DAST - OWASP ZAP baseline
154148
runs-on: ubuntu-latest
155149
needs: prepare
156150
steps:
157-
- name: Check for STAGING_URL
151+
- name: Check STAGING_URL secret
158152
run: |
159153
if [ -z "${{ secrets.STAGING_URL }}" ]; then
160-
echo "STAGING_URL secret not set, skipping ZAP"
154+
echo "STAGING_URL not set, skipping ZAP scan"
161155
exit 0
162156
fi
157+
163158
- name: Run ZAP baseline scan
164-
if: ${{ secrets.STAGING_URL }}
165159
uses: zaproxy/action-baseline@v1
166160
with:
167161
target: ${{ secrets.STAGING_URL }}
168162
rules_file_name: zap-rules.md
169163
format: 'github'
164+
170165
- name: Upload ZAP artifacts
171-
if: ${{ secrets.STAGING_URL }}
172166
uses: actions/upload-artifact@v4
173167
with:
174168
name: zap-output
175169
path: .
176170

177171
dependency-review:
178-
name: Dependency review (GitHub)
172+
name: GitHub Dependency Review
179173
runs-on: ubuntu-latest
180174
steps:
181175
- uses: actions/checkout@v4
182-
- name: Dependency review
176+
- name: Run Dependency Review
183177
uses: github/dependency-review-action@v2
184178
with:
185179
token: ${{ secrets.GITHUB_TOKEN }}
@@ -189,6 +183,6 @@ jobs:
189183
runs-on: ubuntu-latest
190184
needs: [dependency-audit, semgrep, sast-php, secret-scan, dast-zap, dependency-review]
191185
steps:
192-
- name: Print summary message
186+
- name: Print summary
193187
run: |
194-
echo "Advanced Security scan finished. Check artifacts (composer/semgrep/psalm/gitleaks/ZAP) and PR annotations."
188+
echo "Advanced Security Scans finished. Check artifacts (composer/semgrep/psalm/gitleaks/ZAP) and PR annotations."

0 commit comments

Comments
 (0)