Skip to content

feat(entrypoints): Go / Ruby / C / C++ framework detectors#20

Merged
tob-scott-a merged 1 commit into
mainfrom
more-framework-detectors
Apr 23, 2026
Merged

feat(entrypoints): Go / Ruby / C / C++ framework detectors#20
tob-scott-a merged 1 commit into
mainfrom
more-framework-detectors

Conversation

@tob-scott-a

Copy link
Copy Markdown
Collaborator

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.

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>
@tob-scott-a
tob-scott-a merged commit ead4e30 into main Apr 23, 2026
13 checks passed
@tob-scott-a
tob-scott-a deleted the more-framework-detectors branch April 23, 2026 15:36
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