RedFlag
RedFlag uses AI to identify high-risk code changes. Run it in batch mode for release candidate testing or in CI pipelines to flag PRs and add reviewers. RedFlag's flexible configuration makes it valuable for any team.
Install / Use
/learn @Addepar/RedFlagREADME
<a name="readme-top"></a>
<div align="center"> <a href="https://github.com/Addepar/RedFlag"> <img src="https://raw.githubusercontent.com/Addepar/RedFlag/main/docs/images/RedFlag-Logo.png" alt="RedFlag" height="100"> </a>[![Python][python-shield]][python-url] [![Contributors][contributors-shield]][contributors-url] [![MIT License][license-shield]][license-url] [![LinkedIn][linkedin-shield]][linkedin-url]<br /> [![Forks][forks-shield]][forks-url] [![Stargazers][stars-shield]][stars-url] [![Issues][issues-shield]][issues-url]
RedFlag leverages AI to determine high-risk code changes. Run it in batch mode to scope manual security testing of release candidates, or run it in your CI pipelines to flag PRs and add the appropriate reviewers. Despite being a security tool, RedFlag can be leveraged for almost any team as it's configuration makes it infinitely flexible. <br /> <a href="https://addepar.com/blog/introducing-redflag-using-ai-to-scale-addepar-s-offensive-security-team"><strong>Read the blog post »</strong></a> <br /> <br /> <a href="https://opensource.addepar.com/RedFlag/">View Sample Report</a> · <a href="https://github.com/Addepar/RedFlag/issues/new?labels=bug&template=bug-report---.md">Report Bug</a> · <a href="https://github.com/Addepar/RedFlag/issues/new?labels=enhancement&template=feature-request---.md">Request Feature</a>
</div> <details> <summary><strong>Table of Contents</strong></summary> <ul> <li><a href="#batch-mode">Batch Mode</a></li> <li><a href="#ci-mode">CI Mode</a></li> <li><a href="#evaluation-mode">Evaluation Mode</a></li> <li><a href="#advanced-configuration">Advanced Configuration</a></li> <li><a href="#contributing">Contributing</a></li> <li><a href="#license">License</a></li> <li><a href="#contact">Contact</a></li> </ul> </details>Batch Mode
RedFlag is able to analyze a large number of commits in a single run. These commits can be specified using commit hashes, branch names, or tags. This is useful for scoping manual security testing of logical groups of code, such as release candidates.
Workflow
![Batch Workflow][batch-workflow]
Getting Started
Installation
Use a Virtual Environment
-
Create a virtual environment:
python -m venv redflag-venv source redflag-venv/bin/activate -
Install RedFlag:
pip install addepar-redflag
Alternatively, if you'd like to use Poetry, clone the repo and use poetry install and then poetry run redflag.
Setup Credentials
Credentials can be set using:
- Environment variables
- A
.envfile - CLI parameters
- Configuration file (This is not recommended for security reasons!)
AWS Credentials
RedFlag uses Boto3-Compatible Credentials using Profiles or Env Vars.
Ensure that your AWS IAM policy has InvokeModel and InvokeModelWithResponseStream permissions to Amazon Bedrock.
Lastly, make sure you've requested the necessary Claude models!
GitHub PAT
Use a Personal Access Token with
repo permissions. Set the token as an environment variable:
export RF_GITHUB_TOKEN=your-token-here
Jira API Token (Optional)
First, set a Jira URL (https://your-org.atlassian.net) in the configuration file (jira_url), as a CLI parameter (--jira-url), or as an environment variable (RF_JIRA_URL).
Then create a Jira API Token and set it as an environment variable:
export RF_JIRA_USER=your-username-here
export RF_JIRA_TOKEN=your-token-here
Slack Token (Optional)
- Create a Slack App
- Request required scopes
- Install and authorize the App
- Add environment variables or configuration entries when running RedFlag
export RF_SLACK_TOKEN=xoxb-slack-token-here
export RF_SLACK_CHANNEL=C0123456789
Don't forget to invite the bot to the channel to avoid a channel_not_found error.
Usage
Note: When running RedFlag, output messages will indicate it is retrieving and evaluating commits from Pull Requests (PRs). Typically, commits are made via PRs if you have branch protection or repository rulesets in place. Consequently, once a PR is squashed and merged, it appears as a single commit in the target branch. The terminology used may vary depending on how you choose to run RedFlag, as you can specify
--fromand--tocommit SHAs or branches.
Here are some examples on how to run RedFlag in batch mode:
# Using branch names:
redflag --repo YourOrg/SomeRepo --from main --to dev
# Using commit hashes:
redflag --repo YouOrg/SomeRepo --from a1b2c3 --to d4e5f6
# With a custom configuration file:
redflag --config custom-config.yml
Report Output
By default, RedFlag produces an HTML report that can be opened in a browser.
<a href="https://opensource.addepar.com/RedFlag/"> <img src="https://raw.githubusercontent.com/Addepar/RedFlag/main/docs/images/Report-Animated.gif"> </a> <p align="right">(<a href="#readme-top">back to top</a>)</p>CI Mode
RedFlag can be run in CI pipelines to flag PRs and add the appropriate reviewers. This mode uses GitHub Actions to run RedFlag on every PR and post a comment if the PR requires a review. Additionally, CI Mode is best suited for Slack alerting.
[![CI Mode][docs-ci-mode]][docs-ci-mode-url]
<p align="right">(<a href="#readme-top">back to top</a>)</p>Evaluation Mode
RedFlag can be run in evaluation mode to evaluate the performance of the AI model using your own custom dataset. This mode is useful for understanding how the model and prompts perform on your codebase and aids in security risk evaluation.
[![Evaluation Mode][docs-eval-mode]][docs-eval-mode-url]
<p align="right">(<a href="#readme-top">back to top</a>)</p>Advanced Configuration
Order of Precedence
- CLI Parameters
- Environment Variables
- Configuration File
- Default Values
On each execution, RedFlag will load the configuration in the order of precedence above and then output a table that shows the final configuration and where each parameter was set.
Configuration Options and Defaults
The following table shows configuration options for each parameter:
General Settings
| Parameter | CLI Param | Env Var | Config File | Default | |---------------------------------------------------------------------------------------|-----------|---------|-------------|---------| | Configuration File | --config | - | - | - | | Repository | --repo | RF_REPO | repo | - | | Branch/Commit From | --from | RF_FROM | from | - | | Branch/Commit To | --to | RF_TO | to | - |
Integration Settings
| Parameter | CLI Param | Env Var | Config File | Default |
|-------------------------------------------------------------------------------------------------------------------------------------|------------------|-------------------|---------------|---------|
| GitHub Token | --github-token | RF_GITHUB_TOKEN | github_token | - |
| Jira URL | --jira-url | RF_JIRA_URL | jira.url | - |
| Jira Username | --jira-user | RF_JIRA_USER | jira.user | - |
| Jira Token | --jira-token | RF_JIRA_TOKEN | jira.token | - |
| Slack Token | --slack-token | RF_SLACK_TOKEN | slack.token | - |
| Slack Channel (ID) | --slack-channel | RF_SLACK_CHANNEL | slack.channel | - |
| Slack Message Headline | --slack-headline | RF_SLACK_HEADLINE | slack.headline | - |
LLM Settings
| Parameter | CLI Param | Env Var | Config File | Default
Related Skills
healthcheck
346.8kHost security hardening and risk-tolerance configuration for OpenClaw deployments
node-connect
346.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
prose
346.8kOpenProse VM skill pack. Activate on any `prose` command, .prose files, or OpenProse mentions; orchestrates multi-agent workflows.
frontend-design
107.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
