Repository navigation
fix: remove broken --agent secfoo (fabricates reports, never reads target source) - #20
Merged
Merged
Conversation
AdithKB
marked this pull request as ready for review
September 30, 2026 10:22
…odel) src/secfoo/agents/secfoo.py was the original Initiative-2 draft (PR secfoo-com#10). PR secfoo-com#11 fixed the exact bug it has -- the agent never reads the target's files, so the model reviews nothing and fabricates a report -- but fixed it in a new, separate file (api.py) and never removed this one. Both have been registered and independently selectable via --agent ever since, with no indication either is broken. Reproduced twice against we45/Vulnerable-Flask-App (SAST and Secret Scanning): --agent secfoo returns "Confirmed" findings at file paths that don't exist anywhere in the target (app/db.py, app/upload.py, deploy/ci.yml), because build_graph's _State/run() never wires the resolved workdir into the model call at all -- collect_files() (the function that actually reads source) is never called from this file. The adapter's own test asserts this as correct behavior (messages == [{"role": "user", "content": "review this target"}]), so CI can't catch it. --agent api is the real, fixed implementation and needs no changes. This just removes the dead duplicate and its now-stale references: registry, AgentId enum, __init__ exports, its test, and two docs spots (README's duplicate "built-in LangGraph agent" section, and config.example.toml's three conflicting `agent =` example lines). Full suite: 700 passed (down from 702 -- exactly the 2 tests removed with the dead file). bandit clean on the touched agent files. Co-Authored-By: Claude Sonnet 5 <[email protected]>
AdithKB
force-pushed
the
fix/remove-broken-secfoo-agent
branch
from
October 3, 2026 10:36
5c4b68a to
0f31c52
Compare
Contributor
Author
|
Rebased onto current `main` — this was a silent merge collision with #21, not a bug in this branch. Both this PR and #21 independently cleaned up the same messy 3-duplicate-`agent=`-lines block in `config.example.toml`, different ways. Git's merge didn't see them as conflicting (non-overlapping line ranges), so it silently combined both survivors into two `agent =` keys in one TOML table — which `tomllib` rejects, breaking `secfoo config init` for everyone. That's what failed CI here. Resolved by taking #21's version of that file (already correct, already on main) and removing two more stale references to `--agent secfoo` that a later PR had added to the README in the meantime. Full suite (749 tests) passes on the rebased branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes SECFOO-32, Fixes SECFOO-33
Summary
--agent secfoo(src/secfoo/agents/secfoo.py, added in #10) never sends the target's source code to the model — it only sends the rendered skill prompt. The model has nothing to review, so it fabricates a plausible-looking report instead.#11fixed this exact bug ("the agent never sent the source code to the model... reports were generic or invented") — but fixed it in a separate new file,api.py, and never removed the original. Both have been registered and independently selectable via--agentsince #10/#11 merged, with nothing indicating either one is broken.secfoo.py's own test even asserts the broken behavior as correct (messages == [{"role": "user", "content": "review this target"}]), so CI can't catch it.Reproduction (twice, two skills, real API)
Target:
we45/Vulnerable-Flask-App(small, public, intentionally-vulnerable Flask app — the whole app is one file,app/app.py).secfoo run --skill sast --agent secfoo→ "Confirmed" findings atapp/db.py:42andapp/upload.py:20. Neither file exists in the repo.secfoo run --skill secret-scanning --agent secfoo→ a "Confirmed... Looks live" AWS key atdeploy/ci.yml:14, told to rotate immediately. Nodeploy/directory exists anywhere in the repo.--agent api→ real findings at real locations inapp/app.py(JWT bypass, SQL injection, unsafe YAML load, plaintext passwords, MD5 hashing), matching independent findings from other agents.Root cause
secfoo.py's_Statehas noworkdirfield, andrun()never uses theworkdirit's given —collect_files()(the function that reads real source, present inapi.py) is never called anywhere in this file. Confirmed viagit log --all -- src/secfoo/agents/secfoo.py: exactly one commit has ever touched it (the original from #10).What this PR does
Removes the dead, broken duplicate and its now-stale references:
src/secfoo/agents/secfoo.py,tests/test_agents/test_secfoo.py— deletedregistry.py,agents/__init__.py,cli.py'sAgentIdenum — drop theSecFooAdapter/secfooreferencestests/test_cli.py— drop"secfoo"from the agent-id listtest_agents_command_lists_all_adapterschecksREADME.md— removes a fully duplicate "built-in LangGraph agent" section documenting--agent secfooas if it were a distinct, working feature (it duplicated theapiagent docs directly above it)config.example.toml— collapses three conflictingagent = "claude"example lines (each listing a different, partially-stale set of valid agent ids) into one correct lineapiis the real, fixed implementation and needs no changes here.Test plan
pytest tests— 700 passed (702 before, minus exactly the 2 removed tests)secfoo agents—secfoono longer listedbandit -r src/secfoo/agents/api.py— cleangit log --allshows no other commit touching the deleted file, so nothing else depends on it--agent secfoois simply gone, not silently falling back to anythingKnown follow-ups (separate PRs, not blocking this one)
Found two smaller issues in
api.py(the implementation being kept) while investigating:collect_files()reads files withencoding="utf-8"and noerrors="replace", so a non-UTF-8 source file (e.g. legacy Windows-1252) raisesUnicodeDecodeErrorand is silently treated as binary and skipped — no warning, no mention in the report's Coverage Notes.--excludepaths are only mentioned in the rendered prompt text (an instruction to the model) —collect_files(workdir)takes no exclude parameter, so excluded files' full contents are still read and uploaded to the third-party LLM API regardless of--exclude.🤖 Generated with Claude Code