A collection of Python scripts to help you interact with the Contrast Security API and automate common tasks.
- Python 3.x (latest version recommended)
- Contrast Security account with API access
- Git
-
Clone the repository
git clone https://github.com/Contrast-Security-OSS/CSR-Helpful-Scripts.git cd CSR-Helpful-Scripts -
Install dependencies
pip install -r requirements.txt
-
Set up your credentials
Create a
.credsfile in the root directory using the provided template:cp template.creds .creds chmod 600 .creds
.credsstores credentials in plaintext.chmod 600restricts read access to your user account only.Edit
.credsand fill in your Contrast Security credentials:CONTRAST_URL=https://your-contrast-instance.com/Contrast ORG_ID=your-organization-id USERNAME=your-username API_KEY=your-api-key SERVICE_KEY=your-service-key APP_ID=your-app-id⚠️ Important: Never commit the.credsfile to version control. It's already included in.gitignore.
-
Navigate to the script directory:
cd script-folder-name -
Run the script:
python script-name.py
-
Enter credentials:
- If you have a
.credsfile configured, simply press Enter when prompted to use the saved credentials - Otherwise, manually enter your credentials when prompted
- If you have a
| Script | Description |
|---|---|
app-add-label |
Bulk add or remove tags from applications |
correlate-routes-to-vulns |
Determine if vulnerabilities still exist on routes |
distribute-parent-app-rbac-to-children |
Distribute parent application RBAC to child applications |
get-licensed-apps |
Get all licensed applications and their server information |
get-licensed-servers |
Get all licensed servers |
get-scan-data |
Retrieve scan data for SAST projects |
inventory-windows-webapps |
Inventory Windows web applications |
policy-add-to-all-orgs |
Add policies to all organizations |
reporting |
Generate various reports (languages, vulnerabilities, protect vs assess) |
scan-add-label |
Add labels to SAST scan projects |
toggle-server-protect |
Toggle server protect license |
vulnerabilities-by-business-unit |
Get vulnerabilities grouped by business unit |
vulns-and-prompts |
Get vulnerability and prompt details |
📖 Each script directory contains its own
README.mdwith detailed usage instructions.
If you discover any bugs or have feature requests:
- Open an issue in this repository with details about the bug or feature
- Contact your CSA (Customer Success Architect) during your weekly/biweekly calls
- Submit a Pull Request if you've fixed a bug or added a feature
- Never commit credentials to version control
- Keep your
.credsfile secure and private (runchmod 600 .credsafter creating it) - Regularly rotate your API keys and service keys
- Keep your Python dependencies up to date:
pip install --upgrade -r requirements.txt
These scripts produce CSV and JSON exports that often contain customer data, including application names, vulnerability details, server hostnames, user emails, and organization metadata.
Default classification. Treat all exports as confidential customer data unless explicitly cleared otherwise.
Storage.
- Store exports only on encrypted disks.
- Do not commit exports to source control.
.gitignorecovers the common output filenames but the broad*.csvrule can be overridden, double checkgit statusbefore committing. - Do not upload exports to consumer file-sharing tools, public pastebins, or unapproved AI tools. NDA obligations cover any third-party processing of customer data.
Retention.
- Delete exports once the analysis they were generated for is complete.
- Macro backup tools such as Time Machine can capture exports to long-term storage. Consider excluding the working directory from backup, or running scripts from a path your backup policy excludes.
Sharing.
- Share exports only with personnel who have a need-to-know on the engagement and who are covered by the relevant NDA.
- When sharing, prefer access-controlled platforms (e.g. a customer-specific shared folder) over email attachments.
See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
For support, please contact your Contrast Security Customer Success Architect.
Note: These scripts are provided as-is for use by Contrast Security customers and partners. Always test scripts in a non-production environment first.