Skip to content

Commit be6294a

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

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

.github/workflows/advanced-security.yml

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
name: Security scans
1+
name: Advanced Security Scans
22

33
on:
4-
pull_request:
5-
types: [opened, synchronize, reopened]
64
push:
75
branches: [ main ]
6+
pull_request:
7+
types: [opened, synchronize, reopened]
88

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

1212
jobs:
1313
prepare:
@@ -48,7 +48,6 @@ jobs:
4848
if: needs.prepare.outputs.has-composer == 'true'
4949
steps:
5050
- uses: actions/checkout@v4
51-
5251
- name: Setup PHP for audit
5352
uses: shivammathur/setup-php@v4
5453
with:
@@ -58,17 +57,11 @@ jobs:
5857
run: composer --version || true
5958

6059
- name: Composer audit (Composer >= 2.4)
61-
id: compaudit
6260
run: |
63-
if composer --version | grep -q "Composer"; then
64-
composer audit --format=json > composer-audit.json || true
65-
echo "composer-audit=true" >> $GITHUB_OUTPUT || true
66-
else
67-
echo "composer-audit=false" >> $GITHUB_OUTPUT || true
68-
fi
61+
composer audit --format=json > composer-audit.json || true
6962
7063
- name: Upload composer audit
71-
if: always() && (exists('composer-audit.json') || true)
64+
if: always()
7265
uses: actions/upload-artifact@v4
7366
with:
7467
name: composer-audit
@@ -91,8 +84,6 @@ jobs:
9184
semgrep --version
9285
9386
- name: Run semgrep scan
94-
env:
95-
HOMEDIR: ${{ runner.temp }}
9687
run: |
9788
export PATH="$HOME/.local/bin:$PATH"
9889
semgrep --config p/php --json --output semgrep-report.json || true
@@ -131,12 +122,11 @@ jobs:
131122
run: |
132123
if [ -x vendor/bin/psalm ]; then
133124
vendor/bin/psalm --show-info=false --taint-analysis --report=psalm-security-report.xml || true
134-
ls -la psalm-security-report.xml || true
135125
else
136126
echo "psalm not found, skipping"
137127
fi
138128
139-
- name: Upload Psalm report (if exists)
129+
- name: Upload Psalm report
140130
if: always()
141131
uses: actions/upload-artifact@v4
142132
with:
@@ -163,18 +153,22 @@ jobs:
163153
name: DAST - OWASP ZAP baseline (staging only)
164154
runs-on: ubuntu-latest
165155
needs: prepare
166-
if: ${{ secrets.STAGING_URL != '' }}
167-
env:
168-
TARGET_URL: ${{ secrets.STAGING_URL }}
169156
steps:
157+
- name: Check for STAGING_URL
158+
run: |
159+
if [ -z "${{ secrets.STAGING_URL }}" ]; then
160+
echo "STAGING_URL secret not set, skipping ZAP"
161+
exit 0
162+
fi
170163
- name: Run ZAP baseline scan
164+
if: ${{ secrets.STAGING_URL }}
171165
uses: zaproxy/action-baseline@v1
172166
with:
173-
target: ${{ env.TARGET_URL }}
167+
target: ${{ secrets.STAGING_URL }}
174168
rules_file_name: zap-rules.md
175169
format: 'github'
176170
- name: Upload ZAP artifacts
177-
if: always()
171+
if: ${{ secrets.STAGING_URL }}
178172
uses: actions/upload-artifact@v4
179173
with:
180174
name: zap-output
@@ -191,10 +185,10 @@ jobs:
191185
token: ${{ secrets.GITHUB_TOKEN }}
192186

193187
summary:
194-
name: Summary (non-blocking)
188+
name: Summary
195189
runs-on: ubuntu-latest
196190
needs: [dependency-audit, semgrep, sast-php, secret-scan, dast-zap, dependency-review]
197191
steps:
198192
- name: Print summary message
199193
run: |
200-
echo "Security scan pipeline finished. Check artifacts (semgrep/psalm/composer/gitleaks/zap) and PR annotations for findings."
194+
echo "Advanced Security scan finished. Check artifacts (composer/semgrep/psalm/gitleaks/ZAP) and PR annotations."

0 commit comments

Comments
 (0)