Skip to content

Commit 89a7e8c

Browse files
authored
fix: add bandit SAST + pip-audit to CI, fix assert in production code (#20)
fix: add bandit SAST + pip-audit to CI, fix assert in production code, upgrade 4 vulnerable deps. Closes #19, Refs devonartis/agentwrit#31
1 parent 4a3adb6 commit 89a7e8c

4 files changed

Lines changed: 588 additions & 61 deletions

File tree

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,28 @@ jobs:
113113
exit 1
114114
fi
115115
116+
sast:
117+
name: SAST (bandit)
118+
runs-on: ubuntu-latest
119+
steps:
120+
- uses: actions/checkout@v4
121+
- uses: astral-sh/setup-uv@v4
122+
with:
123+
version: "latest"
124+
- run: uv sync --all-extras
125+
- run: uv run bandit -r src/ -q
126+
127+
dep-audit:
128+
name: Dependency Audit (pip-audit)
129+
runs-on: ubuntu-latest
130+
steps:
131+
- uses: actions/checkout@v4
132+
- uses: astral-sh/setup-uv@v4
133+
with:
134+
version: "latest"
135+
- run: uv sync --all-extras
136+
- run: uv run pip-audit
137+
116138
secrets-scan:
117139
name: Secrets Scan
118140
runs-on: ubuntu-latest

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,6 @@ dev-dependencies = [
6464
"python-multipart>=0.0.24",
6565
"uvicorn>=0.44.0",
6666
"flask>=3.0.0",
67+
"bandit>=1.9.4",
68+
"pip-audit>=2.10.0",
6769
]

src/agentwrit/orchestrator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from typing import TYPE_CHECKING
1313

1414
from agentwrit.agent import Agent
15+
from agentwrit.errors import AgentWritError
1516

1617
if TYPE_CHECKING:
1718
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
@@ -80,7 +81,8 @@ def orchestrate(
8081
agent_name = label or f"{orch_id}/{task_id}"
8182

8283
# The app JWT is required as Bearer auth for launch token creation.
83-
assert self._app._session is not None
84+
if self._app._session is None:
85+
raise AgentWritError("App not authenticated — call authenticate() first")
8486
app_token = self._app._session.access_token
8587

8688
lt_response = self._transport.request(

0 commit comments

Comments
 (0)