Skip to content

Commit 7628bb0

Browse files
Merge pull request #344 from XmirrorSecurity/codex/docs-config-ignore-patterns
docs: document config ignore patterns
2 parents 3ce28bc + d67bf02 commit 7628bb0

6 files changed

Lines changed: 115 additions & 6 deletions

File tree

.github/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ English|[中文](../README.md)
2626
- [Method 4: Build from source](#method-4-build-from-source)
2727
- [Use OpenSCA](#use-opensca)
2828
- [Parameters](#parameters)
29+
- [Ignore Paths in Configuration](#ignore-paths-in-configuration)
2930
- [Report Formats](#report-formats)
3031
- [Sample](#sample)
3132
- [Scan \& Report via Docker Container](#scan--report-via-docker-container)
@@ -149,6 +150,22 @@ If no path of configuration file is set, the following ones will be checked:
149150
2. `opensca_config.json` under the user directory
150151
3. `config.json` under `opensca-cli` directory
151152
153+
### Ignore Paths in Configuration
154+
155+
Use `optional.ignore` in the configuration file to skip files or directories during scanning. OpenSCA only reads ignore rules from the current configuration file and does not automatically load the project's `.gitignore`. The rules are compatible with common `.gitignore` syntax, including directory matches, wildcards, and `!` negation.
156+
157+
```json
158+
{
159+
"optional": {
160+
"ignore": [
161+
"JarCollection/",
162+
"*.jar",
163+
"!libs/keep.jar"
164+
]
165+
}
166+
}
167+
```
168+
152169
From v3.0.0, `url` has been put in the configuration file. The default set goes to our cloud vulnerability database. Other online database in accordance with our database structure can also be set through configuration file.
153170

154171
Using previous versions to connect the cloud databse will still need the setting of `url`, which could be done via both CMD and configuration file. Example: `-url https://opensca.xmirror.cn`

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- [方式 4: 从源码构建](#方式-4-从源码构建)
2424
- [使用说明](#使用说明)
2525
- [参数说明](#参数说明)
26+
- [配置文件忽略路径](#配置文件忽略路径)
2627
- [报告格式](#报告格式)
2728
- [使用样例](#使用样例)
2829
- [漏洞库文件格式](#漏洞库文件格式)
@@ -153,6 +154,22 @@ v3.0.2开始,OpenSCA-cli可以通过proj参数向OpenSCA SaaS同步检出结
153154
2. 用户目录下的`opensca_config.json`
154155
3. `opensca-cli`目录下的`config.json`
155156

157+
### 配置文件忽略路径
158+
159+
可在配置文件的 `optional.ignore` 中设置需要跳过的文件或目录。该字段只读取当前配置文件中的规则,不会自动读取项目中的 `.gitignore` 文件;规则语法兼容常用 `.gitignore` 写法,包括目录匹配、通配符和 `!` 反选。
160+
161+
```json
162+
{
163+
"optional": {
164+
"ignore": [
165+
"JarCollection/",
166+
"*.jar",
167+
"!libs/keep.jar"
168+
]
169+
}
170+
}
171+
```
172+
156173
### 报告格式
157174

158175
`out` 参数支持范围如下:

docs/README-zh-CN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
- [生成报告](./User_Guide/Generating_Reports/)
1414
- [SBOM](./User_Guide/Generating_Reports/SBOM-zh_CN.md)
1515
- [检测报告](./User_Guide/Generating_Reports/Reports-zh_CN.md)
16-
- [参数说明](./User_Guide/Parameter_Explanations-zh_CN.md)
16+
- [配置与参数说明](./User_Guide/Configuration-and-Parameters-zh_CN.md)
1717
- [Docker](./User_Guide/Docker-zh_CN.md)
1818
- [集成配置](./Integrations/)
1919
- [IDE 插件](./Integrations/IDE_Plugins-zh_CN.md)
2020
- [CI/CD](./Integrations/CICD-zh_CN.md)
2121
- 开发者指南
2222
- [贡献指南](./Contributing_Guideline-v1.0-zh_CN.md)
23-
- [代码规范](./Code_Standards-zh_CN.md)
24-
- [常见问题](./Troubleshooting-zh_CN.md)
23+
- [代码规范](./Code_Standard-zh_CN.md)
24+
- [常见问题](./Troubleshooting-zh_CN.md)

docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
- [Generating Reports](./User_Guide/Generating_Reports/)
1414
- [Software Bill of Materials (SBOM)](./User_Guide/Generating_Reports/SBOM.md)
1515
- [Detection Reports](./User_Guide/Generating_Reports/Reports.md)
16-
- [Parameter Explanations](./User_Guide/Parameter_Explanations.md)
16+
- [Configuration and Parameters](./User_Guide/Configuration-and-Parameters.md)
1717
- [Docker](./User_Guide/Docker.md)
1818
- [Integrations](./Integrations/)
1919
- [IDE Plugins](./Integrations/IDE_Plugins.md)
2020
- [CI/CD](./Integrations/CICD.md)
2121
- Developer Guide
2222
- [Contribution Guide](./Contributing_Guideline-v1.0.md)
2323
- [Code Standard](./Code_Standard.md)
24-
- [Troubleshooting](./Troubleshooting.md)
24+
- [Troubleshooting](./Troubleshooting.md)

docs/User_Guide/Configuration-and-Parameters-zh_CN.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- [命令行参数](#命令行参数)
44
- [配置文件说明](#配置文件说明)
5+
- [忽略路径配置示例](#忽略路径配置示例)
56
- [漏洞数据库配置示例](#漏洞数据库配置示例)
67
- [漏洞数据库字段说明](#漏洞数据库字段说明)
78

@@ -35,6 +36,7 @@
3536
- `dev`: `Boolean` 是否保留开发组件, 默认为 `true`
3637
- `tls`: `Boolean` 开启 TLS 证书验证, 默认为 `false`
3738
- `proxy`: `String` 代理地址, 默认为空
39+
- `ignore`: `Array<String>` 扫描时忽略的路径规则, 默认为空。仅读取当前配置文件中的规则, 不会自动读取项目 `.gitignore`; 规则语法兼容常用 `.gitignore` 写法, 包括目录匹配、通配符和 `!` 反选
3840
- `repo`: `Object` 组件仓库配置
3941
- `maven`: `Array` maven 镜像/私服仓库配置
4042
- `url`: `String` 仓库地址
@@ -60,6 +62,24 @@
6062
- `dsn`: `String` 数据库连接字符串
6163
- `table`: `String` 数据表名
6264

65+
# 忽略路径配置示例
66+
67+
如需跳过测试依赖、临时目录或特定压缩包, 可在 `optional.ignore` 中配置忽略规则:
68+
69+
```json
70+
{
71+
"optional": {
72+
"ignore": [
73+
"JarCollection/",
74+
"*.jar",
75+
"!libs/keep.jar"
76+
]
77+
}
78+
}
79+
```
80+
81+
上例会跳过 `JarCollection/` 目录及所有 `.jar` 文件, 但保留 `libs/keep.jar`。该配置只影响 OpenSCA 扫描过程, 不会修改项目文件。
82+
6383
# 漏洞数据库配置示例
6484

6585
```json
@@ -120,4 +140,4 @@
120140
>
121141
> 也可以区间和集合混用: `(0,b)||{c,d}||[e,)`代表`x<b``x=c``x=d``x>=e`
122142
- `security_level_id` 可选值: `1` `2` `3` `4`, 分别对应严重、高危、中危、低危
123-
- `exploit_level_id` 可选值 `0`:不可利用 `1`:可利用
143+
- `exploit_level_id` 可选值 `0`:不可利用 `1`:可利用
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
[Back to Contents](/docs/README.md) | [简体中文](./Configuration-and-Parameters-zh_CN.md)
2+
3+
- [Command-line Parameters](#command-line-parameters)
4+
- [Configuration File](#configuration-file)
5+
- [Ignore Path Configuration](#ignore-path-configuration)
6+
7+
# Command-line Parameters
8+
9+
| Parameter | Description | Example |
10+
| --------- | ----------- | ------- |
11+
| `config` | Set the configuration file path | `-config config.json` |
12+
| `path` | Set the target path. HTTP(S), FTP, and file paths are supported | `-path ./foo` |
13+
| `out` | Set report output paths. File types are detected by suffix | `-out out.json,out.html` |
14+
| `log` | Set the log file path | `-log my_log.txt` |
15+
| `token` | Cloud service token | `-token xxx` |
16+
| `proj` | SaaS project token | `-proj xxx` |
17+
| `version` | Print version information | `-version` |
18+
| `help` | Print help information | `-help` |
19+
20+
# Configuration File
21+
22+
The configuration file uses JSON syntax and supports the following top-level fields:
23+
24+
- `path`: `String` target path. HTTP(S), FTP, and file paths are supported.
25+
- `out`: `String` report output paths. Supported suffixes include html/json/xml/csv/sqlite/cdx/spdx/swid/dsdx.
26+
- `optional`: `Object` optional scanning settings.
27+
- `ui`: `Boolean` enable the interactive UI. Default: `false`.
28+
- `dedup`: `Boolean` deduplicate identical components and merge paths. Default: `false`.
29+
- `dir`: `Boolean` scan directories only and skip archives. Default: `false`.
30+
- `vuln`: `Boolean` keep only vulnerable components. Default: `false`.
31+
- `progress`: `Boolean` show the progress bar. Default: `true`.
32+
- `dev`: `Boolean` keep development dependencies. Default: `true`.
33+
- `tls`: `Boolean` enable TLS certificate verification. Default: `false`.
34+
- `proxy`: `String` HTTP proxy address. Default: empty.
35+
- `ignore`: `Array<String>` path rules ignored during scanning. Default: empty. OpenSCA only reads these rules from the current configuration file and does not automatically load the project's `.gitignore`. The syntax is compatible with common `.gitignore` rules, including directory matches, wildcards, and `!` negation.
36+
- `repo`: `Object` component repository settings for Maven, npm, and Composer.
37+
- `origin`: `Object` vulnerability database settings.
38+
39+
# Ignore Path Configuration
40+
41+
Use `optional.ignore` to skip test dependencies, temporary directories, or specific archives:
42+
43+
```json
44+
{
45+
"optional": {
46+
"ignore": [
47+
"JarCollection/",
48+
"*.jar",
49+
"!libs/keep.jar"
50+
]
51+
}
52+
}
53+
```
54+
55+
The example above skips `JarCollection/` and all `.jar` files, but keeps `libs/keep.jar`. Ignore rules only affect OpenSCA scanning and do not modify project files.

0 commit comments

Comments
 (0)