A tool to analyze the compatibility of licenses in a project.
Project description
compliance_license_compatibility
介绍
开源许可证兼容性分析工具,基于结构化的许可证信息和具体场景的依赖行为与构建设置,对目标中引入的开源许可证进行兼容性分析。
尽管我们会尽力确保该工具的准确性和可靠性,但本项目的检查结果不构成任何法律建议。使用者应自行审查和判断,以确定所采取的行动是否符合法律法规以及相关许可证的规定。
注意:本项目当前仍处于早期版本,相关结果的准确性未进行验证,且迭代过程中各模块接口将会发生较大变化。
安装教程
- 确保已经安装
python 3.11^ - clone 仓库
- 进入仓库根目录
pip install .
如果安装过 lict 版本,请先卸载旧版
使用说明
确保工具安装后,终端输入指令 liscopelens --help
usage: liscopelens [-h] [-c CONFIG] {sbom,cpp} ...
部件兼容性分析工具
positional arguments:
{sbom,cpp}
sbom Software Bill of Materials (SBOM) parser, this parser only support for OH sbom format.
cpp This parser is used to parse the C/C++ repository and provide an include dependency graph
for subsequent operations
options:
-h, --help show this help message and exit
-c CONFIG, --config CONFIG
配置文件路径
分析代码仓库的兼容性(请确保存在gn工具或者gn解析文件)
- 获取 OpenHarmoy 源码
- 安装 OpenHarmony 编译构建工具执行
./build.sh --product-name {设备形态} --gn-flags="--ide=json" --gn-flags="--json-file-name=out.json" - 确保在源码根目录下具有
OpenHarmony/out/{设备形态}/out.json存在 - 使用 Scancode 扫描 OpenHarmony 许可证
- 执行 liscopelens 进行兼容性扫描
liscopelens cpp --gn_file OpenHarmony/out/{设备形态}/out.json --scancode-file path/to/scancode-res.json --output ./output
- 查看
output/results.json或则借助审查工具
其他参数可以,查看帮助 liscopelens cpp -h,解释如下:
usage: liscopelens cpp [-h] (--gn_tool GN_TOOL | --gn_file GN_FILE)
(--scancode-file SCANCODE_FILE | --scancode-dir SCANCODE_DIR) [--rm-ref-lang] [--save-kg]
[--ignore-unk] [--out-gml OUT_GML] [--echo] [--out-echo OUT_ECHO]
options:
-h, --help show this help message and exit
--gn_tool GN_TOOL the path of the gn tool in executable form
--gn_file GN_FILE the path of the gn deps graph output file
--scancode-file SCANCODE_FILE
The path of the scancode output in json format file
--scancode-dir SCANCODE_DIR
The path of the directory that contain json files
--rm-ref-lang Automatically remove scancode ref prefix and language suffix from spdx ids
--save-kg Save new knowledge graph after infer parse
--ignore-unk Ignore unknown licenses
--out-gml OUT_GML The output path of the graph
--echo Echo the final result of compatibility checking
--out-echo OUT_ECHO The output path of the echo result
参数列表
| 参数 | 类型 | 说明 | 是否必须 |
|---|---|---|---|
| cpp | bool | 指明检测C/C++代码仓库 | 是 |
| --gn_tool | str | GN 工具的可执行文件路径 | 是 |
| --gn_file | str | GN 依赖图输出文件路径 | 是 |
| --scancode-file | str | Scancode 输出的 JSON 格式文件路径 | 是 |
| --scancode-dir | str | 包含 JSON 文件的目录路径 | 是 |
| --rm-ref-lang | bool | 自动移除 Scancode 引用前缀和语言后缀 | 否 |
| --save-kg | bool | 在解析后保存新的知识图谱 | 否 |
| --ignore-unk | bool | 忽略未知的许可证 | 否 |
| --out-gml | str | 图谱的输出路径 | 否 |
| --echo | bool | 回显兼容性检查的最终结果 | 否 |
| --out-echo | str | 回显结果的输出路径 | 否 |
gn依赖图格式
{
"build_settings": {
"build_dir": "//out/hispark_taurus/ipcamera_hispark_taurus/",
"default_toolchain": "//build/lite/toolchain:linux_x86_64_ohos_clang",
"gen_input_files": [
"//.gn",
"//vendor/hisilicon/hispark_taurus/hdf_config/BUILD.gn",
"//vendor/hisilicon/hispark_taurus/hdf_config/hdf_test/BUILD.gn"
],
"root_path": "/home/dragon/oh"
},
"targets": {
"//applications/sample/camera/cameraApp:cameraApp_hap": {
"all_dependent_configs": [
"//third_party/musl/scripts/build_lite:sysroot_flags"
],
"deps": [
"//applications/sample/camera/cameraApp:cameraApp",
"//developtools/packing_tool:packing_tool",
"//third_party/musl:sysroot_lite"
],
"metadata": {
},
"outputs": [
"//out/hispark_taurus/ipcamera_hispark_taurus/obj/applications/sample/camera/cameraApp/cameraApp_hap_build_log.txt"
],
"public": "*",
"script": "//build/lite/hap_pack.py",
"testonly": false,
"toolchain": "//build/lite/toolchain:linux_x86_64_ohos_clang",
"type": "action",
"visibility": [
"*"
]
},
"//foundation/arkui/ace_engine_lite/frameworks/src/core/stylemgr/test/unittest:stylemgr_unittest": {
"all_dependent_configs": [ "//third_party/musl/scripts/build_lite:sysroot_flags" ],
"deps": [ "//foundation/arkui/ace_engine_lite/frameworks/src/core/stylemgr/test/unittest:js_frameworks_test_condition_arbitrator", "//foundation/arkui/ace_engine_lite/frameworks/src/core/stylemgr/test/unittest:js_frameworks_test_link_queue", "//foundation/arkui/ace_engine_lite/frameworks/src/core/stylemgr/test/unittest:js_frameworks_test_link_stack", "//foundation/arkui/ace_engine_lite/frameworks/src/core/stylemgr/test/unittest:js_frameworks_test_stylemgr", "//foundation/arkui/ace_engine_lite/frameworks/src/core/stylemgr/test/unittest:js_frameworks_test_stylemgr_media_query" ],
"metadata": {
},
"public": "*",
"testonly": false,
"toolchain": "//build/lite/toolchain:linux_x86_64_ohos_clang",
"type": "group",
"visibility": [ "*" ]
}
}
}
已知问题
poetry install | add无响应或者报错提示包括Failed to unlock the collection.
export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
审查结果
执行完成后审查冲突结果(请确保传入输出位置参数 liscopelens <command> ... --output path/to/output_dir)
liscopelens query /path/to/output_dir
参与贡献
参见设计文档
结果复现
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file liscopelens-0.2.7.tar.gz.
File metadata
- Download URL: liscopelens-0.2.7.tar.gz
- Upload date:
- Size: 88.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.13.7 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15d4c163be7004b1eb53f1249711593458ee42cf9ac6165befd83cd19b612571
|
|
| MD5 |
f6be73870471cac4fbc88be55d31f40a
|
|
| BLAKE2b-256 |
b087be9c1472c636c98c93c337154d9dace02b2ab987577655585b5ab3dbcc4d
|
File details
Details for the file liscopelens-0.2.7-py3-none-any.whl.
File metadata
- Download URL: liscopelens-0.2.7-py3-none-any.whl
- Upload date:
- Size: 154.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.13.7 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7788e4c628f3aa84d13b60af5cc9566922b2140b823a5f4cebdce51b3923306
|
|
| MD5 |
b5471bcd715d352227e02432f9c8bf2b
|
|
| BLAKE2b-256 |
5e78206188219188faa45fafc6b3bc52d3bc799e5a5a2f2e484709c143600f93
|