Skip to content

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
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pages/_meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default {
"oneleet-agent": "Oneleet Agent",
"guides": "Guides",
"penetration-testing": "Penetration Testing",
"code-security": "Code Security",
"support": {
"title": "Support",
"type": "page",
Expand Down
1 change: 1 addition & 0 deletions pages/code-security/_meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
104 changes: 104 additions & 0 deletions pages/code-security/ignore-rules.mdx
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}
```
52 changes: 52 additions & 0 deletions public/code-security/oneleetignore.schema.json
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"
}
},
"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"
}
},
"reason": {
"title": "Reason",
"description": "Optionally document why you've suppressed this class of issues.",
"type": "string"
}
},
"anyOf": [
{
"required": ["ruleIds"]
},
{
"required": ["pathPatterns"]
}
]
}
}
},
"required": ["version", "ignores"]
}