|
| 1 | +# Rusty Hogs |
| 2 | +A suite of secret scanners built in Rust for performance. Based on [TruffleHog](https://github.com/dxa4481/truffleHog) |
| 3 | +which is written in Python. |
| 4 | + |
| 5 | +Ankamali Hog: Scan for secrets in a Google Doc |
| 6 | + |
| 7 | +Berkshire Hog: Scan for secrets in an S3 bucket |
| 8 | + |
| 9 | +Choctaw Hog: Scan for secrets in a Git repository |
| 10 | + |
| 11 | +* [Rusty Hogs](#rusty-hogs) |
| 12 | +* [How to run](#how-to-run) |
| 13 | +* [How to build](#how-to-build) |
| 14 | +* [Anakamali Hog Usage](#anakamali-hog-usage) |
| 15 | +* [Berkshire Hog (CLI) Usage](#berkshire-hog-cli-usage) |
| 16 | +* [Berkshire Hog (Lambda) Usage](#berkshire-hog-lambda-usage) |
| 17 | +* [Choctaw Hog Usage](#choctaw-hog-usage) |
| 18 | +* [Open Source License](#open-source-license) |
| 19 | +* [Support](#support) |
| 20 | +* [Community](#community) |
| 21 | +* [Issues / Enhancement Requests](#issues--enhancement-requests) |
| 22 | +* [Contributing](#contributing) |
| 23 | +* [Feature Roadmap](#feature-roadmap) |
| 24 | +* [Performance comparison](#performance-comparison) |
| 25 | +* [What does the name mean?](#what-does-the-name-mean) |
| 26 | + |
| 27 | +## How to run |
| 28 | +Download and unzip the [latest ZIP](https://source.datanerd.us/security/rusty_hogs/releases/download/0.4.1/release.zip) |
| 29 | +on the releases tab, then you can run each binary with `-h` to see the usage. |
| 30 | + |
| 31 | +```shell script |
| 32 | +wget https://source.datanerd.us/security/rusty_hogs/releases/download/0.4.1/release.zip |
| 33 | +unzip release.zip |
| 34 | +cd darwin_releases |
| 35 | +./choctaw_hog -h |
| 36 | +``` |
| 37 | + |
| 38 | +## How to build |
| 39 | +Ensure you have [Rust](https://www.rust-lang.org/learn/get-started) installed and on your path. |
| 40 | + |
| 41 | +Perform a git clone, then run `cargo build --release`. The binaries will be located in `target/release` |
| 42 | + |
| 43 | +To cross-compile Berkshire Hog for the AWS Lambda environment, first install |
| 44 | +[cross](https://github.com/rust-embedded/cross). Then run the following commands and upload berkshire_lambda.zip: |
| 45 | +```shell script |
| 46 | +cross build --release --target x86_64-unknown-linux-musl |
| 47 | +cp target/x86_64-unknown-linux-musl/release/berkshire_hog bootstrap |
| 48 | +zip -j berkshire_lambda.zip bootstrap |
| 49 | +``` |
| 50 | + |
| 51 | +## Anakamali Hog Usage |
| 52 | +``` |
| 53 | +USAGE: |
| 54 | + ankamali_hog [FLAGS] [OPTIONS] <GDRIVEID> |
| 55 | +
|
| 56 | +FLAGS: |
| 57 | + --caseinsensitive Sets the case insensitive flag for all regexes |
| 58 | + --entropy Enables entropy scanning |
| 59 | + --prettyprint Output the JSON in human readable format |
| 60 | + -v, --verbose Sets the level of debugging information |
| 61 | + -h, --help Prints help information |
| 62 | + -V, --version Prints version information |
| 63 | +
|
| 64 | +OPTIONS: |
| 65 | + -o, --outputfile <OUTPUT> Sets the path to write the scanner results to (stdout by default) |
| 66 | + --regex <REGEX> Sets a custom regex JSON file |
| 67 | +
|
| 68 | +ARGS: |
| 69 | + <GDRIVEID> The ID of the google drive file you want to scan |
| 70 | +``` |
| 71 | + |
| 72 | +## Berkshire Hog (CLI) Usage |
| 73 | +``` |
| 74 | +USAGE: |
| 75 | + berkshire_hog [FLAGS] [OPTIONS] <S3URI> <S3REGION> |
| 76 | +
|
| 77 | +FLAGS: |
| 78 | + --caseinsensitive Sets the case insensitive flag for all regexes |
| 79 | + --entropy Enables entropy scanning |
| 80 | + --prettyprint Output the JSON in human readable format |
| 81 | + -r, --recursive Will recursively scan files under the prefix. |
| 82 | + -v, --verbose Sets the level of debugging information |
| 83 | + -h, --help Prints help information |
| 84 | + -V, --version Prints version information |
| 85 | +
|
| 86 | +OPTIONS: |
| 87 | + -o, --outputfile <OUTPUT> Sets the path to write the scanner results to (stdout by default) |
| 88 | + --profile <PROFILE> When using a configuration file, use a non-default profile |
| 89 | + --regex <REGEX> Sets a custom regex JSON file |
| 90 | +
|
| 91 | +ARGS: |
| 92 | + <S3URI> The location of a S3 bucket and optional prefix or filename to scan. This must be written in the form |
| 93 | + s3://mybucket[/prefix_or_file] |
| 94 | + <S3REGION> Sets the region of the S3 bucket to scan. |
| 95 | +``` |
| 96 | + |
| 97 | + |
| 98 | +## Berkshire Hog (Lambda) Usage |
| 99 | +Berkshire Hog is currently designed to be used as a Lambda function. It was written with this overall data-flow |
| 100 | +in mind: |
| 101 | +<pre> |
| 102 | + ┌───────────┐ ┌───────┐ ┌────────────────┐ ┌────────────┐ |
| 103 | + │ S3 Bucket │ ┌────────┐ │ │ │ Berkshire Hog │ │ S3 Bucket │ |
| 104 | + │ (input) ─┼─┤S3 Event├──▶│ SQS │────▶│ (Lambda) │────▶│ (output) │ |
| 105 | + │ │ └────────┘ │ │ │ │ │ │ |
| 106 | + └───────────┘ └───────┘ └────────────────┘ └────────────┘ |
| 107 | +</pre> |
| 108 | + |
| 109 | +In order to run this you will need to setup the following things: |
| 110 | +1) The input bucket must be configured to send an "event" to SQS for each PUSH/PUT event |
| 111 | +2) The SQS topic must be setup to accept events from S3, including IAM permissions. |
| 112 | +3) Berkshire hog must be running with IAM access to SQS and S3. |
| 113 | + |
| 114 | +## Choctaw Hog Usage |
| 115 | +``` |
| 116 | +USAGE: |
| 117 | + choctaw_hog [FLAGS] [OPTIONS] <GITPATH> |
| 118 | +
|
| 119 | +FLAGS: |
| 120 | + --caseinsensitive Sets the case insensitive flag for all regexes |
| 121 | + --entropy Enables entropy scanning |
| 122 | + --prettyprint Output the JSON in human readable format |
| 123 | + -v, --verbose Sets the level of debugging information |
| 124 | + -h, --help Prints help information |
| 125 | + -V, --version Prints version information |
| 126 | +
|
| 127 | +OPTIONS: |
| 128 | + -o, --outputfile <OUTPUT> Sets the path to write the scanner results to (stdout by default) |
| 129 | + --regex <REGEX> Sets a custom regex JSON file, defaults to ./trufflehog_rules.json |
| 130 | + --since_commit <SINCECOMMIT> Filters commits based on date committed (branch agnostic) |
| 131 | + --sshkeypath <SSHKEYPATH> Takes a path to a private SSH key for git authentication, defaults to ssh-agent |
| 132 | + --sshkeyphrase <SSHKEYPHRASE> Takes a passphrase to a private SSH key for git authentication, defaults to |
| 133 | + none |
| 134 | +
|
| 135 | +ARGS: |
| 136 | + <GITPATH> Sets the path (or URL) of the Git repo to scan. SSH links must include username (git@) |
| 137 | +``` |
| 138 | + |
| 139 | +## Open Source License |
| 140 | + |
| 141 | +This project is distributed under the [Apache 2 license](LICENSE). |
| 142 | + |
| 143 | +## Support |
| 144 | + |
| 145 | +New Relic has open-sourced this project. This project is provided AS-IS WITHOUT WARRANTY OR SUPPORT, although you can report issues and contribute to the project here on GitHub. |
| 146 | + |
| 147 | +_Please do not report issues with this software to New Relic Global Technical Support._ |
| 148 | + |
| 149 | +## Community |
| 150 | + |
| 151 | +New Relic hosts and moderates an online forum where customers can interact with New Relic employees as well as other customers to get help and share best practices. Like all official New Relic open source projects, there's a related Community topic in the New Relic Explorer's Hub. You can find this project's topic/threads here: |
| 152 | + |
| 153 | +TODO: Create topic in discuss.newrelic.com and put the link here. |
| 154 | + |
| 155 | +## Issues / Enhancement Requests |
| 156 | + |
| 157 | +Issues and enhancement requests can be submitted in the [Issues tab of this repository](../../issues). Please search for and review the existing open issues before submitting a new issue. |
| 158 | + |
| 159 | +## Contributing |
| 160 | + |
| 161 | +Contributions are welcome (and if you submit a Enhancement Request, expect to be invited to contribute it yourself :grin:). Please review our [Contributors Guide](CONTRIBUTING.md). |
| 162 | + |
| 163 | +Keep in mind that when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. If you'd like to execute our corporate CLA, or if you have any questions, please drop us an email at opensource@newrelic.com. |
| 164 | + |
| 165 | + |
| 166 | +## Feature Roadmap |
| 167 | +- 1.0: Initial open-source release |
| 168 | + - [x] Refactor git-agnostic code into a reusable library |
| 169 | + - [x] Implement logging correctly |
| 170 | + - [x] Prep for New Relic Homebrew release |
| 171 | + - [x] Prep for New Relic GitHub release |
| 172 | + - [x] Implement licensing |
| 173 | + - [x] Clear with New Relic open source committee |
| 174 | + - [x] Finish initial implementation of Ankamali Hog and Berkshire Hog CLI |
| 175 | + - [ ] Finish New Relic Open Source checklist |
| 176 | + - [ ] Unit tests |
| 177 | + - [ ] Prep for crates.io release |
| 178 | + - [ ] Flatten original Git repo |
| 179 | + |
| 180 | +- 1.1: Enterprise features |
| 181 | + - [ ] Support config files (instead of command line args) |
| 182 | + - [ ] Save state between scans, remember and filter "false positives" |
| 183 | + - [ ] Multi-threading |
| 184 | + - [ ] Better context detection and false positive filtering (GitHound, machine learning) |
| 185 | + - [ ] Support for other modes of use for Berkshire Hog (CLI, lambda without SQS) |
| 186 | + - [ ] Use Rusoto instead of s3-rust |
| 187 | + |
| 188 | +- 1.2: Integration with larger scripts and UIs |
| 189 | + - [ ] Support Github API for larger org management |
| 190 | + - [ ] Scan all repos for a list of users |
| 191 | + - [ ] Scan all repos in an org |
| 192 | + - [ ] Generate a web-report or web-interface. Support "save state" generation from UI. |
| 193 | + - [ ] Agent/manager model |
| 194 | + - [ ] Scheduler process (blocked by save state support) |
| 195 | + |
| 196 | + |
| 197 | +## Performance comparison |
| 198 | +Using this repo as a test: `git clone git@github.com:NathanRomike/dictionary-builder.git` |
| 199 | + |
| 200 | +I ran trufflehog 50 times and saw it take 81 seconds... |
| 201 | +``` |
| 202 | +time ( repeat 50 { trufflehog --rules trufflehog_rules.json --regex --entropy=False ../dictionary-builder/ }) |
| 203 | +
|
| 204 | +37.67s user 40.56s system 95% cpu 1:21.88 total |
| 205 | +``` |
| 206 | + |
| 207 | +Then I ran Choctaw Hog 50 times and saw it take 49 seconds... |
| 208 | +``` |
| 209 | +time ( repeat 50 { target/release/choctaw_hog ../dictionary-builder }) |
| 210 | +
|
| 211 | +46.28s user 1.94s system 98% cpu 48.749 total |
| 212 | +``` |
| 213 | + |
| 214 | +## What does the name mean? |
| 215 | +TruffleHog is considered the de-facto standard / original secret scanner. I have been |
| 216 | +building a suite of secret scanning tools for various platforms based on TruffleHog |
| 217 | +and needed a naming scheme, so I started at the top of Wikipedia's |
| 218 | +[list of pig breeds](https://en.wikipedia.org/wiki/List_of_pig_breeds). |
| 219 | +Thus each tool name is a breed of pig starting at A and working up. |
| 220 | + |
0 commit comments