云计算百科
云计算领域专业知识百科平台

scanoss-py 1.54.2 完整命令手册(2026年8月当前最新稳定版本)

目录

⚠️【致命错误复盘(我之前踩坑点)】

❌错误写法(会报 invalid choice: 'http://xxx')

✅私有化部署【标准正确模板】

一、顶层基础命令(全局)

所有子命令清单(1.54.2 稳定版)

二、核心命令:scan(源码扫描)

基础语法

高频参数

实用示例

1)私有化内网扫描,直接输出 HTML 报告(你需要的)

2)输出 JSON 原始结果,后续转报表

3)公网免费扫描(默认api.osskb.org,限流)

三、fingerprint /wfp 指纹生成(离线方案必备)

四、convert 格式转换(重点!很多人分开扫描 + 转 html)

五、dependencies 依赖解析

六、component 组件查询

七、环境变量方式(CI 流水线推荐,不用命令行明文密钥)

八、常见避坑清单

九、CI 流水线标准完整脚本示例(Anolis OS 可用)


⚠️【致命错误复盘(我之前踩坑点)】

❌错误写法(会报 invalid choice: 'http://xxx')

scanoss-py http://x.x.x.x:8083 scan .

原理:–apiurl、–key 属于 scan 子命令参数,必须放在 scan 后面,不能放在 scanoss-py 和 scan 中间!

✅私有化部署【标准正确模板】

scanoss-py scan –apiurl http://x.x.x.x:8083 –key YOUR_API_KEY -o result.json ./源码目录


一、顶层基础命令(全局)

# 查看版本(确认当前1.54.2)
scanoss-py -v
scanoss-py version

# 全局帮助
scanoss-py -h
# 查看某个子命令帮助(推荐)
scanoss-py scan -h

所有子命令清单(1.54.2 稳定版)

scan (sc) # 核心源码扫描【最常用】
fingerprint (fp,wfp) # 生成wfp指纹文件
dependencies (dep,dp) # 单独解析项目依赖(package.json/pom.xml等)
convert (cv) # 扫描结果格式互转(json→html/cyclonedx/spdx)
component (comp) # 查询组件信息
file_count (fc) # 统计目录文件数量
utils (ut) # 工具集

二、核心命令:scan(源码扫描)

基础语法

scanoss-py scan [OPTIONS] 源码路径

高频参数

参数说明
–apiurl URL 指定私有 Scanoss 服务地址(私有化必须加!)
–key API_KEY 私有服务 / 公有云密钥
-o, –output FILE 输出文件
-f, –format 输出格式:json/html/cyclonedx/spdx
–wfp file.wfp 直接扫描预先生成的指纹文件,不扫描源码
–dep pom.xml 附加依赖清单增强扫描
–exclude .git,node_modules 排除目录 / 文件,逗号分隔
–quiet 静默模式,只输出错误
–trace 开启详细调试日志
–timeout 300 请求超时(秒)
–proxy http://127.0.0.1:7890 代理

实用示例

1)私有化内网扫描,直接输出 HTML 报告(你需要的)

scanoss-py scan \\
–apiurl http://x.x.x.x:8083 \\
–key 你的密钥 \\
–exclude node_modules,.git,dist \\
-f html -o scan_result.html \\
./project_source

2)输出 JSON 原始结果,后续转报表

scanoss-py scan –apiurl http://x.x.x.x:8083 -o scan_raw.json ./code

3)公网免费扫描(默认api.osskb.org,限流)

scanoss-py scan -f html -o public_scan.html ./code

三、fingerprint /wfp 指纹生成(离线方案必备)

先本地生成指纹文件,再上传到服务端扫描,适合超大项目、CI 分批扫描

# 生成指纹文件
scanoss-py fingerprint ./code -o source.wfp

# 使用指纹文件扫描
scanoss-py scan –apiurl http://x.x.x.x:8083 –wfp source.wfp -o result.json

四、convert 格式转换(重点!很多人分开扫描 + 转 html)

如果扫描先输出 json,之后随时转换成 HTML、SBOM,不用重新扫描!

# json 转 html
scanoss-py convert scan_raw.json -f html -o report.html

# json 转 CycloneDX SBOM(合规审计常用)
scanoss-py convert scan_raw.json -f cyclonedx -o bom.xml

五、dependencies 依赖解析

单独提取项目包管理依赖(maven/npm/pip/go 等)

scanoss-py dependencies ./pom.xml -o dep.json

六、component 组件查询

通过 PURL 查询组件许可证、漏洞信息

scanoss-py component –purl "pkg:npm/lodash@4.17.21" –apiurl http://x.x.x.x:8083

七、环境变量方式(CI 流水线推荐,不用命令行明文密钥)

# Linux/Mac
export SCANOSS_API_URL=http://x.x.x.x:8083
export SCANOSS_API_KEY=xxx
scanoss-py scan -o result.html ./source

# Powershell
$env:SCANOSS_API_URL="http://x.x.x.x:8083"
$env:SCANOSS_API_KEY="xxx"

八、常见避坑清单

  • ❌ scanoss-py –apiurl xxx scan . ✅ scanoss-py scan –apiurl xxx . 参数必须放在子命令scan之后!这就是你 invalid choice 的根源!

  • HTML 报告只能通过 -f html 输出,或者使用 convert 转换 json 结果

  • 私有服务地址不要带后缀 /scan/direct,scanoss-py 会自动拼接接口路径 正确:http://x.x.x.x:8083 错误:http://x.x.x.x:8083/scan/direct

  • 遇到接口限流:优先使用【wfp 指纹分批扫描】方案

  • 九、CI 流水线标准完整脚本示例(Anolis OS 可用)

    SOURCE_PATH="./code"
    API_URL="http://x.x.x.x:8083"
    API_KEY="xxx"

    scanoss-py scan \\
    –apiurl ${API_URL} \\
    –key ${API_KEY} \\
    –exclude node_modules,.git,venv,build \\
    -f html \\
    -o scanoss_report.html \\
    ${SOURCE_PATH}

    赞(0)
    未经允许不得转载:网硕互联帮助中心 » scanoss-py 1.54.2 完整命令手册(2026年8月当前最新稳定版本)
    分享到: 更多 (0)

    评论 抢沙发

    评论前必须登录!