Skip to content

test(tools): comprehensive test suite for search_for_exploits module (+53 tests) - #181

Open
manus-use wants to merge 1 commit into
mainfrom
test/search-for-exploits-suite
Open

test(tools): comprehensive test suite for search_for_exploits module (+53 tests)#181
manus-use wants to merge 1 commit into
mainfrom
test/search-for-exploits-suite

Conversation

@manus-use

Copy link
Copy Markdown
Owner

Summary

Adds a comprehensive test suite for the search_for_exploits module (src/manus_agent/tools/search_for_exploits.py) — 53 fully-mocked tests covering all code paths in this security-critical GitHub PoC search tool.

What's tested

Category Tests Coverage
TOOL_SPEC contract 5 Name, description, inputSchema structure, required fields, types
Input validation 7 None, empty string, numeric, missing CVE- prefix, random string, missing key, toolUseId preservation
Successful search 7 Results returned, summary includes count, top-5 limiting, result field structure, case variants, single result
Zero results 3 Success status, CVE mentioned in summary, empty links list
Token handling 5 Env var injection, config fallback, no-token path, env priority over config, config exception fallback
HTTP errors 5 Timeout, connection error, 403 rate limit, 500 server error, 422 unprocessable
JSON errors 2 JSONDecodeError, unexpected response structure (KeyError)
Unexpected exceptions 2 RuntimeError, OSError catch-all
Output logging 4 Logging integration doesn't crash on success, error, invalid input, zero results
Request construction 5 URL includes CVE ID, targets search API, Accept header, timeout param, sort=updated
Result parsing edge cases 5 Null description, zero stars, exactly 5 results, fewer than 5, summary mentions "top 5"
ToolUse ID propagation 3 ID preserved on success, network error, validation error

Why this matters

search_for_exploits is a security-critical tool that searches GitHub for public Proof-of-Concept exploits. It handles authentication tokens, makes network requests, and parses untrusted JSON responses. Despite this, it had zero dedicated test coverage (only 2 importability checks in unrelated files). This suite covers:

  • All error paths (network failures, malformed responses, auth failures)
  • Token injection security (env var priority, config fallback, exception safety)\n- Response parsing robustness (null fields, missing keys, count boundaries)
  • Request construction correctness (URL format, headers, timeout)

Test design notes

  • No real HTTP calls — all requests.get calls are mocked
  • Resilient to test ordering — the TestOutputLogging class avoids assert_called_once patterns that break when test_packageability.py (which uses importlib._fresh_import) runs earlier in the suite and invalidates module-level mock patches
  • Config isolationConfig.from_file() is mocked to prevent filesystem dependencies

Existing PRs checked (no overlap)

This is the first dedicated functional test suite for search_for_exploits.

Test results

1211 passed, 3 deselected, 3 warnings in 24.56s

Baseline: 1158 tests. New: 53 tests. All pass, ruff check/format clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant