CI/CD Setup
Integrate PrismSec into your CI/CD pipeline to block insecure code from reaching production.
PrismSec integrates seamlessly into your CI/CD pipeline, running security scans on every pull request and commit. You can configure PrismSec to block merges if critical vulnerabilities are detected, ensuring that only secure code reaches production.
How CI/CD Integration Works
When PrismSec is integrated into your CI/CD pipeline:
- Trigger — A pull request or commit triggers your CI workflow
- Scan — PrismSec analyzes the changed files for vulnerabilities
- Status check — PrismSec posts a commit status (Pass/Fail) based on your configured severity threshold
- Block or allow — If the status is "Fail," the merge is blocked (if branch protection is enabled)
PrismSec scans run in parallel with your existing CI jobs (tests, linting, builds), so they don't slow down your pipeline.
GitHub Actions
PrismSec automatically posts commit statuses for pull requests in GitHub. To enforce blocking:
1. Enable Branch Protection
- Go to your repository Settings → Branches
- Add a branch protection rule for
main(or your default branch) - Enable Require status checks to pass before merging
- Select PrismSec from the list of required status checks
2. Optional: Run PrismSec Explicitly
If you want to run PrismSec as a workflow step (in addition to the automatic PR scans):
# .github/workflows/security.yml
name: Security Scan
on:
pull_request:
push:
branches: [main, develop]
jobs:
prismsec:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run PrismSec Scan
uses: prismsec/action@v1
with:
api_key: ${{ secrets.PRISMSEC_API_KEY }}
fail_on_severity: high # Fail if High or Critical findings3. Get an API Key
- Go to the PrismSec dashboard
- Navigate to Settings → API Keys
- Click Generate New Key and copy it
- In your GitHub repository, go to Settings → Secrets and variables → Actions
- Add a new secret named
PRISMSEC_API_KEYwith the copied key
The GitHub Action is optional if you're already using PrismSec's automatic PR scanning. The action provides more control over when scans run.
GitLab CI
Add a PrismSec job to your .gitlab-ci.yml:
# .gitlab-ci.yml
stages:
- test
- security
prismsec:
stage: security
image: prismsec/cli:latest
script:
- prismsec scan --api-key $PRISMSEC_API_KEY --fail-on high
only:
- merge_requests
- main
- develop
allow_failure: false # Block pipeline if scan failsSet the API Key
- Go to your GitLab project Settings → CI/CD → Variables
- Add a new variable:
- Key:
PRISMSEC_API_KEY - Value: Your API key from the PrismSec dashboard
- Flags: Check "Mask variable" and "Protect variable"
- Key:
Enforce Merge Blocking
- Go to Settings → Merge requests
- Enable Pipelines must succeed under merge checks
- PrismSec failures will now block merges
Bitbucket Pipelines
Add a PrismSec step to your bitbucket-pipelines.yml:
# bitbucket-pipelines.yml
pipelines:
pull-requests:
'**':
- step:
name: Security Scan
image: prismsec/cli:latest
script:
- prismsec scan --api-key $PRISMSEC_API_KEY --fail-on high
branches:
main:
- step:
name: Security Scan
image: prismsec/cli:latest
script:
- prismsec scan --api-key $PRISMSEC_API_KEY --fail-on highSet the API Key
- Go to Repository settings → Pipelines → Repository variables
- Add a new variable:
- Name:
PRISMSEC_API_KEY - Value: Your API key from the PrismSec dashboard
- Secured: Yes
- Name:
Configuring Severity Thresholds
You can configure when PrismSec fails the CI build:
Option 1: Config File
Add a severity threshold to prismsec.yml:
# prismsec.yml
severity_threshold: highOptions:
critical— Only fail on Critical findingshigh— Fail on Critical or High findingsmedium— Fail on Critical, High, or Medium findingslow— Fail on any finding
Option 2: CLI Flag
Pass the threshold as a flag:
prismsec scan --fail-on highOption 3: Branch-Specific Thresholds
Apply stricter thresholds to production branches:
# prismsec.yml
branches:
main:
severity_threshold: low # Strict: fail on any finding
block_on_findings: true
develop:
severity_threshold: high # Lenient: fail only on Critical/High
block_on_findings: falseHandling Scan Failures
When a scan fails in CI, you have three options:
1. Fix the Vulnerability
The recommended approach:
- Review the finding in the PrismSec dashboard or PR comment
- Fix the vulnerability (or merge an auto-fix PR)
- Re-run the CI pipeline — the scan will now pass
2. Ignore the Finding
If the finding is a false positive or accepted risk:
- Mark it as Ignored in the PrismSec dashboard (with justification)
- Re-run the CI pipeline — ignored findings do not fail the build
See Triage & Ignoring for details.
3. Bypass the Check (Emergency Only)
If you must merge urgently (e.g., hotfix for a production outage):
- Temporarily disable the required status check in branch protection settings
- Merge the PR
- Immediately re-enable the status check and create a follow-up PR to fix the vulnerability
Bypassing security checks should be rare and documented. Treat it as a security incident and remediate as soon as possible.
Scanning Frequency
PrismSec scans run:
- On every pull request — Automatically, when you connect your repository
- On push to protected branches — Optional, configure in CI/CD
- On a schedule — Optional, configure in the PrismSec dashboard (e.g., daily scans to catch newly disclosed CVEs)
Performance Considerations
PrismSec scans are fast:
- Average scan time: 30–60 seconds for most pull requests
- Parallel execution: Scans run concurrently with tests, linting, and builds
- Incremental analysis: Only changed files are scanned in PRs
For large monorepos or PRs with many changed files, scans may take 2-3 minutes but rarely exceed that.
Viewing Scan Results
Scan results appear in three places:
- Commit status — Pass/Fail indicator on the PR
- PR comments — Inline findings on specific lines of code
- PrismSec dashboard — Full findings list with filtering and search
Best Practices
- Fail on High and Critical — Use
severity_threshold: highto catch serious vulnerabilities without blocking on low-risk issues - Stricter for production branches — Apply
severity_threshold: lowtomainorproductionbranches - Automate fixes — Enable auto-fix PRs to reduce manual remediation work
- Monitor trends — Use the dashboard to track security improvements over time
Next Steps
- Integrate with Slack: Slack
- Understand severity levels: Severity & Risk Score
- Configure scan behavior: Configuring Scans