Skip to content

Commit 1616d1d

Browse files
doc: add --include-metadata option
fix #742
1 parent 0eb815e commit 1616d1d

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

website/reference/cli.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ ast-grep scan [OPTIONS] [PATHS]...
6262
| -r | --rule `<RULE_FILE>`| Scan the codebase with the single rule located at the path `RULE_FILE`.|
6363
| | --inline-rules `<RULE_TEXT>` | Scan the codebase with a rule defined by the provided `RULE_TEXT` |
6464
| | --filter `<REGEX>` |Scan the codebase with rules with ids matching `REGEX` |
65+
| | --include-metadata | Include rule metadata in the json output |
6566
| -j | --threads `<NUM>` | Set the approximate number of threads to use [default: heuristic]
6667
| -i | --interactive|Start interactive edit session.|
6768
| | --color `<WHEN>`|Controls output color [default: auto] [possible values: auto, always, ansi, never]|

website/reference/cli/scan.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ Scan the codebase with rules with ids matching REGEX.
4040

4141
This flags conflicts with --rule. It is useful to scan with a subset of rules from a large set of rule definitions within a project.
4242

43+
### `--include-metadata`
44+
45+
Include rule [metadata](/reference/yaml.html#metadata) in the json output.
46+
47+
This flags requires --json mode. Default is false.
48+
4349
## Input Options
4450

4551
### `--no-ignore <FILE_TYPE>`

website/reference/yaml.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,15 @@ url: 'https://ast-grep.github.io/catalog/python/#migrate-openai-sdk'
261261
* type: `HashMap<String, String>`
262262
* required: false
263263

264-
Extra information for the rule.
264+
Extra information for the rule. This section can include custom data for external program to consume. For example, CVE/OWASP information can be added here for security research.
265+
266+
ast-grep will output `metadata` with matches in [`--json`](/reference/cli/scan.html#json-style) mode if [`--include-metadata`](/reference/cli/scan.html#include-metadata) is on.
265267

266268
Example:
267269

268270
```yaml
269271
metadata:
270272
extraField: 'Extra information for other usages'
273+
complexData:
274+
key: value
271275
```

0 commit comments

Comments
 (0)