-
Notifications
You must be signed in to change notification settings - Fork 0
Docs and JSON schema for ignore rules dotfiles #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ian-oneleet
wants to merge
2
commits into
main
Choose a base branch
from
ian/code-security-ignore-dotfiles
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+175
−0
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
--- | ||
title: Ignore rules | ||
--- | ||
|
||
# Ignore rules | ||
|
||
You may want to suppress "noisy," low-value Code Security findings. These may be findings you have consistently resolved as "False Positive" (not actual security issues) or "Accepted Risk" (genuine issues, but low severity and not worth fixing). | ||
|
||
To do so, you can add ignore rules for issues or files. Your ignore rules will automatically suppress future findings that match the rule. If you add ignore rules, please let us know why! We want to keep improving our Code Security product and boost signal-to-noise for all of our customers. | ||
|
||
A word of caution: since ignore rules may hide genuine future issues, we suggest minimizing their number and scope. However, you have the final say. | ||
|
||
## Dotfile ignore rules | ||
|
||
You can suppress issues in a single repository by adding an ignore rules dotfile. There are three formats to choose from: JSON (**recommended**), YAML, or .gitignore style. | ||
|
||
When Code Security scans your repository, it looks for ignore rules in the following files **at the root level**: | ||
|
||
- **.oneleetignore.json** | ||
- **.oneleetignore.yaml** or **.oneleetignore.yml** | ||
- **.oneleetignore** | ||
|
||
If multiple dotfiles are present, Code Security will OR together the rules they define. | ||
|
||
### .oneleetignore.json | ||
|
||
We recommend this JSON format because it's both simple and feature-complete. | ||
|
||
Start from the following template: | ||
|
||
```json | ||
{ | ||
"$schema": "https://docs.oneleet.com/code-security/oneleetignore.schema.json", | ||
"version": 1, | ||
"ignores": [ | ||
<your-ignore-rules> | ||
] | ||
} | ||
``` | ||
|
||
If you use VSCode or Cursor, enable the setting [`json.schemaDownload.enable`](https://code.visualstudio.com/docs/languages/json#_offline-mode) and you should be able to code complete to victory. | ||
|
||
For example, the following rule ignores two issues for `.js` files under the `/examples` directory: | ||
|
||
```json | ||
{ | ||
"$schema": "https://docs.oneleet.com/code-security/oneleetignore.schema.json", | ||
"version": 1, | ||
"ignores": [ | ||
{ | ||
"ruleIds": [ | ||
"javascript.language.eval.dynamic-code", | ||
"javascript.react.dangerouslysetinnerhtml" | ||
], | ||
"pathPatterns": ["/examples/**/*.js"], | ||
"reason": "Example code only" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
At least one of `ruleIds` and `pathPatterns` is required. The optional reason message (`"Example code only"`) documents why you've suppressed this class of findings. | ||
|
||
### .oneleetignore.yaml | ||
|
||
The YAML format is the same as the JSON format, but with YAML syntax. Start from the following template: | ||
|
||
```yaml | ||
$schema: https://docs.oneleet.com/code-security/oneleetignore.schema.json | ||
version: 1 | ||
ignores: | ||
- <your-ignore-rule> | ||
- <your-ignore-rule> | ||
- ... | ||
``` | ||
|
||
Here's the JSON example translated to YAML: | ||
|
||
```yaml | ||
$schema: https://docs.oneleet.com/code-security/oneleetignore.schema.json | ||
version: 1 | ||
ignores: | ||
- ruleIds: | ||
- javascript.language.eval.dynamic-code | ||
- javascript.react.dangerouslysetinnerhtml | ||
pathPatterns: | ||
- /examples/**/*.js | ||
reason: Example code only | ||
``` | ||
|
||
### .oneleetignore | ||
|
||
This follows the [.gitignore format](https://git-scm.com/docs/gitignore). Unlike .gitignore, this file must be at the root of the repository. | ||
|
||
This format is a blunt instrument. Files matching the glob patterns will be exempt from **all** `ruleIds`, and `reason` messages are not supported. If you need more granularity, consider using the JSON or YAML format instead. | ||
|
||
```sh | ||
README.md | ||
*.txt | ||
|
||
# Comment | ||
dir/ | ||
/.github/**/*.{yml,yaml} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"$comment": "See https://docs.oneleet.com/code-security/ignore-rules", | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"title": "Oneleet Code Security ignore rules", | ||
"type": "object", | ||
"properties": { | ||
"version": { | ||
"title": "Schema version", | ||
"const": 1 | ||
}, | ||
"ignores": { | ||
"title": "Ignore rules", | ||
"description": "List of ignore rules, which will be OR'd together.", | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"ruleIds": { | ||
"title": "Issue identifiers", | ||
"description": "List of issue identifiers (SARIF \"ruleId\"s) to ignore. If not set, all issues are ignored.", | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
}, | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"pathPatterns": { | ||
"title": "Path patterns", | ||
"description": "List of glob patterns for file paths to ignore. If not set, the ignore applies to all files in the repository.", | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
}, | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"reason": { | ||
"title": "Reason", | ||
"description": "Optionally document why you've suppressed this class of issues.", | ||
"type": "string" | ||
} | ||
}, | ||
"anyOf": [ | ||
{ | ||
"required": ["ruleIds"] | ||
}, | ||
{ | ||
"required": ["pathPatterns"] | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"required": ["version", "ignores"] | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.