Skip to content

Commit ffa5162

Browse files
committed
DevSecOps test
1 parent 8391ffe commit ffa5162

2 files changed

Lines changed: 66 additions & 16 deletions

File tree

.github/workflows/devsecops-pipeline.yml

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ on:
77
branches: [ main ]
88
workflow_dispatch:
99

10-
# Required permissions for code scanning API
10+
# Required permissions for code scanning API and committing reports
1111
permissions:
1212
security-events: write
1313
actions: read
14-
contents: read
14+
contents: write # Upgraded from 'read' to 'write' to allow committing files
1515

1616
jobs:
1717
secrets-scanning:
@@ -31,13 +31,7 @@ jobs:
3131
uses: trufflesecurity/trufflehog@v3.63.7
3232
with:
3333
path: ./
34-
extra_args: --debug --json
35-
36-
# Generate TruffleHog report in docs/reports
37-
- name: Generate TruffleHog report
38-
run: |
39-
echo "Running TruffleHog scan manually to save report"
40-
docker run --rm -v $(pwd):/pwd trufflesecurity/trufflehog:latest github --repo file:///pwd --json > ./docs/reports/trufflehog-results.json || true
34+
extra_args: --debug --json
4135

4236
# Upload TruffleHog results as artifact
4337
- name: Upload TruffleHog results
@@ -411,6 +405,9 @@ jobs:
411405
steps:
412406
- name: Checkout code
413407
uses: actions/checkout@v4
408+
with:
409+
token: ${{ github.token }} # Use GitHub token for authentication
410+
fetch-depth: 0 # Full history for proper commits
414411

415412
- name: Download all artifacts
416413
uses: actions/download-artifact@v4
@@ -452,15 +449,43 @@ jobs:
452449
echo "Saved reports in docs/reports directory:"
453450
ls -la ./docs/reports/
454451
455-
# Option to commit the reports directly to the repository
456-
- name: Create local commit with reports (optional)
457-
if: github.event_name == 'workflow_dispatch'
452+
# Commit and push the reports to the repository
453+
- name: Commit and push reports to the repository
458454
run: |
459-
git config --local user.email "action@github.com"
460-
git config --local user.name "GitHub Action"
455+
# Configure git
456+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
457+
git config --local user.name "github-actions[bot]"
458+
459+
# Check for changes in remote and pull if needed
460+
echo "Checking for updates from remote..."
461+
git pull origin ${GITHUB_REF_NAME} --no-rebase || echo "Failed to pull, proceeding anyway"
462+
463+
# Ensure docs/reports directory exists
464+
mkdir -p ./docs/reports/
465+
466+
# Stage the changes
467+
echo "Adding report files to git..."
461468
git add ./docs/reports/
462-
git commit -m "Add scan reports [skip ci]" || echo "No changes to commit"
463-
echo "Reports committed to the repository. Use git push to push these changes."
469+
470+
# Verify changes were staged
471+
git status
472+
473+
# Check if there are changes to commit
474+
if git diff --staged --quiet; then
475+
echo "No changes to commit"
476+
else
477+
# Commit the changes
478+
echo "Committing report files..."
479+
git commit -m "Add security scan reports [skip ci]"
480+
481+
# Push to the repository
482+
echo "Pushing changes to the repository..."
483+
git push origin ${GITHUB_REF_NAME}
484+
485+
echo "Reports have been committed and pushed to the repository."
486+
echo "View them at: https://github.com/${GITHUB_REPOSITORY}/tree/${GITHUB_REF_NAME}/docs/reports"
487+
fi
488+
continue-on-error: true # Continue workflow even if push fails
464489

465490
defectdojo-import:
466491
name: Import Results to DefectDojo

docs/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# DevSecOps Documentation and Reports
2+
3+
This directory contains documentation and security scan reports for the Angular XSS DevSecOps project.
4+
5+
## Directory Structure
6+
7+
- **`reports/`** - Contains all security scan reports generated by the DevSecOps pipeline
8+
- TruffleHog secrets scanning results
9+
- CodeQL SAST scan results
10+
- OWASP Dependency-Check SCA results
11+
- CycloneDX SBOM
12+
- OWASP ZAP DAST scan reports
13+
- A comprehensive README.md indexing all reports
14+
15+
- **`setup-secrets.md`** - Instructions for setting up required secrets for DefectDojo integration
16+
- **`devsecops-summary.md`** - Overview of the DevSecOps implementation
17+
- **`usage-guide.md`** - Detailed guide on using the DevSecOps pipeline
18+
19+
## Reports Access
20+
21+
The `reports/` directory is automatically populated by the GitHub Actions workflow with the latest scan results after each pipeline run. You can access these reports directly from the GitHub repository at:
22+
23+
[https://github.com/Taofeeqib/angular-xss/tree/main/docs/reports](https://github.com/Taofeeqib/angular-xss/tree/main/docs/reports)
24+
25+
For more information about the reports and how to interpret them, see the README.md file within the reports directory.

0 commit comments

Comments
 (0)