fix(parsers/go): classify entry points by signature, not return type or bare next(#129
fix(parsers/go): classify entry points by signature, not return type or bare next(#129gadievron wants to merge 1 commit into
Conversation
|
Findings F7 + F10 (MED). Coordinates with #126 ( |
…or bare next( Two over-broad heuristics in classifyUnitType seeded false remote-web entry points: isHTTPHandler matched HTTP type patterns (incl. HandlerFunc) against the RETURN type, tagging factories like func Logger() gin.HandlerFunc as http_handler (F10); isMiddleware tagged any body containing the substring next( as middleware, catching Go 1.23 iterators / lexers / cursors (F7). Match handler patterns only against parameters, and gate the next( heuristic on an HTTP request signature. Genuine handlers and middleware remain classified (covered by new tests). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
c984135 to
aeeb641
Compare
|
Rebased onto origin/master (post-release #133 / Wave 1). Conflicts resolved by UNION — both this PR's fix and the Wave-1 parser fixes are preserved; no Wave-1 change reverted (independently judge-verified). Force-pushed with --force-with-lease. Clean rebase (master did not touch extractor.go); go test green. |
|
Closing as already resolved on current master. This fix's behavior shipped via the parser-fix-stack release (#133/#134); confirmed by independent reproduction — the original bug (reconstructed from its bug-pipeline investigation) no longer manifests on master, not merely by line-presence. Part of a full validated sweep of the open-PR corpus. |
fix(parsers/go): classify entry points by signature, not return type or bare next(
Base:
master· Type: bug fix · Findings: F10 + F7 (MED)What
parsers/go/go_parser/extractor.go:isHTTPHandlerno longer matcheshttpHandlerPatternsagainst thereturn type (dropped
|| pattern.MatchString(returnsStr)); it matchesparameters only.
isMiddlewareno longer treats a barenext(substring as middleware;the
next(heuristic is now gated on the function having an HTTP requestsignature (
hasHTTPSignature && strings.Contains(code, "next(")). Thehttp.Handler/http.HandlerFuncreturn andnext.ServeHTTPsignals are kept.Why
Both heuristics over-matched, seeding false remote-web entry points:
func Logger() gin.HandlerFunchas no request param but matched thebare
HandlerFuncpattern against its return type → taggedhttp_handler. Ahandler is defined by what it receives, not what it returns.
next(— Go 1.23 range-over-func iterators(
iter.Pull→next()), lexers, cursors — was taggedmiddleware.Tests
parsers/go/go_parser/extractor_classify_test.go(new): factory returninghttp.HandlerFuncis nothttp_handler; iterator usingnext()is notmiddleware; a genuine(w, r)handler and genuinenext.ServeHTTPmiddlewareare still detected.
go test ./...passes.Reachability impact (verified empirically, base vs patched binary)
Function-id sets identical (no extraction loss). Reclassified units sampled and
confirmed all fake:
middleware1 → 0 (CutPrefix, a pull-iterator).http_handler108 → 89; all 19 removed are factoriesreturning
HandlerFunc(Logger,Recovery,BasicAuth, …) with no requestparam. All 89 retained handlers carry a genuine request/context param.
Zero genuine handlers or middleware lost.
Scope / siblings (deferred, documented)
Same defect class but out of scope here (tightening risks false negatives,
needs its own corpus):
isHTTPHandlerbody heuristicsw.Write(/Handler =(
:289-290) over-match any localwwith.Write(;isCLIHandleros.Argsbody match (
:318). Tracked for a follow-up.Upstream coordination
Only PR #126 also edits
extractor.go(different functions:typeToStringgenerics +
duplicateIDWarning). No hunk overlap withisHTTPHandler/isMiddleware; rebase trivially if #126 lands first. Binarygo_parsernotincluded — reviewers/CI rebuild from source.
Author notes
isHTTPHandlerparam-only loop;isMiddlewarehasHTTPSignaturegate on
next(.next()-using iterators thatpreviously became false entry points.
gin/echo/fiber handlers always take the request/context as a param; a return-only
match is a factory. Body heuristics still catch param-less real handlers.