Skip to content

Commit c84aca0

Browse files
committed
fix: Resolve CI build and security scan issues
- Fix build dependency installation verification in build job - Fix bandit B324: Use usedforsecurity=False for MD5 cache keys - Fix bandit B608: Add nosec comments for parameterized SQL queries - Make bandit fail on high/medium severity issues (remove || true) - Bandit already runs on all branches, now properly enforced These SQL queries use parameterized placeholders (?) and are safe from SQL injection. MD5 is only used for cache key generation, not cryptographic security.
1 parent 131500c commit c84aca0

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ jobs:
113113
114114
- name: Run bandit security scan
115115
run: |
116-
bandit -r src/ -f json -o bandit-report.json || true
116+
bandit -r src/ -ll -f json -o bandit-report.json
117+
echo "Bandit scan completed. Check bandit-report.json for details."
117118
118119
- name: Run safety check
119120
run: |
@@ -143,7 +144,8 @@ jobs:
143144
- name: Install build dependencies
144145
run: |
145146
python -m pip install --upgrade pip
146-
pip install build twine
147+
pip install --upgrade build twine
148+
python -m pip list | grep -E "(build|twine)"
147149
148150
- name: Build package
149151
run: |

src/aletheia_probe/backends/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def _generate_cache_key(self, query_input: QueryInput) -> str:
269269
query_input.identifiers.get("doi", ""),
270270
]
271271
key_string = "|".join(key_parts)
272-
return hashlib.md5(key_string.encode()).hexdigest()
272+
return hashlib.md5(key_string.encode(), usedforsecurity=False).hexdigest() # nosec B324 - MD5 used for cache key, not security
273273

274274
async def query_with_timeout(
275275
self, query_input: QueryInput, timeout: int = 10

src/aletheia_probe/cache.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ def search_journals(
464464
if rows:
465465
journal_ids = [dict(row)["id"] for row in rows]
466466
placeholders = ",".join("?" * len(journal_ids))
467+
# nosec B608 - SQL uses parameterized placeholders, not string interpolation
467468
url_cursor = conn.execute(
468469
f"""
469470
SELECT journal_id, url FROM journal_urls

src/aletheia_probe/cache_sync.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ def _batch_write_journals(
182182
existing_journals = {}
183183
if normalized_names:
184184
placeholders = ",".join("?" * len(normalized_names))
185+
# nosec B608 - SQL uses parameterized placeholders, not string interpolation
185186
cursor.execute(
186187
f"SELECT id, normalized_name FROM journals WHERE normalized_name IN ({placeholders})",
187188
normalized_names,

0 commit comments

Comments
 (0)