Trust in Protection, Trust in Us .
Guardians of Cyber Space .
Safeguarding Your Digital Identity .
Ensuring Security in the Digital Age .
Fortifying Your Cyber Defenses.
Securing Your Digital Frontier.
Documentation
Explore our comprehensive documentation to find technical guides, setup instructions, and troubleshooting resources.
Java Analysis SAST

Requirements:

  • JDK, (versions before 1.8 included use different plugin)
  • Maven 3.8+ installed
  • Access to a Maven repository with DocSpot
    plugins (maven plugin and javac plugin) available
  • Connectivity with the DocSpot API

Nowadays, Maven and Gradle are supported for configuring the analysis

Maven Configuration

When a build is performed in Maven, the dependencies and
plugins of the project are fetched from public repositories or
those defined in the local Maven installation configurations. In our
case, we use a public repository where the plugins necessary for
performing an analysis are located.

The first step is to configure the Maven repository as one of the
sources of dependencies and plugins for the project:

 

<repositories>
   <repository>
      <snapshots>
         <enabled>true</enabled>
      </snapshots>
      <id>ossrh</id>
      <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
   </repository>
</repositories>
<pluginRepositories>
   <pluginRepository>
      <snapshots>
         <enabled>true</enabled>
      </snapshots>
      <id>ossrh</id>
      <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
   </pluginRepository>
</pluginRepositories>

 

Two plugins are necessary for the analysis: one is the plugin that
intercepts the compilation process (javac plugin), and the other is
the plugin that intercepts the Maven build (Maven plugin).
The javac plugin collects information from the source code directly
from the compiler, while the Maven plugin is responsible for sending
this information to the DocSpot API.

To configure the Maven plugin:

 

<plugin>
   <groupId>com.docexploit</groupId>
   <artifactId>docspot-maven-plugin</artifactId>
   <version>1.1.7-SNAPSHOT</version>
   <configuration>
      <skip>false</skip>
      <baseApi>https://api.docspot.docexploit.com</baseApi>
      <apiKey>API-KEY</apiKey>
      <projectId>PROJECT-ID</projectId>
      <analyzer>java</analyzer>
      <language>java</language>
      <ignoredPaths>
         <ignore>target/**</ignore>
         <ignore>.mvn/**</ignore>
         <ignore>.github/**</ignore>
      </ignoredPaths>
   </configuration>
   <executions>
      <execution>
         <id>analyzer</id>
         <goals>
            <goal>docspot-analysis</goal>
         </goals>
      </execution>
   </executions>
</plugin>

 

Also we need to add the compiler plugin, where the DocSpot logical runs with the compiler. In the case of Maven is configured with the Maven Compiler Plugin.

 

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
	<configuration>
	  <annotationProcessorPaths>
		<path>
		  <groupId>com.docexploit</groupId>
		  <artifactId>docspot-java-importer</artifactId>
		  <version>1.2.5-SNAPSHOT</version>
		</path>
	  </annotationProcessorPaths>
	  <fork>true</fork>
	  <compilerArgs>
		<arg>-J--add-exports="jdk.compiler/com.sun.source.util=ALL-UNNAMED"</arg>
		<arg>-J--add-exports="jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"</arg>
		<arg>-J--add-exports="jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"</arg>
		<arg>-J--add-exports="jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"</arg>
		<arg>-J--add-exports="jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED"</arg>
		<arg>-J-Xmx4g</arg>
	  </compilerArgs>
	  <compilerArgument>-Xplugin:DocspotPlugin</compilerArgument>
	  <testCompilerArgument>-Xplugin:DocspotPlugin test</testCompilerArgument>
	</configuration>
</plugin>

 

After this, an analysis will be run every time the project is compiled. If you want to skip an analysis put the skip parameter as true.

Join Our Newsletter To Get The Latest Guides
Discover the new range of specialized and disruptive tools on the market, specialized in virtualized cloud and on-premise environments.
Gran Via, 18. 26001 Logrono, La Rioja
© DocExploit
Alcance para las actividades desarrolladas en su sede de Logroño
DOCEXPLOIT SL, con CIF B67868513, ha recibido financiación por parte de la Agencia de Desarrollo Económico de La Rioja. Esta financiación ha sido solicitada a través de la convocatoria 2025 de las ayudas destinadas al fomento de Nuevas Empresas de Base Tecnológica –Programa 1: Empresas de Base Tecnológica -en el marco del Programa de Redes Territoriales de Especialización Tecnológica (RETECH)-Proyecto TechFabLab, por valor de 320.394,76 € a través del expediente 2025-I-EBT-00001, y por valor de 257.317,75 € a través del expediente 2025-I-EBT-00009.
© 2024, All Rights Reserved