Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fuzz/fuzz_runtime_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

def check(data: bytes) -> None:
for table in _INGEST_TABLES:
_repo.connection.execute(f"DELETE FROM {table}") # noqa: S608 -- fixed table names
_repo.connection.execute(f"DELETE FROM {table}") # fixed table names, not input
_repo.connection.commit()
lines = data.decode("utf-8", errors="replace").splitlines() # exactly as post_events decodes
lines = _with_app_env(lines, "fuzz-app", "fuzz-env")
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ packages = ["src/secfoo"]
[tool.pytest.ini_options]
testpaths = ["tests"]

[tool.ruff]
# Adversarial and fuzz fixtures are exact byte inputs, checked by SHA-256
# (scripts/adversarial_eval.py corpus_digest); lint must never rewrite them.
extend-exclude = ["tests/fixtures"]

[tool.ruff.lint.flake8-bugbear]
# typer.Option and FastAPI's Form are designed to be used as parameter
# defaults (they describe the parameter, they aren't shared mutable state),
Expand Down
2 changes: 1 addition & 1 deletion src/secfoo/agents/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from secfoo.agents.base import AgentAdapter, AgentResult
from secfoo.agents.registry import ADAPTERS, get_adapter

__all__ = ["AgentAdapter", "AgentResult", "ADAPTERS", "get_adapter"]
__all__ = ["ADAPTERS", "AgentAdapter", "AgentResult", "get_adapter"]
2 changes: 1 addition & 1 deletion src/secfoo/agents/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from secfoo.agents.api import ApiAdapter
from secfoo.agents.base import AgentAdapter
from secfoo.agents.claude import ClaudeAdapter
from secfoo.agents.copilot import CopilotAdapter
from secfoo.agents.codex import CodexAdapter
from secfoo.agents.copilot import CopilotAdapter
from secfoo.agents.cursor import CursorAdapter
from secfoo.agents.devin import DevinAdapter
from secfoo.agents.droid import DroidAdapter
Expand Down
110 changes: 55 additions & 55 deletions src/secfoo/cli.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/secfoo/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _request(url: str, *, api_key: str, payload: dict | None = None) -> dict:
headers["Content-Type"] = "application/json"
request = urllib.request.Request(url, data=data, headers=headers)
try:
with urllib.request.urlopen(request, timeout=REQUEST_TIMEOUT_SECONDS) as response: # noqa: S310 # nosec B310 -- user-configured portal URL, same trust as MCP settings
with urllib.request.urlopen(request, timeout=REQUEST_TIMEOUT_SECONDS) as response: # nosec B310 -- user-configured portal URL, same trust as MCP settings
return json.loads(response.read().decode("utf-8"))
except urllib.error.HTTPError as exc:
detail = exc.read().decode("utf-8", errors="replace")
Expand Down
2 changes: 1 addition & 1 deletion src/secfoo/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def _request(url: str, *, payload: dict | None = None, api_key: str | None = Non
headers["Content-Type"] = "application/json"
request = urllib.request.Request(url, data=data, headers=headers)
try:
with urllib.request.urlopen(request, timeout=REQUEST_TIMEOUT_SECONDS) as response: # noqa: S310 # nosec B310 -- user-configured memory URL, same trust as MCP settings
with urllib.request.urlopen(request, timeout=REQUEST_TIMEOUT_SECONDS) as response: # nosec B310 -- user-configured memory URL, same trust as MCP settings
return json.loads(response.read().decode("utf-8") or "{}")
except urllib.error.HTTPError as exc:
detail = exc.read().decode("utf-8", errors="replace")
Expand Down
2 changes: 1 addition & 1 deletion src/secfoo/osv.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def query_osv(ecosystem: str, package: str, version: str) -> list[dict]:
OSV_API_URL, data=body, headers={"Content-Type": "application/json"}, method="POST"
)
try:
with urllib.request.urlopen(request, timeout=REQUEST_TIMEOUT_SECONDS) as response: # noqa: S310 # nosec B310 -- hardcoded public OSV.dev API URL
with urllib.request.urlopen(request, timeout=REQUEST_TIMEOUT_SECONDS) as response: # nosec B310 -- hardcoded public OSV.dev API URL
data = json.loads(response.read().decode("utf-8"))
except urllib.error.HTTPError as exc:
detail = exc.read().decode("utf-8", errors="replace")
Expand Down
3 changes: 1 addition & 2 deletions src/secfoo/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ class RunOutcome:
def _project_display_name(resolved: ResolvedTarget) -> str:
if resolved.is_temporary:
cleaned = resolved.display_name.rstrip("/")
if cleaned.endswith(".git"):
cleaned = cleaned[: -len(".git")]
cleaned = cleaned.removesuffix(".git")
match = re.search(r"(?:https?://[^/]+/|git@[^:]+:)(.+)$", cleaned)
return match.group(1) if match else cleaned
return Path(resolved.display_name).name or resolved.display_name
Expand Down
2 changes: 1 addition & 1 deletion src/secfoo/skills/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
__all__ = [
"Skill",
"SkillLoadError",
"TargetContext",
"load_all_skills",
"load_skill",
"TargetContext",
"render_prompt",
]
2 changes: 1 addition & 1 deletion src/secfoo/targets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"ResolvedTarget",
"TargetKind",
"TargetResolutionError",
"clone_shallow",
"is_github_url",
"looks_like_url",
"resolve_target",
"clone_shallow",
]
6 changes: 5 additions & 1 deletion src/secfoo/web/architecture_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
extract_verdict_counts,
)
from secfoo.storage.repository import RunRepository
from secfoo.web.dashboard_common import append_boundary_changed_projects, percentile, read_report
from secfoo.web.dashboard_common import (
append_boundary_changed_projects,
percentile,
read_report,
)

SKILL_ID = "security-architecture-review"

Expand Down
10 changes: 6 additions & 4 deletions src/secfoo/web/routes/activities.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
from secfoo.skills.loader import SkillLoadError, load_skill
from secfoo.storage.repository import RunRepository
from secfoo.web import architecture_dashboard as arch_dashboard
from secfoo.web import finding_filters
from secfoo.web import sast_dashboard
from secfoo.web import sca_dashboard
from secfoo.web import secret_scanning_dashboard
from secfoo.web import (
finding_filters,
sast_dashboard,
sca_dashboard,
secret_scanning_dashboard,
)
from secfoo.web import threat_modeling_dashboard as tm_dashboard
from secfoo.web.templating import severity_rows, templates

Expand Down
15 changes: 7 additions & 8 deletions src/secfoo/web/routes/assessments.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import tempfile
import threading
from pathlib import Path
from typing import Optional
from urllib.parse import urlencode

from fastapi import APIRouter, Form, HTTPException, Request, UploadFile
Expand Down Expand Up @@ -167,12 +166,12 @@ def _list_query(**params: object) -> str:
@router.get("/assessments")
def assessments_list(
request: Request,
type: Optional[str] = None, # noqa: A002 -- matches the query param name
status: Optional[str] = None,
q: Optional[str] = None,
sort: Optional[str] = None,
updated: Optional[int] = None,
updated_to: Optional[str] = None,
type: str | None = None, # matches the query param name
status: str | None = None,
q: str | None = None,
sort: str | None = None,
updated: int | None = None,
updated_to: str | None = None,
):
"""Sorting happens in Python over the rows the page already shows
(list_assessments' most-recently-updated cap), which keeps the
Expand Down Expand Up @@ -211,7 +210,7 @@ def assessments_list(
def assessments_bulk_status(
ids: list[int] = Form(default_factory=list),
new_status: str = Form(...),
type: str = Form(""), # noqa: A002 -- the list's current filters, to return to the same view
type: str = Form(""), # the list's current filters, to return to the same view
status: str = Form(""),
q: str = Form(""),
sort: str = Form(""),
Expand Down
7 changes: 6 additions & 1 deletion src/secfoo/web/routes/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
from secfoo.config import STORE_DIR
from secfoo.report.markdown import render_report_html
from secfoo.storage.repository import RunRepository
from secfoo.web.run_status import ACTIVE_STATUSES, blocked_hint, elapsed_seconds, run_steps
from secfoo.web.run_status import (
ACTIVE_STATUSES,
blocked_hint,
elapsed_seconds,
run_steps,
)
from secfoo.web.templating import templates

router = APIRouter()
Expand Down
2 changes: 1 addition & 1 deletion src/secfoo/web/sast_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from collections import Counter
from dataclasses import dataclass, field

from secfoo.report.sast import SKILL_ID
from secfoo.report.sast import SKILL_ID # noqa: F401 -- re-exported: routes/activities.py uses sast_dashboard.SKILL_ID
from secfoo.storage.models import SastFindingRecord
from secfoo.storage.repository import RunRepository

Expand Down
6 changes: 5 additions & 1 deletion src/secfoo/web/third_party_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@

from dataclasses import dataclass, field

from secfoo.report.architecture import CCM_DOMAINS, conformance_to_score, extract_ccm_conformance
from secfoo.report.architecture import (
CCM_DOMAINS,
conformance_to_score,
extract_ccm_conformance,
)
from secfoo.storage.repository import RunRepository
from secfoo.web.dashboard_common import read_report

Expand Down
6 changes: 5 additions & 1 deletion src/secfoo/web/threat_modeling_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
extract_threat_register_rows,
)
from secfoo.storage.repository import RunRepository
from secfoo.web.dashboard_common import append_boundary_changed_projects, percentile, read_report
from secfoo.web.dashboard_common import (
append_boundary_changed_projects,
percentile,
read_report,
)

SKILL_ID = "threat-modeling"

Expand Down
3 changes: 2 additions & 1 deletion tests/test_cli_assessment.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

from secfoo.cli import app
from typer.testing import CliRunner

from secfoo.cli import app

runner = CliRunner()


Expand Down
3 changes: 2 additions & 1 deletion tests/test_responsible_ai_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@

import pytest
from fastapi.testclient import TestClient
from typer.testing import CliRunner

from secfoo.cli import app
from secfoo.storage.repository import RunRepository
from secfoo.web.app import create_app
from typer.testing import CliRunner

FIXTURE_DIR = Path(__file__).parent / "fixtures" / "reports"
SKILL_ID = "responsible-ai-compliance"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_web/test_activity_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_sidebar_marks_exactly_the_active_activity(client):

resp = client.get("/activities/sast")
# Links lead with an inline <svg> icon, so match through to </a>.
links = re.findall(r'<a class="sidebar__link".*?</a>', resp.text, re.S)
links = re.findall(r'<a class="sidebar__link".*?</a>', resp.text, re.DOTALL)
active = [re.sub(r"\s+", " ", link) for link in links if "aria-current" in link]
assert len(active) == 1, f"expected exactly one active link, got {active}"
assert 'href="/activities/sast"' in active[0]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_web/test_architecture_review_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def test_by_project_ends_with_each_projects_review_status(client, tmp_path):
assert header[-1] == "Review status"

def status_of(name: str) -> str:
row = re.search(rf"<tr[^>]*>(?:(?!</tr>).)*{re.escape(name)}(?:(?!</tr>).)*</tr>", table, re.S).group(0)
cells = re.findall(r"<td[^>]*>(.*?)</td>", row, re.S)
row = re.search(rf"<tr[^>]*>(?:(?!</tr>).)*{re.escape(name)}(?:(?!</tr>).)*</tr>", table, re.DOTALL).group(0)
cells = re.findall(r"<td[^>]*>(.*?)</td>", row, re.DOTALL)
return re.sub(r"<[^>]+>", "", cells[-1]).strip()

assert status_of("acme/current") == "Current"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_web/test_widget_info_tips.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _seed(tmp_path, project: str, depth: str) -> None:
def test_every_threat_modeling_widget_has_an_info_tip(client, tmp_path):
_seed(tmp_path, "acme/app", "Lightweight")
html = client.get("/activities/threat-modeling").text
tips = re.findall(r'<details class="info-tip[^"]*">.*?</details>', html, re.S)
tips = re.findall(r'<details class="info-tip[^"]*">.*?</details>', html, re.DOTALL)
titles = [re.search(r'<p class="info-tip__title">([^<]*)</p>', t).group(1) for t in tips]
# The activity page also shows the generic severity card under the
# program dashboard. Architecture, SAST, SCA, and secret scanning hide it.
Expand Down Expand Up @@ -119,7 +119,7 @@ def test_long_lists_scroll_after_ten_rows():


def _assert_titled_tips(page: str, expected: list[str]) -> None:
tips = re.findall(r'<details class="info-tip[^"]*">.*?</details>', page, re.S)
tips = re.findall(r'<details class="info-tip[^"]*">.*?</details>', page, re.DOTALL)
titles = [
html.unescape(re.search(r'<p class="info-tip__title">([^<]*)</p>', tip).group(1))
for tip in tips
Expand Down
Loading