Skip to content

Scanning with the Lineai Java Agent (Docker)

The LineaiJava Agent for Docker provides an easy way to integrate Lineai scanning into your build process.

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.

Terminal window
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 /scan

Docker 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

Terminal window
analyze -a yourApp -t ARCHIVE -p /locationToYourApp/app.jar

analyze an application with a relational database

Terminal window
analyze -a yourApp -d jdbc:postgresql://localhost:5432/sampledb -t ARCHIVE -p /locationToYourApp/app.jar

For more information, see Binary Scanning via Command Line (Java).

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
''')
}
}
}