Skip to content

feat(parsers): add Kotlin language support#18

Merged
tob-scott-a merged 1 commit intomainfrom
kotlin-parser
Apr 23, 2026
Merged

feat(parsers): add Kotlin language support#18
tob-scott-a merged 1 commit intomainfrom
kotlin-parser

Conversation

@tob-scott-a
Copy link
Copy Markdown
Collaborator

Handles .kt and .kts files using tree-sitter-language-pack's kotlin grammar (transitive dep, no new installs). Extracts:

  • Top-level functions (fun main, suspend fun fetch, ...)
  • Classes, interfaces, data classes, objects, enum classes
  • Methods inside class_body and enum_class_body
  • Parameters from function_value_parameters and their user_type / type_identifier / nullable_type annotations
  • Return types from the type node following : on the signature
  • Imports — captured as graph.dependencies

Entrypoint detectors for Kotlin:

  • Spring MVC / WebFlux annotations (@GetMapping, @PostMapping, etc.) reusing the existing Java detector since the annotations are identical across the two languages.
  • Android component lifecycle methods: onCreate, onStart, onResume, onNewIntent, onActivityResult, onReceive, onBind, onHandleIntent. These are attacker-reachable when the component is exported — we over-detect on purpose and rely on the override file to tighten.

Known gap (parallel to Swift, documented in parser docstring): throw statements share their AST node type with return/break/continue via jump_expression, so exception-type capture needs a Kotlin-specific walk filtered by the leading throw token. Deferred.

14 new tests: Kotlin parser, Kotlin entrypoint detection. README supported-languages and framework-coverage tables updated.

Roadmap left before v0.2.0: Dart/Flutter parser, Go/Ruby/C++ entrypoint detectors (Option A), branches + docstring in JSON export (Option B).

Handles .kt and .kts files using tree-sitter-language-pack's kotlin
grammar (transitive dep, no new installs). Extracts:

- Top-level functions (fun main, suspend fun fetch, ...)
- Classes, interfaces, data classes, objects, enum classes
- Methods inside class_body and enum_class_body
- Parameters from function_value_parameters and their user_type /
  type_identifier / nullable_type annotations
- Return types from the type node following `:` on the signature
- Imports — captured as graph.dependencies

Entrypoint detectors for Kotlin:

- Spring MVC / WebFlux annotations (@GetMapping, @PostMapping, etc.)
  reusing the existing Java detector since the annotations are identical
  across the two languages.
- Android component lifecycle methods: onCreate, onStart, onResume,
  onNewIntent, onActivityResult, onReceive, onBind, onHandleIntent.
  These are attacker-reachable when the component is exported — we
  over-detect on purpose and rely on the override file to tighten.

Known gap (parallel to Swift, documented in parser docstring): `throw`
statements share their AST node type with `return`/`break`/`continue`
via `jump_expression`, so exception-type capture needs a Kotlin-specific
walk filtered by the leading `throw` token. Deferred.

14 new tests: Kotlin parser, Kotlin entrypoint detection. README
supported-languages and framework-coverage tables updated.

Roadmap left before v0.2.0: Dart/Flutter parser, Go/Ruby/C++ entrypoint
detectors (Option A), branches + docstring in JSON export (Option B).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tob-scott-a tob-scott-a merged commit c3ae26e into main Apr 23, 2026
6 checks passed
@tob-scott-a tob-scott-a deleted the kotlin-parser branch April 23, 2026 14:46
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