CI/CD Integration
CI/CD Integration
Overview
Pensar provides a CLI tool and API for integrating automated pentesting directly into your CI/CD pipeline. Run pentests on every commit or deployment to catch vulnerabilities before they reach production.
CI-triggered pentests consume credits from your workspace balance. See Billing & Usage for details on credit management and usage tracking.
Installation
Install the Pensar CI package globally:
Or add it as a dev dependency:
View the source code and additional examples on GitHub.
Configuration
Required Environment Variables
Optional Environment Variables
You can configure CI/CD integration directly from the Pensar Console. Navigate to Settings → Automation → CI/CD in your workspace for guided setup and one-click workflow creation.
CLI Usage
Run a Pentest
Options:
Examples:
Check Scan Status
Example:
CI/CD Examples
GitHub Actions
On Push
After Deployment
Run a pentest when commits are pushed to main branches:
GitLab CI
Add to your .gitlab-ci.yml:
Bitbucket Pipelines
Add to your bitbucket-pipelines.yml:
Exit Codes
By default, the CLI will exit with code 1 if any security issues are found. Use this to block deployments when vulnerabilities are detected.
API Reference
Dispatch Scan
Headers:
Authorization: Bearer <api_key>orx-api-key: <api_key>Content-Type: application/json
Request Body:
Provide a repository so the pentest is scoped to that repository’s
applications. Supply either repoId (GitHub’s numeric repository id — the
CLI auto-detects this from GITHUB_REPOSITORY_ID) or repositoryId (the
internal repository UUID). When neither is supplied the scan covers every
application in the workspace.
The repository must already be connected to the workspace. If it isn’t found,
the API responds 404; if it belongs to another workspace, 403; if it has
no discovered applications yet (run reconnaissance first), 422.
Response:
Get Scan Status
Headers:
Authorization: Bearer <api_key>orx-api-key: <api_key>
Response: