License 扫描
481 字约 2 分钟
License 扫描插件比较 Pull Request 的依赖变更,只报告本次新增的 License 风险, 并支持按 LicenseRisk 严重等级设置质量门禁——命中门禁时该检查失败。
功能特性
- 增量 License 扫描:只检查当前 PR 新增的 License 风险;
- 组件 License 识别:识别依赖组件的 License Expression;
- 风险门禁:支持按
low、medium、high阻断;
插件镜像
cnbcool/sca-license:latest参数说明
插件参数通过 settings 传递:
| 参数 | 说明 | 默认 |
|---|---|---|
failOnSeverity | 触发门禁的最低 License 风险等级,可选 low、medium、high;未配置时仅输出扫描结果,不启用门禁 | 无 |
在 CNB 中使用
.cnb.yml
main:
pull_request:
- stages:
- name: License 扫描
image: cnbcool/sca-license:latest
settings:
failOnSeverity: high以上配置会在 PR 新增 High License 风险时使检查失败。
只扫描不阻断
省略 failOnSeverity,即可输出新增 License 风险而不启用严重等级门禁:
.cnb.yml
main:
pull_request:
- stages:
- name: License 扫描
image: cnbcool/sca-license:latest输出说明
插件将新增 License 风险直接输出到 CI 日志:
service/pom.xml: HIGH GPL-3.0-only
component: example:library@2.0.0
license: GPL-3.0-only
message: component uses GPL-3.0-only
SCA gate failed: 1 new risk findings, 1 matched gate增量规则
- 组件版本变化但 License Expression 不变时,不会重复阻断;
- 新组件或新的 License Expression 会形成新增风险;
- Base 已存在的同一 License 风险不会在当前 PR 重复阻断。
退出码
| 退出码 | 说明 |
|---|---|
0 | 扫描完成,且新增 License 风险未命中门禁 |
1 | 新增 License 风险命中门禁 |
2 | 配置错误或扫描失败 |
下一步
- 插件总览 —— 三个插件的整体配置与门禁说明
- 开源组件漏洞扫描 —— 漏洞门禁与增量规则
- SBOM 生成(Delta) —— 组件变化清单