Skip to content

Commit 6d9b328

Browse files
Fix CI lint failures from ruff
Thirteen ruff findings on the first CI run, all cosmetic: - F401 unused typing.Any imports in findings.py, blast_radius.py, reasoning.py - F401 unused POLICIES import in policy.py (POLICY_BY_ID is the surface used) - F401 unused get_rest_client import in seed_splunk.py - F541 four f-strings without placeholders (seed_splunk, test_injection, test_pipeline) - F841 unused local 'app' in seed_splunk's ensure_kv_collection - E402 module-level imports after load_dotenv in smoke_test_splunk.py — added noqa comments since the late import is intentional (env vars must load before splunklib reads them) Local `ruff check .` now reports "All checks passed". Pytest still green.
1 parent 9626fa1 commit 6d9b328

8 files changed

Lines changed: 9 additions & 13 deletions

File tree

agentgate/findings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from __future__ import annotations
99

1010
import json
11-
from typing import Any
1211

1312
from rich.console import Console
1413

agentgate/middleware/blast_radius.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from __future__ import annotations
88

99
import time
10-
from typing import Any
1110

1211
from ..graph import GraphArtifact, blast_radius
1312
from ..models import Severity, StageResult, ToolCall

agentgate/middleware/policy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from typing import Iterable
1313

1414
from ..models import Decision, Severity, StageResult, ToolCall
15-
from ..policies import POLICIES, POLICY_BY_ID, Policy
15+
from ..policies import POLICY_BY_ID, Policy
1616

1717
DESTRUCTIVE_SPL_RE = re.compile(
1818
r"(?:\|\s*delete\b|\bcrawl\b|outputlookup[^|]*append\s*=\s*false|"

agentgate/middleware/reasoning.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from __future__ import annotations
1111

1212
import time
13-
from typing import Any
1413

1514
from ollama import Client
1615

scripts/seed_splunk.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
REPO_ROOT = Path(__file__).resolve().parents[1]
2525
sys.path.insert(0, str(REPO_ROOT))
2626

27-
from agentgate.splunk_client import get_rest_client, get_service, rest # noqa: E402
27+
from agentgate.splunk_client import get_service, rest # noqa: E402
2828

2929
console = Console()
3030
fake = Faker()
@@ -172,7 +172,7 @@
172172
{"asset_id": "host:webfront01", "asset_type": "host", "compliance_tags": ["PCI"], "criticality": "high", "owner": "frontend"},
173173
{"asset_id": "user:svc_payment", "asset_type": "user", "compliance_tags": ["PCI"], "criticality": "high", "owner": "payments"},
174174
{"asset_id": "user:svc_hl7", "asset_type": "user", "compliance_tags": ["HIPAA"], "criticality": "high", "owner": "clinical"},
175-
{"asset_id": f"sourcetype:windows:security", "asset_type": "sourcetype", "compliance_tags": ["SOX", "PCI"], "criticality": "high", "owner": "soc"},
175+
{"asset_id": "sourcetype:windows:security", "asset_type": "sourcetype", "compliance_tags": ["SOX", "PCI"], "criticality": "high", "owner": "soc"},
176176
]
177177

178178

@@ -223,7 +223,6 @@ def upsert_saved_search(service: Any, spec: dict[str, Any]) -> None:
223223

224224

225225
def ensure_kv_collection(service: Any) -> None:
226-
app = service.apps[DEMO_APP] # search app for visibility
227226
collections = service.kvstore
228227
if KV_COLLECTION in collections:
229228
console.print(f" KV collection {KV_COLLECTION!r} already exists")
@@ -364,7 +363,7 @@ def main() -> int:
364363
if "\nAGENTGATE_HEC_TOKEN=\n" in (env_text + "\n") or env_text.rstrip().endswith("AGENTGATE_HEC_TOKEN="):
365364
env_text = env_text.replace("AGENTGATE_HEC_TOKEN=", f"AGENTGATE_HEC_TOKEN={audit_token}")
366365
env_path.write_text(env_text)
367-
console.print(f" [green]wrote AGENTGATE_HEC_TOKEN to .env[/green]")
366+
console.print(" [green]wrote AGENTGATE_HEC_TOKEN to .env[/green]")
368367

369368
console.print("\n[bold]3. Saved searches[/bold]")
370369
for spec in SAVED_SEARCHES:

scripts/smoke_test_splunk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
REPO_ROOT = Path(__file__).resolve().parents[1]
1313
load_dotenv(REPO_ROOT / ".env")
1414

15-
import splunklib.client as splunk_client
16-
import splunklib.results as splunk_results
15+
import splunklib.client as splunk_client # noqa: E402 (load_dotenv must run first)
16+
import splunklib.results as splunk_results # noqa: E402
1717

1818
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
1919

tests/test_injection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ def test_metrics_report() -> None:
7979
print(f"in-scope corpus: positives={len(POSITIVE)} negatives={len(NEGATIVE)}")
8080
print(f" TP={tp} FN={fn} TN={tn} FP={fp}")
8181
print(f" precision={precision:.3f} recall={recall:.3f} F1={f1:.3f} specificity={specificity:.3f}")
82-
print(f"out-of-scope corpus (INJECAGENT-style tool hijacking, not in heuristic threat model):")
82+
print("out-of-scope corpus (INJECAGENT-style tool hijacking, not in heuristic threat model):")
8383
print(f" total={len(OUT_OF_SCOPE)} intentionally-missed-by-heuristic={oos_missed}/{len(OUT_OF_SCOPE)}")
84-
print(f" -> routed to Foundation-Sec semantic stage in production pipeline")
84+
print(" -> routed to Foundation-Sec semantic stage in production pipeline")
8585
assert precision >= 0.85, f"precision too low: {precision}"
8686
assert recall >= 0.85, f"recall too low: {recall}"
8787
assert specificity >= 0.90, f"specificity too low: {specificity}"

tests/test_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def test_benign_corpus_zero_false_positives(pipeline: Pipeline) -> None:
7979
v = pipeline.evaluate(tc)
8080
if v.decision != Decision.ALLOW:
8181
bad.append((tc.arguments["query"], v.summary))
82-
assert not bad, f"benign calls wrongly gated:\n" + "\n".join(f" {q!r}: {s}" for q, s in bad)
82+
assert not bad, "benign calls wrongly gated:\n" + "\n".join(f" {q!r}: {s}" for q, s in bad)
8383

8484

8585
def test_friendly_fire_blocks(pipeline: Pipeline) -> None:

0 commit comments

Comments
 (0)