feat(entrypoints): Go / Ruby / C / C++ framework detectors#20
Merged
Conversation
Adds Option A from the v0.2.0 roadmap — entrypoint detection for the
three languages that lagged behind the decorator-based detectors because
their conventions don't fit the scan-lines-above-start pattern.
Go:
- `http.HandleFunc("/path", name)` / `http.Handle(...)` stdlib.
- Router DSLs that share the `<receiver>.(GET|POST|PUT|PATCH|DELETE|
HEAD|OPTIONS|Any|Match)("/path", handler)` shape — gin, chi, echo,
fiber, and similar community routers.
The _SourceCache now exposes `go_http_handler_names(path)` which scans
a file once and caches the set of handler identifiers registered
anywhere in it; the detector looks up each function by name.
Ruby:
- Rails controllers — classes inheriting ApplicationController or
ActionController::*. Every method of such a class is tagged as an
untrusted-external API entrypoint.
- Sidekiq workers — classes with `include Sidekiq::Worker` /
`Sidekiq::Job`. Only the `perform` method is tagged.
Adds a class-body scanner to _SourceCache that tracks `class X ... end`
nesting to map include directives to their enclosing class.
C / C++:
- `extern "C"` linkage.
- `__attribute__((visibility("default")))`.
- `__declspec(dllexport)`.
Markers are matched on the signature line or the line immediately above
it; plain non-static functions are intentionally NOT flagged (too broad
for audit purposes — use the override file).
Also fixes a pre-existing gap in the C++ parser: `extern "C" int foo()`
wraps the function in a `linkage_specification` node, which the parser
wasn't unwrapping, so no function node was emitted. Now handled.
8 new tests across Go, Ruby, and C/C++ detection. README coverage
table updated.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Adds Option A from the v0.2.0 roadmap — entrypoint detection for the three languages that lagged behind the decorator-based detectors because their conventions don't fit the scan-lines-above-start pattern.
Go:
http.HandleFunc("/path", name)/http.Handle(...)stdlib.<receiver>.(GET|POST|PUT|PATCH|DELETE| HEAD|OPTIONS|Any|Match)("/path", handler)shape — gin, chi, echo, fiber, and similar community routers. The _SourceCache now exposesgo_http_handler_names(path)which scans a file once and caches the set of handler identifiers registered anywhere in it; the detector looks up each function by name.Ruby:
include Sidekiq::Worker/Sidekiq::Job. Only theperformmethod is tagged. Adds a class-body scanner to _SourceCache that tracksclass X ... endnesting to map include directives to their enclosing class.C / C++:
extern "C"linkage.__attribute__((visibility("default"))).__declspec(dllexport). Markers are matched on the signature line or the line immediately above it; plain non-static functions are intentionally NOT flagged (too broad for audit purposes — use the override file).Also fixes a pre-existing gap in the C++ parser:
extern "C" int foo()wraps the function in alinkage_specificationnode, which the parser wasn't unwrapping, so no function node was emitted. Now handled.8 new tests across Go, Ruby, and C/C++ detection. README coverage table updated.