Scanning with the Lineai Java Agent (Docker)
The LineaiJava Agent for Docker provides an easy way to integrate Lineai scanning into your build process.
Run the Docker Image
Section titled “Run the Docker Image”Pull and run the Java agent image from your Lineai server registry. Set LINEAI_HOST, AGENT_UUID, and AGENT_PASSWORD to match your environment. Mount the directory to scan into the container.
docker run --pull always --rm --interactive \ --env LINEAI_HOST="https://yourinstance.app.lineai.com" \ --env AGENT_UUID="your-agent-uuid" \ --env AGENT_PASSWORD="your-agent-password" \ --volume /path/to/scan:/scan \ yourinstance.app.lineai.com/lineai_java:latest analyze \ --application "Your Application" \ --path /scanDocker options:
- —pull always — ensures that you always get the newest image
- —env LINEAI_HOST — Lineai server URL
- —env AGENT_UUID / —env AGENT_PASSWORD — agent credentials
- —volume — mounts the host directory to scan into the container
See Docker Documentation for more options.
Only analyze an application
analyze -a yourApp -t ARCHIVE -p /locationToYourApp/app.jaranalyze an application with a relational database
analyze -a yourApp -d jdbc:postgresql://localhost:5432/sampledb -t ARCHIVE -p /locationToYourApp/app.jarFor more information, see Binary Scanning via Command Line (Java).
CI/CD Scanning
Section titled “CI/CD Scanning”Using the Docker agent with Jenkins
Section titled “Using the Docker agent with Jenkins”The Lineai Java Agent for Docker can be used to scan artifacts in Jenkins pipelines.
Example:
stage('Lineai Scan') { when { expression { BRANCH_NAME ==~ /(integration|v.*|feature\/.*)/ } } steps { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { // Publish Lineai Scan sh(''' docker run --pull always --rm --interactive \ --env LINEAI_HOST="https://yourinstance.app.lineai.com" \ --env "AGENT_UUID=${AGENT_UUID}" \ --env "AGENT_PASSWORD=${AGENT_PASSWORD}" \ --env "SCAN_SPACE_NAME=${SCAN_SPACE_NAME}" \ --volume ${PWD}:/scan \ yourinstance.app.lineai.com/lineai_java:latest analyze \ --application "Your Application" \ --path /scan \ --scan-space-name "Development" \ --method-filter com.example. \ --recursive com.example \ --expunge-scan-sessions ''') } }}