Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Java and Kotlin

Snyk support for Java and Kotlin with Snyk Code and Snyk Open Source, including SCM import, CLI and IDE testing, and Maven and Gradle

Applicability and integration

Java and Kotlin are supported for Snyk Code and Snyk Open Source.

Available integrations:

  • SCM import

  • CLI and IDE: test or monitor your app

Release status

Improved Gradle SCM scanning is in Early Access. For more information, visit SCM integrations for Java and Kotlin.

Technical specifications

Snyk supports Java analysis for Java versions up to SE 25 and is designed to process code from newer Java versions where feasible.

Supported frameworks and libraries

For Java and Kotlin, Snyk supports the following frameworks and libraries:

  • Amazon AWS SDK

  • Amazon AWS SDK DynamoDB, including the Enhanced Client

  • Android Standard Library

  • Apache Camel

  • Apache Commons

  • Apache Commons Collections

  • Apache Commons FileUpload

  • Apache CXF

  • Apache Tomcat

  • Apache XML

  • apache.mahout

  • bouncycastle

  • com.azure.ai.openai

  • com.google.ai.client.generativeai

  • com.google.cloud.vertexai.generativeai

  • com.google.re2j

  • com.google.gwt

  • Dropwizard

  • elasticsearch

  • FasterXML Jackson

  • Flyway

  • Google API Client

  • Google Cloud BigQuery

  • Google Guava

  • Google OAuth Client

  • grpc-java

  • hibernate

  • http4k

  • io.jsonwebtoken

  • Jakarta EE

  • Jakarta XML Services

  • Java EE

  • Java Servlet

  • Java Servlet (javax)

  • Java Server Pages

  • Java Standard Edition

  • javalin

  • Jax-RS

  • JAXB

  • Jolokia

  • jooq

  • Kryo

  • Micronaut

  • mongo-java-driver

  • MSAL4J

  • Netty

  • okhttp3

  • org.apache.hc.client5

  • org.apache.http.client

  • org.apache.sling

  • org.apache.tools.zip

  • org.codehaus.plexus

  • org.dom4j.io

  • Playframework

  • rxhttp

  • SAP Commerce (Hybris)

  • Seam logger

  • SnakeYaml

  • Spongycastle

  • Spring AI

  • Spring boot

  • Spring Cloud Config

  • Spring Data MongoDB

  • Spring Security OAuth2 Client

  • Spring Web, MVC and JDBC

  • Spring WebFlux

  • Struts

  • Vaadin

  • Vert.x

  • XStream

Kotlin only:

  • Android Standard Library

  • com.aallam.openai

  • com.expediagroup.graphql.server

  • Javalin

  • Ktor

  • Kotlin Standard Library

  • khttp

For SAP Commerce (Hybris), Snyk Code analyzes FlexibleSearch queries for SQL injection. This is supported for Java only. Snyk Code recognizes values supplied through query parameter binding as safe and does not report them.

For Google Cloud BigQuery, Snyk Code recognizes query parameters created with QueryParameterValue.of() as safe and does not report them for SQL injection. This is supported for Java only.

Supported package managers and package registries

Java and Kotlin for Snyk Code

For an overview of the supported security rules, visit Java rules and Kotlin rules.

Supported file formats

For Java and Kotlin, Snyk Code supports the following file formats:

  • For Java: .java, .jsp, .jspx

  • For Kotlin: .kt

Available features

  • Reports

  • Interfile analysis: fully supported for Kotlin

  • Interfile analysis: partially supported for Android

Template file analysis

Snyk Code parses template files and follows data from your application code into the template, so it reports a cross-site scripting vulnerability that becomes exploitable only where the template renders its output.

For Java and Kotlin, Snyk Code supports the following template engines:

  • FreeMarker

  • Thymeleaf

  • Velocity

For file extensions and the full set of supported language and template engine combinations, visit Template file analysis.

Java and Kotlin for Snyk Open Source

Supported file formats

For Java and Kotlin, Snyk Open Source supports the following file formats:

  • For Maven: pom.xml

  • For Gradle: build.gradle, build.gradle.kts

Available features

  • Reports

  • License scanning

  • Fix PRs (for Gradle, only fix advice is available)

  • Test your app's software bill of materials (SBOM) and packages using pkg:maven PURLs through the SBOM test CLI command

Validating, monitoring, alerting, and gating for Java and Kotlin

For SCM integrations, you can run PR Checks to validate submitted changes to code and open source packages before merging. Snyk can also retest and alert on the default branch on a scheduled basis. You can see the results on the Projects page.

For continuous integration/continuous delivery (CI/CD) integrations, Snyk can passively monitor and provide a QA gate by failing build checks during testing for policy violations.

Snyk provides flexible capabilities, including:

  • Gradle plugins (Community project)

  • Dedicated plugins for Jenkins, CircleCI, and others (visit the relevant marketplaces)

  • The Snyk CLI, which you can use in most CI/CD systems (visit the examples)

  • Partner platforms: Azure, Bitbucket, and AWS have built-in pipes and components for use with Snyk. For Java, Snyk recommends using the SCM integration with Bitbucket Cloud or using the CLI instead of the prepackaged Bitbucket Pipe.

Using the Kubernetes integration, Snyk can monitor container images and their open-source or Linux-based packages used in production, and notify you of known vulnerabilities in applications in production. This feature is available only for Enterprise plans.

Where a production integration does not exist, use the snyk monitor CLI command to take a snapshot and monitor what is being pushed to production (available for all plans).

Java support for BOM

Maven supports bill of materials (BOM) POM files to centralize dependency versions known to work together.

A BOM file includes:

  • a pom packaging type: <packaging>pom</packaging>

  • a dependencyManagement section

Third-party projects can provide BOM files to simplify dependency management. Common examples include the following:

  • spring-data-bom: The Spring team provides a BOM for the Spring Data project.

  • jackson-bom: The Jackson project provides a BOM for Jackson dependencies.

Example of a BOM file:

The dependencyManagement section contains dependency elements. Each dependency is a lookup reference for Maven to determine the version to select for transitive (and direct) dependencies.

A dependency defined in the dependencyManagement section is only a lookup reference. Maven does not add it to the dependency tree of the Project.

You can run mvn dependency:tree on the previous BOM example to show that Maven does not treat the contents as dependencies of the file itself.

You can import this BOM into a Project POM as a parent. You do not need to specify the log4j version, because the Project POM inherits it from the BOM:

Snyk applies the versions in the BOM dependencyManagement lookup to any dependencies declared in Project POMs that import it as a parent.

When Snyk scans BOM files, Snyk does not consider the dependencyManagement contents to be dependencies of that file. They are only lookups.

For the previous examples, Snyk analyzes and treats the files as follows:

  • BOM file: Snyk does not create a Snyk Project for this file because it has no dependencies.

  • Project POM: Snyk creates a Project with a single dependency, log4j, with v1.2.12. Snyk applies the rules from the parent BOM to identify the correct version for log4j. The dependency commons-logging is not included, as it is not directly declared in the Project POM.

This example uses log4j 1.x to demonstrate BOM version inheritance. log4j 1.x is end-of-life and has known vulnerabilities, so Snyk does not recommend using it.

If a BOM has direct dependencies outside dependencyManagement, then Snyk creates a Project for that BOM.

Snyk also offers fix advice, including recommendations to upgrade vulnerable packages through the Fix PR feature.

Snyk can create Fix PRs only for dependencies whose versions are managed in the POM file where Snyk reports the vulnerability.

If the version or dependency is managed in a parent BOM, then even though Snyk sees that it could fix the vulnerable path by changing the version, it cannot apply the fix.

Visit the following resources for Java developers on security topics and best practices:

Last updated

Was this helpful?