[K9VULN-16456] Add additional generated file detections#932
Merged
Conversation
Extends the Java match arm with banners emitted by:
- @javax.annotation.Generated (JSR-250, used by OpenAPI Generator,
MapStruct, wsimport, JAXB)
- "This file is generated by" (jOOQ and similar SQL/IDL generators)
- JAXB/wsimport ("This class was generated by")
- ANTLR 4 ("// Generated from ... by ANTLR ...")
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ed by) Extends the JavaScript match arm with: - "@generated by" (protoc and similar tools that emit "@generated by <tool>" banners) - "Auto-generated by" (pmndrs/gltfjsx React Three Fiber component generator and similar tools) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Extends the Python match arm with: - "file was automatically generated by" (SWIG and similar tools that emit this prefix) - "Automatically generated by Colab" (Colab-exported notebooks/scripts) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Extends the Ruby match arm with: - "# Code generated by" (Speakeasy and other generators) - "This file is auto-generated from the current" (Rails db/schema.rb) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ed by) Extends the TypeScript match arm with: - "@generated by" (protobuf-ts and similar; the trailing " by" avoids the webpack-alias false positives that bare "@generated" produces) - "auto-generated by" (openapi-typescript and other tools that emit this lowercase prefix) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Matches banners emitted by: - "@generated by" (prost / tonic gRPC, SeaORM) - "automatically generated by rust-bindgen" (rust-bindgen C FFI) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Matches banners emitted by: - "Generated by the Swift generator plugin for the protocol buffer compiler" (SwiftProtobuf) - "This file was automatically generated" (Swift codegen tools) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Matches banners emitted by: - "@generated by Composer" (Composer autoload files) - "@generated by a phing" (Phing build tool task output) - "This file has been auto-generated by the Symfony" (Symfony DI container cache) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
🎯 Code Coverage (details) 🔗 Commit SHA: fd7d7fb | Docs | Datadog PR Page | Give us feedback! |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands static-analysis-kernel’s generated-file heuristics by adding additional header substring detections for common generators across multiple ecosystems (Java, JS/TS, Python, Ruby, Rust, Swift, PHP), along with corresponding unit tests to reduce false negatives when deciding whether to skip analysis on generated sources.
Changes:
- Added multiple new per-language header substring matches in
is_generated_file. - Added/expanded unit tests to cover the new detection substrings (including new tests for PHP/Swift/Rust).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bahar-shah
approved these changes
Jun 25, 2026
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.
What this PR does
Adds extra substring matches for common ecosystem code generators.
(This is an AI-generated PR, but it needed heavy steering and touch-ups. I've reviewed each commit.)
Java
@javax.annotation.GeneratedThis file is generated byThis class was generated byby ANTLRJavaScript
@generated byAuto-generated byPython
file was automatically generated byAutomatically generated by ColabRuby
# Code generated byThis file is auto-generated from the currentTypeScript
@generated byauto-generated byRust
@generated byautomatically generated by rust-bindgenSwift
Generated by the Swift generator plugin for the protocol buffer compilerThis file was automatically generatedPHP
@generated by Composer@generated by a phingThis file has been auto-generated by the Symfony