Add SAST Scala security test files only#72
Conversation
amazon-pratik
commented
Sep 3, 2025
- Added 158 Scala security test files from SAST repositories
- Files from sast-rules and curated-semgrep-rules repositories
- Security categories: injection, crypto, authentication, file handling, XML, network
- Clean branch with only Scala files for security analysis
- Added 158 Scala security test files from SAST repositories - Files from sast-rules and curated-semgrep-rules repositories - Security categories: injection, crypto, authentication, file handling, XML, network - Clean branch with only Scala files for security analysis
|
⏳ Code review in progress. Analyzing for code quality issues and best practices. Detailed findings will be posted upon completion. Using Amazon Q Developer for GitHubAmazon Q Developer1 is an AI-powered assistant that integrates directly into your GitHub workflow, enhancing your development process with intelligent features for code development, review, and transformation. Slash Commands
FeaturesAgentic Chat Code Review CustomizationYou can create project-specific rules for Amazon Q Developer to follow:
Example rule: FeedbackTo provide feedback on Amazon Q Developer, create an issue in the Amazon Q Developer public repository. For more detailed information, visit the Amazon Q for GitHub documentation. Footnotes
|
There was a problem hiding this comment.
Summary of Changes
Hello @amazon-pratik, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly enhances the project's static application security testing capabilities by integrating a substantial collection of Scala security test cases. These additions provide a robust and diverse set of examples for identifying common vulnerabilities, streamlining the process of security analysis and ensuring broader coverage against potential threats.
Highlights
- New Scala Security Test Files: This pull request introduces 158 new Scala security test files, significantly expanding the test coverage for static application security testing (SAST).
- Source Repositories: The added files are sourced from both the 'sast-rules' and 'curated-semgrep-rules' repositories, consolidating security test cases.
- Comprehensive Security Categories: The new test files cover a broad spectrum of security categories, including injection, cryptography, authentication, file handling, XML processing, and network-related vulnerabilities.
- Dedicated Security Analysis Branch: The changes are specifically designed to create a clean branch containing only Scala files, optimized for focused security analysis.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request adds a large number of Scala files intended for security testing. The overall structure and content of these test files are appropriate for their purpose. I've identified a few issues in the test code itself that could lead to runtime exceptions or incorrect behavior. These include potential null pointer exceptions when handling cookies, incorrect argument handling, an unconventional main method signature, and a bug in an XSS stripping utility. Addressing these will improve the robustness and correctness of the test suite.
| innerValue = scriptPattern.matcher(innerValue).replaceAll("") | ||
| } | ||
| } | ||
| value |
| innerValue = scriptPattern.matcher(innerValue).replaceAll("") | ||
| } | ||
| } | ||
| value |
| for (cookie <- req.getCookies) { | ||
| cookie.getName | ||
| cookie.getValue | ||
| cookie.getPath | ||
| } |
There was a problem hiding this comment.
req.getCookies can return null if no cookies are sent with the request. Iterating on a null value with a for comprehension will result in a NullPointerException. You should add a null check to prevent this.
| for (cookie <- req.getCookies) { | |
| cookie.getName | |
| cookie.getValue | |
| cookie.getPath | |
| } | |
| for (cookie <- Option(req.getCookies).flatten) { | |
| cookie.getName | |
| cookie.getValue | |
| cookie.getPath | |
| } |
| val c: Cookie = req.getCookies.head | ||
| c.getName |
There was a problem hiding this comment.
req.getCookies can return null or an empty array. Calling .head on it can cause a NullPointerException or NoSuchElementException. This should be handled to avoid runtime exceptions.
| val c: Cookie = req.getCookies.head | |
| c.getName | |
| val c = Option(req.getCookies).flatMap(_.headOption) | |
| c.map(_.getName).orNull |
|
|
||
|
|
||
| object WeakTLSProtocol { | ||
| def main(args: Array): Unit = { |
There was a problem hiding this comment.
The main method signature is unconventional. It uses java.lang.reflect.Array (imported on line 7) for the args parameter type, which is not a standard entry point for a Scala application. The standard signature is def main(args: Array[String]): Unit. The import on line 7 should also be removed.
| def main(args: Array): Unit = { | |
| def main(args: Array[String]): Unit = { |
| @throws[Exception] | ||
| def main(args: Array[String]): Unit = { | ||
| val doc: Document = null | ||
| val input = args(1) |
There was a problem hiding this comment.
| for (cookie <- req.getCookies) { | ||
| cookie.getName | ||
| cookie.getValue | ||
| cookie.getPath | ||
| } |
There was a problem hiding this comment.
req.getCookies can return null if no cookies are sent with the request. Iterating on a null value with a for comprehension will result in a NullPointerException. You should add a null check to prevent this.
| for (cookie <- req.getCookies) { | |
| cookie.getName | |
| cookie.getValue | |
| cookie.getPath | |
| } | |
| for (cookie <- Option(req.getCookies).flatten) { | |
| cookie.getName | |
| cookie.getValue | |
| cookie.getPath | |
| } |
| val c: Cookie = req.getCookies.head | ||
| c.getName |
There was a problem hiding this comment.
req.getCookies can return null or an empty array. Calling .head on it can cause a NullPointerException or NoSuchElementException. This should be handled to avoid runtime exceptions.
| val c: Cookie = req.getCookies.head | |
| c.getName | |
| val c = Option(req.getCookies).flatMap(_.headOption) | |
| c.map(_.getName).orNull |
|
|
||
|
|
||
| object WeakTLSProtocol { | ||
| def main(args: Array): Unit = { |
There was a problem hiding this comment.
The main method signature is unconventional. It uses java.lang.reflect.Array (imported on line 7) for the args parameter type, which is not a standard entry point for a Scala application. The standard signature is def main(args: Array[String]): Unit. The import on line 7 should also be removed.
| def main(args: Array): Unit = { | |
| def main(args: Array[String]): Unit = { |
| val input = if (args.length != 0) args(1) | ||
| else "guess' or '1'='1" |
There was a problem hiding this comment.
The check args.length != 0 is insufficient to prevent an ArrayIndexOutOfBoundsException. If the program is run with one argument, args.length will be 1, and accessing args(1) will still cause an exception. The check should be args.length > 1.
| val input = if (args.length != 0) args(1) | |
| else "guess' or '1'='1" | |
| val input = if (args.length > 1) args(1) | |
| else "guess' or '1'='1" |
|
@BugBot run |