mirror of
https://github.com/elementalsouls/Claude-BugHunter.git
synced 2026-11-24 20:30:23 +01:00
* fix(scope): normalize every rule source to host; add Scope.warnings Out-of-scope rules written with a scheme/port/path/trailing punctuation or a wildcard matched nothing and silently failed open. One normalization point in Scope.__init__ now reduces every rule source (scope.md, scope.json, CLI flags, osint/recon helpers) to its host. Port/path widening is recorded in a new Scope.warnings channel. Reported by @fairoz-539 (#182). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(scope): recognize IPv6 CIDR rules via ipaddress The CIDR detector used p.replace('.','').replace('/','').isdigit(), which colons make non-digit, so an IPv6 CIDR deny/allow rule (2001:db8::/32) never matched. Detect any CIDR via ipaddress.ip_network; a family mismatch returns False, never raises. Reported by @fairoz-539 (#182). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(scope): soft-fail an invalid out-of-scope regex (warn, treat as host) A bad re: deny regex was caught and silently matched nothing — a fail-open on the one gate that must fail closed. Now it warns loudly and re-admits the remainder as a literal host deny rule, so the run continues with scope still enforcing. Valid regexes are unaffected. Reported by @fairoz-539 (#182). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(scope): open a section only on a start/end scope heading; hint recon hosts A recon-seeded note heading ('... VERIFY in-scope before testing') matched the substring 'in-scope' and opened the in-scope section, silently promoting passive crt.sh/subfinder hosts to scope rules (#198). _section_of now opens a section only when the heading's label starts or ends with a scope phrase (trailing parenthetical and colon stripped first). Hosts found under a scope-mentioning note heading are surfaced as a Scope.warnings hint instead. Scaffolder heading reworded (no inner quotes; hunt.ps1 stays ASCII). Reported by @udarshmarthala (#198). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(scope): surface scope warnings on stderr and in the engine log Scope.warnings (bad deny regex, widened rule, recon-seeded hosts) now print to stderr from scope.py and go to the engine log at start — nothing is silent, and stdout stays clean for --json-style consumers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(engine): follow recon redirects one hop at a time, inside scope Recon fetches followed redirects to any host: spa_recon adopted the landed (possibly off-scope) origin and crawled its robots/sitemap; _probe ran curl -L, so platform/openapi recon chased Location anywhere. A new _walk() follows at most MAX_REDIRECTS hops and only while the scope predicate accepts the next URL; all backends (requests, a no-redirect stdlib _OPENER, curl without -L) route through it. spa_recon re-checks the landed host, and platform/openapi recon skip out-of-scope seeds. In-scope redirects (http->https, / -> /home) are unaffected. Reported by @fairoz-539 (#181). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(engine): auth sweep grades a 3xx as enforcement, never chases Location A declared-secured op answering 302 -> /login was graded by the followed login page's 200 as 'declared-secured, NOT enforced' — a false positive. The sweep now uses the no-redirect opener, so a 3xx is graded as itself (enforcement) and no request chases Location. Repoints test_openapi_readonly to the module opener. Adds the scope-hardening CHANGELOG entry. Reported by @fairoz-539 (#181). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(scope): review follow-ups — bare IPv6 deny, prune redirect, test sockets Fresh-review fixes: - CRITICAL: a bare/zoned unbracketed IPv6 single-host rule normalized to its first hextet (urlparse split on ':'), so an IPv6 out-of-scope rule failed open. Detect a literal IP in _normalize_rule and return its canonical form. - IMPORTANT: prune_inert_params followed no redirects (allow=None), so a live parameterized endpoint behind an in-scope redirect (http->https, canonical slash) was mis-judged inert and dropped. Thread scope through and follow in-scope hops. - MINOR: loopback test servers now server_close() in tearDown (no leaked sockets under -W error). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * docs(superpowers): scope-hardening design + implementation plan Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * test(osint): enumeration_roots covers host after scope normalizes port/path Rebase interaction with #221: the scope gate (#205) now widens example.com/path and example.com:8080 to the host example.com, so enumeration_roots correctly yields ['example.com'] instead of dropping them. Update the #221 regression case to the combined correct behavior. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
24 lines
1.1 KiB
Python
24 lines
1.1 KiB
Python
import json
|
|
import unittest
|
|
from unittest.mock import Mock, patch
|
|
|
|
import recon
|
|
from scope import Scope
|
|
|
|
|
|
class OpenAPIReadOnlyTests(unittest.TestCase):
|
|
def test_recon_maps_writes_but_only_probes_them_after_opt_in(self):
|
|
spec = {
|
|
"security": [{"session": []}],
|
|
"paths": {"/api/items": {"get": {}, "post": {}, "delete": {}}},
|
|
}
|
|
scope = Scope(["example.test"], seeds=["https://example.test"])
|
|
for intrusive, methods in ((False, ["GET"]), (True, ["GET", "POST", "DELETE"])):
|
|
with self.subTest(intrusive=intrusive), \
|
|
patch.object(recon, "_probe", return_value=(200, json.dumps(spec))), \
|
|
patch.object(recon._OPENER, "open", return_value=Mock(status=401)) as request:
|
|
items = recon.openapi_recon(scope, log=Mock(), allow_intrusive=intrusive)
|
|
self.assertEqual({item["method"] for item in items}, {"GET", "POST", "DELETE"})
|
|
self.assertEqual([call.args[0].get_method() for call in request.call_args_list],
|
|
methods)
|