Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 7290550

Browse files
chore: enhance security workflows and dependency management
1 parent 2c7549f commit 7290550

File tree

2 files changed

+62
-173
lines changed

2 files changed

+62
-173
lines changed

.github/workflows/dependency-updates.yml

Lines changed: 35 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -5,91 +5,53 @@ on:
55
- cron: '0 0 * * 1' # Run weekly on Monday
66
workflow_dispatch: # Allow manual trigger
77

8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
812
jobs:
9-
update-dependencies:
13+
dependency-update:
1014
runs-on: ubuntu-latest
11-
timeout-minutes: 30
12-
1315
steps:
14-
- name: Checkout repository
15-
uses: actions/checkout@v4
16-
with:
17-
fetch-depth: 0
18-
token: ${{ secrets.GITHUB_TOKEN }}
19-
20-
- name: Setup Node.js
21-
uses: actions/setup-node@v3
22-
with:
23-
node-version: 'lts/*'
24-
cache: 'npm'
16+
- uses: actions/checkout@v4
2517

26-
- name: Check for npm updates
27-
id: npm-check
18+
# Rust dependencies
19+
- name: Update Rust dependencies
2820
run: |
29-
npm install -g npm-check-updates
30-
ncu --upgrade
31-
if [[ $(git status --porcelain) ]]; then
32-
echo "updates_available=true" >> $GITHUB_OUTPUT
33-
fi
34-
35-
- name: Create Pull Request for npm
36-
if: steps.npm-check.outputs.updates_available == 'true'
37-
uses: peter-evans/create-pull-request@v5
38-
with:
39-
token: ${{ secrets.GITHUB_TOKEN }}
40-
commit-message: "chore(deps): Update npm dependencies"
41-
title: "chore(deps): Update npm dependencies"
42-
body: "Automated dependency updates"
43-
branch: "deps/npm-updates"
44-
labels: "dependencies,automated pr"
45-
46-
- name: Setup Python
47-
uses: actions/setup-python@v4
48-
with:
49-
python-version: '3.x'
50-
cache: 'pip'
21+
cargo install cargo-edit
22+
cargo upgrade --workspace
5123
52-
- name: Check for pip updates
53-
id: pip-check
24+
# NPM dependencies
25+
- name: Update NPM dependencies
5426
run: |
55-
pip install pip-review
56-
pip-review --auto
57-
if [[ $(git status --porcelain) ]]; then
58-
echo "updates_available=true" >> $GITHUB_OUTPUT
27+
if [ -f package.json ]; then
28+
npm update
29+
npm audit fix
5930
fi
6031
61-
- name: Create Pull Request for pip
62-
if: steps.pip-check.outputs.updates_available == 'true'
63-
uses: peter-evans/create-pull-request@v5
64-
with:
65-
token: ${{ secrets.GITHUB_TOKEN }}
66-
commit-message: "chore(deps): Update pip dependencies"
67-
title: "chore(deps): Update pip dependencies"
68-
body: "Automated dependency updates"
69-
branch: "deps/pip-updates"
70-
labels: "dependencies,automated pr"
71-
72-
- name: Setup Rust
73-
uses: actions-rs/toolchain@v1
74-
with:
75-
toolchain: stable
76-
profile: minimal
77-
78-
- name: Check for Cargo updates
79-
id: cargo-check
32+
# Python dependencies
33+
- name: Update Python dependencies
8034
run: |
81-
cargo update
82-
if [[ $(git status --porcelain) ]]; then
83-
echo "updates_available=true" >> $GITHUB_OUTPUT
35+
if [ -f requirements.txt ]; then
36+
pip install pip-tools
37+
pip-compile --upgrade requirements.in
8438
fi
8539
86-
- name: Create Pull Request for Cargo
87-
if: steps.cargo-check.outputs.updates_available == 'true'
40+
# Create Pull Request
41+
- name: Create Pull Request
8842
uses: peter-evans/create-pull-request@v5
8943
with:
9044
token: ${{ secrets.GITHUB_TOKEN }}
91-
commit-message: "chore(deps): Update Cargo dependencies"
92-
title: "chore(deps): Update Cargo dependencies"
93-
body: "Automated dependency updates"
94-
branch: "deps/cargo-updates"
95-
labels: "dependencies,automated pr"
45+
commit-message: "chore(deps): Update dependencies"
46+
title: "chore(deps): Update dependencies"
47+
body: |
48+
Automated dependency updates
49+
50+
This PR updates dependencies to their latest versions and includes security fixes.
51+
52+
Please review the changes carefully before merging.
53+
branch: "deps/update-dependencies"
54+
base: "main"
55+
labels: "dependencies,security"
56+
reviewers: "${{ github.repository_owner }}"
57+
delete-branch: true

.github/workflows/security-scan.yml

Lines changed: 27 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -26,118 +26,45 @@ jobs:
2626

2727
# CodeQL Analysis
2828
- name: Initialize CodeQL
29-
uses: github/codeql-action/init@v2
29+
uses: github/codeql-action/init@v3
3030
with:
3131
languages: python, javascript, rust
3232
queries: security-extended,security-and-quality
3333

3434
- name: Perform CodeQL Analysis
35-
uses: github/codeql-action/analyze@v2
35+
uses: github/codeql-action/analyze@v3
3636
with:
3737
category: "/language:python /language:javascript /language:rust"
3838

39-
# Dependency Scanning
40-
- name: Run Snyk to check for vulnerabilities
41-
uses: snyk/actions/node@master
42-
env:
43-
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
44-
with:
45-
args: --severity-threshold=high
39+
# Dependency Review
40+
- name: Dependency Review
41+
uses: actions/dependency-review-action@v3
42+
if: github.event_name == 'pull_request'
4643

47-
# Secret Scanning
48-
- name: TruffleHog OSS
49-
uses: trufflesecurity/trufflehog@main
44+
# Rust Security Audit
45+
- name: Run Rust Audit
46+
uses: actions-rs/audit-check@v1
5047
with:
51-
path: ./
52-
base: ${{ github.event.repository.default_branch }}
53-
head: HEAD
54-
extra_args: --debug --only-verified
48+
token: ${{ secrets.GITHUB_TOKEN }}
5549

56-
# Container Scanning
57-
- name: Run Trivy vulnerability scanner
58-
uses: aquasecurity/trivy-action@master
59-
with:
60-
scan-type: 'fs'
61-
scan-ref: '.'
62-
format: 'table'
63-
exit-code: '1'
64-
ignore-unfixed: true
65-
severity: 'CRITICAL,HIGH'
50+
# NPM Audit
51+
- name: Run npm audit
52+
run: |
53+
if [ -f package.json ]; then
54+
npm audit
55+
fi
6656
67-
# SAST
68-
- name: SonarCloud Scan
69-
uses: SonarSource/sonarcloud-github-action@master
70-
env:
71-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
57+
# Python dependency check
58+
- name: Run pip audit
59+
run: |
60+
if [ -f requirements.txt ]; then
61+
python -m pip install pip-audit
62+
pip-audit
63+
fi
7364
74-
# Security Report Generation
75-
- name: Generate Security Report
65+
# SARIF upload
66+
- name: Upload SARIF file
67+
uses: github/codeql-action/upload-sarif@v3
7668
if: always()
77-
uses: actions/github-script@v6
78-
with:
79-
script: |
80-
const fs = require('fs');
81-
82-
const report = `## Security Scan Report
83-
84-
### 🔍 Scan Summary
85-
- CodeQL Analysis: ${{ job.status }}
86-
- Dependency Scan: ${{ steps.snyk.outcome }}
87-
- Secret Scan: ${{ steps.trufflehog.outcome }}
88-
- Container Scan: ${{ steps.trivy.outcome }}
89-
- SAST Analysis: ${{ steps.sonarcloud.outcome }}
90-
91-
### 🚨 Critical Findings
92-
${fs.existsSync('trivy-results.json') ? require('./trivy-results.json').filter(f => f.Severity === 'CRITICAL').map(f => `- ${f.VulnerabilityID}: ${f.Title}`).join('\n') : 'No critical findings'}
93-
94-
### 📊 Metrics
95-
- Code Coverage: ${fs.existsSync('sonar-results.json') ? require('./sonar-results.json').coverage : 'N/A'}
96-
- Security Rating: ${fs.existsSync('sonar-results.json') ? require('./sonar-results.json').securityRating : 'N/A'}
97-
98-
### 🔐 Recommendations
99-
1. Review all critical and high severity findings
100-
2. Update vulnerable dependencies
101-
3. Address any identified secrets or credentials
102-
`;
103-
104-
// Create/update security report issue
105-
const { data: issues } = await github.rest.issues.listForRepo({
106-
owner: context.repo.owner,
107-
repo: context.repo.repo,
108-
labels: ['security-report'],
109-
state: 'open'
110-
});
111-
112-
if (issues.length > 0) {
113-
await github.rest.issues.update({
114-
owner: context.repo.owner,
115-
repo: context.repo.repo,
116-
issue_number: issues[0].number,
117-
body: report
118-
});
119-
} else {
120-
await github.rest.issues.create({
121-
owner: context.repo.owner,
122-
repo: context.repo.repo,
123-
title: 'Security Scan Report',
124-
body: report,
125-
labels: ['security-report']
126-
});
127-
}
128-
129-
# Notify on Critical Issues
130-
- name: Notify Security Team
131-
if: failure()
132-
uses: actions/github-script@v6
13369
with:
134-
script: |
135-
const message = `🚨 Critical security issues found in the latest scan!
136-
Please review the security report immediately.`;
137-
138-
await github.rest.issues.createComment({
139-
owner: context.repo.owner,
140-
repo: context.repo.repo,
141-
issue_number: context.issue.number,
142-
body: message
143-
});
70+
sarif_file: results.sarif

0 commit comments

Comments
 (0)