Levo

Fully Automated API Security Testing in CI/CD

Levo AI

Test your APIs using Levo AI test plans or app-based testing and get the results in real time.

Usage

Pre-requisites

In order to run this plugin you will need to:

  • Have a Levo AI account
  • Have a Levo CLI Authorization Key
  • For test plan mode: Have a Levo AI test plan
  • For app-based mode: Have an application configured in Levo AI

Installation

  • Go to "Manage Jenkins" > "Manage Plugins" > "Available".
  • Search for "Levo".
  • Install the plugin.

Configuring Levo Test Step on your builds

After adding a Levo Test Plan step into your build, you'll need to configure some values.

Execution Modes

The plugin supports two execution modes:

  1. Test Plan LRN : Run tests using a pre-configured test plan
  2. Application Name : Dynamically create and run tests based on application configuration

Credentials

For credentials this plugin is relying on credentials-plugin. You'll need to add a credential for the Levo API key.

  • Click on the "Add" button next to the credentials dropdown.
  • Select your datastore.
  • Select "Levo Credential" as credential type.
  • Enter your CLI Authorization Key.
  • Enter your organization id that you can get from the Organizations Tab in your user settings.
  • Save and select the new credential.

Mode 1: Test Plan LRN

This mode uses a pre-configured test plan from your Levo organization.

Configuration:

  • Test Plan LRN: The test plan identifier. Go to the Test Plan section of your Levo organization and click the "Copy LRN" button on the selected test plan.
  • Target: The target URL to test
  • Test Users: Comma-separated test user names (optional). If not specified, uses default user. Test users must be configured in Levo SaaS first.
  • Extra CLI Arguments: Additional command-line arguments (optional)
  • Generate JUnit Reports: Check to generate JUnit XML reports

Mode 2: Application Name (App-Based Testing)

This mode automatically creates and runs tests based on your application configuration. No need to manually create test plans!

Required Configuration:

  • Application Name: The name of your application in Levo AI
  • Environment: The environment to test (e.g., "production", "staging")

Optional Filtering:

  • Categories: Comma-separated test categories (default: BOLA,BFLA,INJECTION,SSRF)
  • HTTP Methods: Comma-separated methods to include (e.g., GET,POST,PUT)
  • Exclude Methods: Comma-separated methods to exclude (e.g., DELETE,OPTIONS)
  • Endpoint Pattern: Regex pattern to include specific endpoints (e.g., .*api.*)
  • Exclude Endpoint Pattern: Regex pattern to exclude endpoints
  • Test Users: Comma-separated test user names (optional). If not specified, uses default user. Test users must be configured in Levo SaaS first.
  • Target URL: Override the app's default target URL

Failure Criteria (Advanced):

  • Fail Severity: Minimum severity to fail the build (none, low, medium, high, critical)
  • Fail Scope: Fail on new vulnerabilities, any vulnerabilities, or none
  • Fail Threshold: Fail if vulnerability count exceeds this number

Example Configuration:

Application Name: my-api-app
Environment: production
Categories: BOLA,BFLA
HTTP Methods: GET,POST,PUT
Endpoint Pattern: .*api/v1.*
Test Users: Victim1,Victim2
Fail Severity: high
Fail Scope: new

Test User Selection:

  • Test users allow you to specify which authenticated users (configured in Levo SaaS) should be used when running tests
  • Multiple test users can be specified as comma-separated values (e.g., Victim1,Victim2)
  • The plugin will pass each test user to the CLI using the --test-user flag
  • If no test users are specified, the default test user for the app/environment will be used
  • Test users must be configured in Levo SaaS before they can be used in Jenkins jobs

Environment File (Optional)

If you are using an environment file to define authentication details, you can add those details as a secret using a secret file in the credentials-plugin.

  • Click on "Environment Secret Text" dropdown.
  • Click on "Add" next to the credentials dropdown.
  • Select your datastore.
  • Select "Secret File" as credential type.
  • Import the file.
  • Save and select the new file.

You're ready to go!

Levo DAST Scan (web application scanning)

The Levo DAST Scan build step (levoDastScan in Pipeline) scans a web application with the Levo DAST engine, sends the findings to your Levo workspace and passes or fails the build on a severity threshold.

Two execution modes:

Mode Where the scan runs Agent needs
Run on this agent (default) levoai/levoai-shadownet in Docker on the build agent Linux or macOS, Docker 20.10+, ~4 GB free RAM, ~3 GB disk; network access to the target, the Levo API and the Levo satellite of your region
Run on Levo Levo Cloud or your on-prem DAST runner (shadownet remote-scan, same levoai/levoai-shadownet image) Linux or macOS, Docker 20.10+, disk for the shadownet image and access to the Levo API; no access to the target or the satellite

Required: a Levo CLI Credentials credential, a target URL and the Levo environment (its name, for example staging, or its ID). Without an environment, findings are not sent to Levo.

node {
  try {
    levoDastScan(
      levoCredentialsId: 'levo-cli',
      targetUrl: 'https://staging.example.com',
      environment: 'staging',                      // name or ID
      configFile: '.levo/levo-dast.yml',          // optional
      authStrategy: 'form',                        // none | form | token | ai
      loginUrl: 'https://staging.example.com/login',
      targetCredentialsId: 'staging-login',        // Username with password
      failSeverity: 'high',                        // none | low | medium | high | critical
      failResult: 'UNSTABLE')                      // FAILURE | UNSTABLE
  } finally {
    junit allowEmptyResults: true, testResults: 'levo-dast-reports/junit.xml'
    archiveArtifacts artifacts: 'levo-dast-reports/**', allowEmptyArchive: true
  }
}

Run on Levo, on an on-prem DAST runner group (runnerGroup is only used with runOn: 'on-prem'):

levoDastScan(levoCredentialsId: 'levo-cli', environment: 'staging', executionMode: 'levo',
             targetUrl: 'https://staging.example.com', configFile: '.levo/levo-dast.yml',
             runOn: 'on-prem', runnerGroup: 'dc-1', failSeverity: 'critical')

Behaviour:

  • The step writes levo-dast-reports/scan-report.json and levo-dast-reports/junit.xml (one test case per finding; findings at or above the threshold fail) and prints a summary with a link to the scan in Levo.
  • A scan that does not complete fails the build: no report, a non-zero scanner exit, or a report whose status is not completed (failed, stopped, cancelled, ...). The summary and JUnit report are still written. A scan that stops at its own time budget (status timeout) marks the build UNSTABLE, or fails it if findings reach the threshold.
  • Each step invocation uses its own container names and temporary folder. Parallel scans in one workspace still share levo-dast-reports/: run them in separate directories (dir('a') { levoDastScan ... }).
  • Secrets (Levo key, target password/token, LLM key) are passed to the containers as environment variables and never appear in the build log or on a command line.
  • Both modes use the same shadownet login, the same Config file format and the same report. Extra CLI arguments apply to Run on this agent only.
  • Aborting the build stops the scanner container; in Run on Levo mode the scan is cancelled in Levo.
  • imageTag takes a tag (1.4.164) or a digest (sha256:…) to pin the scanner image.
  • The config file must be inside the workspace. The target login and token credentials must be in the global credentials domain or in a domain that matches the target URL's host.
  • Windows agents are not supported.

Behaviour of the Levo Test Plan step

Behaviour change: earlier versions ignored the Levo CLI exit code, so builds stayed green even when tests failed or the run errored. The step now fails the build when the Levo CLI exits non-zero, in all three execution modes. To keep the old "don't fail the build" behaviour, untick Fail build on Levo CLI error (Pipeline: failBuildOnError: false); a non-zero exit then marks the build UNSTABLE and the build continues.

  • A non-zero Levo CLI exit means test failures, findings that meet the configured failure criteria, or a run error. In Remote Test Run mode set Fail Severity to none to only fail on run errors.
  • Missing Levo credentials, a missing environment secret and a failed levo login always fail the build.
  • The authorization key is never printed in the console. Note that the released Levo CLI only accepts the key as a command-line argument (levo login -k, remote-test-run --key), so it is visible in the process list of the agent that runs Docker while those commands run.
  • The environment file is written with owner-only permissions (0600) and deleted after every run, including failed and aborted runs.
  • Mounted folders are created on the agent that runs Docker.

LICENSE

Licensed under Apache 2.0, see LICENSE