Skip to content

Scanning with the Lineai SQL Agent (Docker)

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

Pull and run the SQL agent image from your Lineai server registry:

Terminal window
docker run --pull always --rm --interactive --tty \
--env LINEAI_HOST="http://your_server" \
--env AGENT_UUID="your-agent-uuid" \
--env AGENT_PASSWORD="your-agent-password" \
your_server/lineai_sql:latest analyze \
--application "yourApp" \
--connection-url "jdbc:postgresql://localhost:5432/sampledb" \
--username postgres_user --password postgres_pass

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
  • See Docker Documentation for more options.

Before running the docker image, ensure read permission on the database to be scanned.

Verify that /etc/mongod.conf is configured to authenticate:

security:
authorization: "enabled"

Ensure the credentials have read permissions on the database to be analyzed. For example, to analyze the sample_mflix database, the lineai_reader user was created using this command:

Terminal window
test> use admin
switched to db admin
admin> db.createUser({user: "lineai_reader", pwd: "password1234", roles: [{role: "read", db: "sample_mflix"}]})
{ ok: 1 }

This mongodb connection string authenticates with the user lineai_reader, password password1234 and uses the option of including it in connection string instead of the CLI. The username and password are authenticated against the admin database. It is used with the output above to analyze the sample_mflix database.

Terminal window
--connection-url "mongodb://lineai_reader:password1234@myServer.myCompany.com:27017/sample_mflix?authSource=admin"

Combined with the docker run example above and including the credentials in the string instead of separately, the entire command line may look similar to this:

Terminal window
docker run --network=host --pull always --rm --interactive --tty \
--env LINEAI_HOST="http://myServer.myCompany.com" \
--env AGENT_UUID="6f396f98-9884-4530-ab3e-9a916885dcd0" \
--env AGENT_PASSWORD="qE15EVh4SyU3rfbJ" \
myServer.myCompany.com/lineai_sql:latest analyze \
--application "sample_mflix_app" \
--scan-space-name "ss-Sample_mflix" \
--connection-url "mongodb://lineai_reader:password1234@myServer.myCompany.com:27017/sample_mflix?authSource=admin"
Terminal window
analyze -a yourApp -c jdbc:postgresql://localhost:5432/sampledb -u postgres_user -pwd postgres_pass

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