Skip to content

Commit fda4a54

Browse files
committed
Add security audits for Rust and Python dependencies; enhance scraper and workflow tests
1 parent 2c40ce1 commit fda4a54

File tree

6 files changed

+801
-30
lines changed

6 files changed

+801
-30
lines changed

.github/workflows/security.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Security Scanning
2+
3+
on:
4+
push:
5+
branches: [ main, dev ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
- cron: '0 0 * * 0' # Weekly on Sundays
10+
11+
permissions:
12+
contents: read
13+
security-events: write
14+
15+
jobs:
16+
semgrep:
17+
name: Semgrep Security Scan
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: returntocorp/semgrep-action@v1
23+
with:
24+
config: >-
25+
p/security-audit
26+
p/secrets
27+
p/owasp-top-ten
28+
p/python
29+
p/rust
30+
31+
dependency-review:
32+
name: Dependency Review
33+
runs-on: ubuntu-latest
34+
if: github.event_name == 'pull_request'
35+
steps:
36+
- uses: actions/checkout@v4
37+
- name: Dependency Review
38+
uses: actions/dependency-review-action@v4
39+
with:
40+
fail-on-severity: moderate
41+
42+
cargo-audit:
43+
name: Rust Security Audit
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- name: Setup Rust
49+
uses: dtolnay/rust-toolchain@stable
50+
51+
- name: Install cargo-audit
52+
run: cargo install cargo-audit
53+
54+
- name: Run cargo-audit
55+
run: cargo audit --deny warnings
56+
57+
pip-audit:
58+
name: Python Security Audit
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v4
62+
63+
- name: Set up Python
64+
uses: actions/setup-python@v5
65+
with:
66+
python-version: '3.12'
67+
68+
- name: Install uv
69+
run: |
70+
curl -LsSf https://astral.sh/uv/install.sh | sh
71+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
72+
73+
- name: Create virtual environment
74+
run: uv venv .venv
75+
76+
- name: Install dependencies
77+
run: |
78+
.venv/bin/uv pip install --upgrade pip
79+
.venv/bin/uv pip install -r requirements.txt
80+
.venv/bin/uv pip install pip-audit
81+
82+
- name: Run pip-audit
83+
run: .venv/bin/pip-audit --desc
84+
85+
bandit:
86+
name: Bandit Security Linting
87+
runs-on: ubuntu-latest
88+
steps:
89+
- uses: actions/checkout@v4
90+
91+
- name: Set up Python
92+
uses: actions/setup-python@v5
93+
with:
94+
python-version: '3.12'
95+
96+
- name: Install bandit
97+
run: pip install bandit[toml]
98+
99+
- name: Run bandit
100+
run: bandit -r RAGnificent/ -ll -f json -o bandit-report.json
101+
continue-on-error: true
102+
103+
- name: Upload bandit results
104+
uses: actions/upload-artifact@v4
105+
if: always()
106+
with:
107+
name: bandit-security-report
108+
path: bandit-report.json

.github/workflows/unified-ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ jobs:
3737

3838
- name: Run tests
3939
run: cargo test --verbose
40+
41+
- name: Security audit for Rust dependencies
42+
run: |
43+
cargo install cargo-audit --features=fix || true
44+
cargo audit
4045
4146
python-tests:
4247
name: Python ${{ matrix.python-version }} Tests
@@ -95,3 +100,13 @@ jobs:
95100
run: |
96101
.venv/bin/uv pip install build
97102
.venv/bin/python -m build
103+
104+
- name: Security scan with pip-audit
105+
run: |
106+
.venv/bin/uv pip install pip-audit
107+
.venv/bin/pip-audit
108+
109+
- name: Security scan with bandit
110+
run: |
111+
.venv/bin/uv pip install bandit[toml]
112+
.venv/bin/bandit -r RAGnificent/ -ll

RAGnificent/core/security.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def sanitize_headers(headers: Dict[str, str]) -> Dict[str, str]:
161161
return {}
162162

163163
# Build a mapping of lowercase -> original key to preserve original casing
164-
original_keys: Dict[str, str] = {k.lower(): k for k in headers.keys()}
164+
original_keys: Dict[str, str] = {k.lower(): k for k in headers}
165165

166166
sensitive_headers = {
167167
"authorization",

0 commit comments

Comments
 (0)