Deploying the AcuSensor agent for JAVA - Docker Spring Boot
🔍 AcuSensor Network PreRequisites
AcuSensor makes use of the AcuSensor Bridge. Read more information here.
The AcuSensor agent will need to be deployed to your Docker Spring Boot container. This section describes how to deploy AcuSensor together with your Spring Boot web application into a Docker container
The Java AcuSensor requires:
- Deploying aspectjweaver.jar into your web server - provides the integration required for AcuSensor to work with your application
- Deploying the Acunetix Java AcuSensor into your web server - this is unique for each Target, and can be downloaded by using the Download JAVA AcuSensor button
- Configuring your web server to use Load Time Weaving (AspectJWeaver)
Assumptions for this document
Note: This document assumes that you will be using version 1.9.5 (latest at time of writing) of AspectJWeaver.
Note: This document assumes that you are logged into the docker host as root, and that all files for this web application will be kept in the folder "/root/myspringapp/"
Prepare Folder for Spring Boot Docker deployment
On the docker host, run the following command:
- mkdir /root/myspringapp/
Preparing AspectJWeaver for your container
To download and deploy AspectJWeaver, run the following commands:
- cd /root/myspringapp/
- wget -c https://repo1.maven.org/maven2/org/aspectj/aspectjweaver/1.9.5/aspectjweaver-1.9.5.jar
- mv aspectjweaver-1.9.5.jar aspectjweaver.jar
Preparing AcuSensor for your container
- Create a Target in your Acunetix UI for the exact URL of your new web application (for example: http://myspringapp.example.com:8080/ )
- Download the Acunetix JAVA AcuSensor for your web application target from the Acunetix UI
- Copy the Acunetix JAVA AcuSensor (AcuSensor.jar) to the docker host into folder /root/myspringapp/
Preparing Spring Boot web application for your container
- Build your application called, for this example, myspringapp.jar
- Copy the JAR file for your web application myspringapp.jar to the docker host folder /root/myspringapp/
Create Dockerfile for your Spring Boot web application
- To create and edit your Dockerfile, run the following command:
- nano /root/myspringapp/Dockerfile
- Edit the contents of your Dockerfile to show the following:
COPY AcuSensor.jar AcuSensor.jar
COPY aspectjweaver.jar aspectjweaver.jar
COPY myspringapp.jar myspringapp.jar
CMD java -javaagent:aspectjweaver.jar -Dacusensor.debug.log=ON -Dloader.path=AcuSensor.jar -cp myspringapp.jar org.springframework.boot.loader.PropertiesLauncher
- Save the Dockerfile and exit the nano editor
Build your Docker Image and Start a Container based on the Image
On the docker host, run the following commands:
- cd /root/myspringapp/
- docker build -t myspringapp:test .
- docker run --publish 8080:8080 --detach --name myspringapp myspringapp:test
Congratulations! You are now ready to scan your new Spring Boot web application with Acunetix.