Astra’s CI/CD integration is designed to be flexible and production-ready, allowing you to embed security scans directly into your pipeline while maintaining control over how and when the pipeline should respond to scan outcomes. By configuring a set of environment variables, you can customize:

This article explains each of these variables in detail, helping you configure Astra to meet your CI/CD security and performance requirements.

Setting Environment Variables in Your CI/CD Pipeline

To integrate Astra with your CI/CD pipeline, you'll need to define the environment variables in your CI/CD configuration file or within the environment settings of your CI/CD tool. These variables control the scan behavior and exit strategy.

Typically, you would set them in one of the following places:

Once the variables are set, your pipeline will automatically use these configurations when initiating Astra scans, providing you with control over scan behavior, polling, and exit conditions.

Variables

Scan Mode (ASTRA_AUDIT_MODE)

Controls the type of assessment Astra runs when a scan is triggered. This helps differentiate between fully automated scans, manual pentesting workflows, or just web crawling without actual testing.

Default:

ASTRA_AUDIT_MODE="automated"

Options:

Recommended Usage:

Automated Scan Type (ASTRA_SCAN_TYPE)

Defines the depth and speed of the scan to be performed.

Default:

ASTRA_SCAN_TYPE="lightning"

Options:

Recommended Usage:

Inventory Coverage Mode (ASTRA_SCAN_INVENTORY_COVERAGE)

Controls the inventory scope for the scan — whether Astra should scan the entire known inventory or only newly discovered parts. Useful for large, continuously evolving applications.

Default:

ASTRA_SCAN_INVENTORY_COVERAGE="full"

Options:

Recommended Usage:

CI/CD Job Exit Strategy (ASTRA_JOB_EXIT_STRATEGY)

Define how your CI/CD pipeline should behave based on scan results:

ASTRA_JOB_EXIT_STRATEGY='always_pass'

    ASTRA_JOB_EXIT_STRATEGY='fail_when_vulnerable' 


ASTRA_JOB_EXIT_STRATEGY='wait_for_completion' 

For the fail_when_vulnerable and wait_for_completion modes, Astra enforces a soft limit to prevent CI/CD jobs from being held indefinitely. The default timeout is 10 minutes. If the scan does not complete in this timeframe, Astra stops checking for status updates and logs a message.

Configuring the Refetch Interval and Maximum Retries (ASTRA_JOB_EXIT_REFETCH_INTERVAL and ASTRA_JOB_EXIT_REFETCH_MAX_RETRIES)

For fail_when_vulnerable and wait_for_completion modes, Astra periodically checks the scan status before deciding on the next action in the pipeline. You can adjust the following environment variables:

# How often the CI/CD job should check for a status update
ASTRA_JOB_EXIT_REFETCH_INTERVAL=30

#How many times should we check for the status
ASTRA_JOB_EXIT_REFETCH_MAX_RETRIES=50

Example Calculation

If ASTRA_JOB_EXIT_REFETCH_INTERVAL=30 and ASTRA_JOB_EXIT_REFETCH_MAX_RETRIES=50, the pipeline will check for status 50 times with a 30-second interval, totaling 1500 seconds (25 minutes).

You can modify these values as needed to fit your pipeline execution time.

Defining the Exit Criterion (ASTRA_JOB_EXIT_CRITERION)

You can specify a condition for when the pipeline should fail, based on vulnerability severity:

ASTRA_JOB_EXIT_CRITERION="severityCount[\\\"high\\\"] > 0 or severityCount[\\\"critical\\\"] > 0"

This ensures the pipeline fails if any high or critical severity vulnerabilities are found.

Full Example Configuration

By following these steps, your CI/CD pipeline will automatically fail if vulnerabilities meeting the defined severity criteria are detected during the Astra scan.

ASTRA_JOB_EXIT_STRATEGY='fail_when_vulnerable'

ASTRA_JOB_EXIT_REFETCH_INTERVAL=10

ASTRA_JOB_EXIT_REFETCH_MAX_RETRIES=10

ASTRA_JOB_EXIT_CRITERION="severityCount[\\\"high\\\"] > 0 or severityCount[\\\"critical\\\"] > 0"

For further assistance or troubleshooting, please contact our support team.