|
1 | | -# Orb Starter Kit [](https://circleci.com/gh/CircleCI-Public/orb-starter-kit) [](https://discuss.circleci.com/c/ecosystem/orbs) |
| 1 | +# Nightfall DLP CircleCI Orb |
| 2 | + |
| 3 | +## [Nightfall](https://nightfall.ai) DLP Orb: A code review tool that protects you from committing sensitive information to your repositories. |
2 | 4 |
|
3 | | -The Orb Starter Kit is a bash utility that makes creating your first orb a breeze! |
| 5 | +The Nightfall DLP CircleCI Orb scans your code commits for sensitive information - like credentials & secrets, PII, credit card numbers & more - and posts review comments to your code hosting service automatically. The Nightfall DLP CircleCI Orb is intended to be used as a part of your CI to simplify the development process, improve your security, and ensure you never accidentally leak secrets or other sensitive information via an accidental commit. |
4 | 6 |
|
5 | | -**What are orbs?** |
6 | | -Orbs are reusable [commands](https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-commands), [executors](https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-executors), and [jobs](https://circleci.com/docs/2.0/reusing-config/#jobs-defined-in-an-orb) (as well as [usage examples](https://github.com/CircleCI-Public/config-preview-sdk/blob/v2.1/docs/usage-examples.md))—snippets of CircleCI configuration—that can be shared across teams and projects. See [CircleCI Orbs](https://circleci.com/orbs), [Explore Orbs](https://circleci.com/orbs/registry), [Creating Orbs](https://circleci.com/docs/2.0/creating-orbs), and [Using Orbs](https://circleci.com/docs/2.0/using-orbs) for further information. |
| 7 | +## Example |
| 8 | +Here's an example of the Nightfall DLP CircleCI Orb providing feedback on a Pull Request: |
7 | 9 |
|
8 | | -## What is in this kit? |
| 10 | + |
9 | 11 |
|
10 | | -This kit includes three main components: |
| 12 | +Here's the CircleCI log output from the same run: |
11 | 13 |
|
12 | | - * **Orb init script.** |
13 | | - * The Orb init script will auytomatically generate for you a new GitHub repository with all of the source code needed to get started developing your own orb, complete with automation pipeline |
14 | | -* **Hello World template.** |
15 | | - * Within the [/src](https://github.com/CircleCI-Public/orb-starter-kit/tree/master/src) folder you can find find the destructured source of a simple "Hello World" orb. You can simply copy this code and begin hacking, or initialize it with our orb init script. |
16 | | -* **Automated CI/CD Pipeline.** |
17 | | - * After you run the init script you will also be automatically given a development pipeline to test and update your orb on CircleCI. |
18 | | - * Automated Semver release process |
19 | | - * Automated Integration Testing |
20 | | - * No need to use CLI commands. |
| 14 | + |
21 | 15 |
|
| 16 | +The orb runs when configured as a job in your CircleCI config: |
22 | 17 |
|
| 18 | +```yaml |
| 19 | +version: 2.1 |
23 | 20 |
|
24 | | -### Prerequisites |
25 | | - |
26 | | -Before getting started you will need the the following things: |
27 | | -1. A CircleCI [account](https://circleci.com/signup/). |
28 | | -2. Git installed and configured locally. |
29 | | -3. A CircleCI [Personal API Token](https://circleci.com/docs/2.0/managing-api-tokens/#creating-a-personal-api-token) (Must be Org admin to claim a namespace and publish production Orbs) |
30 | | - |
| 21 | +orbs: |
| 22 | + nightfall_code_scanner: nightfall/[email protected] |
31 | 23 |
|
| 24 | +workflows: |
| 25 | + test_scanner: |
| 26 | + jobs: |
| 27 | + - nightfall_code_scanner/scan: |
| 28 | + event_before: << pipeline.git.base_revision >> |
| 29 | +``` |
32 | 30 |
|
33 | 31 | ## Usage |
34 | | - |
35 | | -### Getting started |
36 | | -**1.** Clone this repo into a new directory with the name of your orb: |
37 | | - |
38 | | -``` |
39 | | -git clone [email protected]:CircleCI-Public/orb-starter-kit.git My-Orb-Name |
| 32 | +**1. Get a Nightfall API key.** |
| 33 | +
|
| 34 | +The Nightfall DLP Orb is powered by the Nightfall DLP API. Learn more and request access to a free API key **[here](https://nightfall.ai/api/)**. Alternatively, you can email **[[email protected]](mailto:[email protected])** to provision a free account. |
| 35 | +
|
| 36 | +**2. Set up config file to specify detectors.** |
| 37 | +
|
| 38 | +- Place a `.nightfalldlp/` directory within the root of your target repository, and inside it a `config.json` file in which you can configure your detectors (see `Detectors` section below for more information on Detectors) |
| 39 | +- See `Additional Configuration` section for more advanced configuration options |
| 40 | +- Below is a sample `.nightfalldlp/config.json` file: |
| 41 | + |
| 42 | +```json |
| 43 | +{ |
| 44 | + "detectors": [ |
| 45 | + "CREDIT_CARD_NUMBER", |
| 46 | + "PHONE_NUMBER", |
| 47 | + "API_KEY", |
| 48 | + "CRYPTOGRAPHIC_KEY", |
| 49 | + "RANDOMLY_GENERATED_TOKEN", |
| 50 | + "US_SOCIAL_SECURITY_NUMBER", |
| 51 | + "AMERICAN_BANKERS_CUSIP_ID", |
| 52 | + "US_BANK_ROUTING_MICR", |
| 53 | + "ICD9_CODE", |
| 54 | + "ICD10_CODE", |
| 55 | + "US_DRIVERS_LICENSE_NUMBER", |
| 56 | + "US_PASSPORT", |
| 57 | + "EMAIL_ADDRESS", |
| 58 | + "IP_ADDRESS" |
| 59 | + ] |
| 60 | +} |
40 | 61 | ``` |
| 62 | +**3. Set up a few environment variables.** |
| 63 | +These variables should be made available to the Nightfall DLP orb by adding them to `Environment Variables` under `Project Settings` on the CircleCI console. Instructions [here](https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project): |
41 | 64 |
|
42 | | -**2.** Create a new repository on GitHub with the same name. https://github.com/new |
| 65 | +- `NIGHTFALL_API_KEY` |
| 66 | + - Get a free Nightfall DLP API Key by registering for an account with the [Nightfall API](https://nightfall.ai/api) |
43 | 67 |
|
44 | | -**3.** Run the `orb-init.sh` script to begin. |
| 68 | +- `GITHUB_TOKEN` (Optional) |
| 69 | + - Create a [Github Personal Access Token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) with the `repo` scope |
| 70 | + - This token is used to authenticate to Github to write Comments/Annotations to your Pull Requests and Pushes |
| 71 | + - If not included, we will only log the finding messages to the CircleCI Workflow UI |
45 | 72 |
|
46 | | -[](https://asciinema.org/a/oSc3M8uJri4zfo616wOVbh1lO) |
| 73 | +- `EVENT_BEFORE` |
| 74 | + - Make sure to include `event_before` as an argument with the value `<< pipeline.git.base_revision >>` in your circle config as shown in the example above |
| 75 | + - This allows the orb to scan against the diff between the current commit sha and the most recent commit sha to trigger a workflow on push events |
47 | 76 |
|
48 | | -The Orb Init script will automate the following tasks: |
| 77 | +- `BASE_BRANCH` (Optional) |
| 78 | + - In the case that you want to scan your Pull Requests against a branch separate from `master`, include the `base_branch` argument with your branch's name in your circle config |
| 79 | + - This will allow you to scan the diff between your Pull Request and `base_branch` |
49 | 80 |
|
50 | | -> * Install and update the CircleCI CLI |
51 | | -> * Request a CircleCI API token if none is currently set. |
52 | | -> * Check to ensure git is installed and authenticated with GitHub. |
53 | | -> * Connect your repository with the blank repo created in step 2. |
54 | | -> * Create and switch to an "Alpha" branch |
55 | | -> * Walk through creating a new orb via the CircleCI CLI |
56 | | -> * Allow you to optionally enable advanced features. |
57 | | -> * Create your customized config file |
58 | | -> * Clean up - The script will remove itself from the repo for the next commit. |
59 | | -> * Commit alpha branch with changes to GitHub. |
| 81 | +**4. Allow Uncertified Orbs** |
| 82 | +To use our orb, make sure to allow uncertified orbs in Organization Settings. Instructions are [here](https://circleci.com/docs/2.0/orbs-faq/#using-uncertified-orbs). At this time, CircleCI still requires allowing un-certified orbs to use orbs developed by CircleCI Partners. |
| 83 | +## Supported GitHub Events |
| 84 | +The Nightfall DLP CircleCI Orb can run in a Circle Workflow triggered by the following events: |
60 | 85 |
|
61 | | -Your orb will now be available at `<your namespace>/<your orb>@dev:Alpha` |
| 86 | +- `PULL_REQUEST` |
| 87 | +- `PUSH` |
62 | 88 |
|
63 | | -The script will end by giving you a link to the running automated pipeline on your CircleCI account which will be building a "Hello World" orb. |
| 89 | +The Nightfall DLP CircleCI Orb does not currently support forked repositories due to potential permissioning issues that may occur. |
64 | 90 |
|
| 91 | +## Detectors |
| 92 | +Each detector represents a type of information you want to search for in your code scans. A few examples of detectors Nightfall supports includes: |
65 | 93 |
|
| 94 | +- `API_KEY`: A freeform string used for user verification to access online program functions. |
| 95 | +- `CREDIT_CARD_NUMBER`: A 12 to 19 digit number used for payments and other monetary transactions. |
| 96 | +- `CRYPTOGRAPHIC_KEY`: A string of characters used by an encryption algorithm to generate seemingly random tokens. |
| 97 | +- `RANDOMLY_GENERATED_TOKEN`: A pseudo-random string generated by an encryption algorithm. This detector is more general than the API_KEY detector. |
| 98 | +- `US_SOCIAL_SECURITY_NUMBER`: A 9 digit numeric string often used as a unique identification number for United States citizens and residents. |
| 99 | +- Many more... |
66 | 100 |
|
67 | | -**4.** Begin editing. |
68 | | -> You may now edit the contents of the `/src` folder and commit your changes to the `Alpha` branch or any non-master branch. |
| 101 | +**Find a full list of supported detectors in the Nightfall API Documentation, after creating your account (per the instructions above).** |
69 | 102 |
|
70 | | -**5.** Build and test! |
71 | | -> All commits to non-master branches will automatically result in the creation of a development orb under that branch. The automated pipeline will then run your integration tests against that newly created dev orb. |
| 103 | +## Additional Configuration |
72 | 104 |
|
73 | | -**6.** Publish! |
74 | | -> Once ready to produce a new production version of your orb, you may merge your branch into the master branch to trigger the automated release process. |
75 | | -> |
76 | | ->**Recommended:** If you have enabled the `fail-if-semver-not-indicated` option, your commit message when merging to master _MUST_ include `[semver:patch|minor|major|skip]` to designate the release type. |
77 | | -> |
78 | | -> You will need to manually publish the production version of your Orb for the initial version before the automated pipeline can update your production version later on. This is not needed on subsequent pushes. |
| 105 | +You can add additional fields to your config to ignore tokens and files from being flagged, as well as specify which files to exclusively scan. |
79 | 106 |
|
80 | | -Once the orb is complete, you will have two new Green workflows in your CircleCI account. The first one is for the initial setup and the second one will have produced a development version of your orb which contains a sample Command, Executor, and Job. |
| 107 | +### Token Exclusion |
81 | 108 |
|
| 109 | +To ignore specific tokens from being flagged, you can add the `tokenExclusionList` field to your nightfalldlp config. The `tokenExclusionList` is a list of strings, and it mutes findings that match any of the given regex patterns. |
82 | 110 |
|
83 | | -### Writing your orb |
84 | | -This orb provides a basic directory/file structure for a decomposed orb (where commands, jobs, examples, and executors each live in their own YAML file). Create each of your commands, jobs, examples, and executors within the requisite folders in the `src` directory. |
| 111 | +Here's an example use case: |
85 | 112 |
|
86 | | -Following are some resources to help you build and test your orb: |
| 113 | +```tokenExclusionList: ["NF-gGpblN9cXW2ENcDBapUNaw3bPZMgcABs", "^127\\."]``` |
87 | 114 |
|
88 | | -- [Intro to authoring orbs](https://circleci.com/docs/2.0/orb-author-intro/#section=configuration) |
89 | | -- [Orb Best Practices](https://circleci.com/docs/2.0/orbs-best-practices/#orb-best-practices-guidelines) |
90 | | -- [How to make an easy and valuable open source contribution with CircleCI orbs](https://circleci.com/blog/how-to-make-an-easy-and-valuable-open-source-contribution-with-circleci-orbs/) |
| 115 | +In the example above, findings with the API token `NF-gGpblN9cXW2ENcDBapUNaw3bPZMgcABs` as well as local IP addresses starting with `127.` would not be reported. For more information on how we match tokens, take a look at [regexp](https://golang.org/pkg/regexp/). |
91 | 116 |
|
| 117 | +### File Inclusion & Exclusion |
92 | 118 |
|
93 | | -### Permissions |
| 119 | +To omit files from being scanned, you can add the `fileExclusionList` field to your nightfalldlp config. In addition, to only scan specific files, add the `fileInclusionList` to the config. |
94 | 120 |
|
95 | | -Explanation of all permissions required for the script. |
96 | | - |
97 | | -* **sudo** - The CircleCI CLI Update command will request sudo permissions to update. |
98 | | - |
99 | | -### Preview |
| 121 | +Here's an example use case: |
| 122 | +``` |
| 123 | + fileExclusionList: ["*/tests/*"], |
| 124 | + fileInclusionList: ["*.go", "*.json"] |
| 125 | +``` |
| 126 | +In the example, we are ignoring all file paths with a `tests` subdirectory, and only scanning on `go` and `json` files. |
| 127 | +Note: we are using [gobwas/glob](https://github.com/gobwas/glob) to match file path patterns. Unlike the token regex matching, file paths must be completely matched by the given pattern. e.g. If `tests` is a subdirectory, it will not be matched by `tests/*`, which is only a partial match. |
100 | 128 |
|
101 | | -<details> |
102 | | -<Summary>Preview "Hello-World" Orb produced by this repo by default.</Summary> |
| 129 | +## [Nightfall DLP API](https://nightfall.ai/api) |
| 130 | +With the Nightfall API, you can inspect & classify your data, wherever it lives. Programmatically get structured results from Nightfall's deep learning-based detectors for things like credit card numbers, API keys, and more. Scan data easily in your own third-party apps, internal apps, and data silos. Leverage these classifications in your own workflows - for example, saving them to a data warehouse or pushing them to a SIEM. Request access & learn more **[here](https://nightfall.ai/api/)**. |
103 | 131 |
|
104 | | -```yaml |
105 | | -commands: |
106 | | - greet: |
107 | | - description: | |
108 | | - Replace this text with a description for this command. # What will this command do? # Descriptions should be short, simple, and clear. |
109 | | - parameters: |
110 | | - greeting: |
111 | | - default: Hello |
112 | | - description: Select a proper greeting |
113 | | - type: string |
114 | | - steps: |
115 | | - - run: |
116 | | - command: echo << parameters.greeting >> world |
117 | | - name: Hello World |
118 | | -description: | |
119 | | - Sample orb description # What will your orb allow users to do? # Descriptions should be short, simple, and clear. |
120 | | -examples: |
121 | | - example: |
122 | | - description: | |
123 | | - Sample example description. # What will this example document? # Descriptions should be short, simple, and clear. |
124 | | - usage: |
125 | | - jobs: |
126 | | - build: |
127 | | - machine: true |
128 | | - steps: |
129 | | - - foo/hello: |
130 | | - username: Anna |
131 | | - orbs: |
132 | | - |
133 | | - version: 2.1 |
134 | | -executors: |
135 | | - default: |
136 | | - description: | |
137 | | - This is a sample executor using Docker and Node. # What is this executor? # Descriptions should be short, simple, and clear. |
138 | | - docker: |
139 | | - - image: circleci/node:<<parameters.tag>> |
140 | | - parameters: |
141 | | - tag: |
142 | | - default: latest |
143 | | - description: | |
144 | | - Pick a specific circleci/node image variant: https://hub.docker.com/r/circleci/node/tags |
145 | | - type: string |
146 | | -jobs: |
147 | | - hello: |
148 | | - description: | |
149 | | - # What will this job do? # Descriptions should be short, simple, and clear. |
150 | | - executor: default |
151 | | - parameters: |
152 | | - greeting: |
153 | | - default: Hello |
154 | | - description: Select a proper greeting |
155 | | - type: string |
156 | | - steps: |
157 | | - - greet: |
158 | | - greeting: << parameters.greeting >> |
159 | | -orbs: |
160 | | - |
161 | | -version: 2.1 |
162 | | -``` |
| 132 | +## Versioning |
| 133 | +The Nightfall DLP CircleCI Orb issues releases using semantic versioning. |
163 | 134 |
|
164 | | -</details> |
| 135 | +## Support |
| 136 | +For help, please email us at **[[email protected]](mailto:[email protected])**. |
0 commit comments