Validate Custom JSON-LD Context
还没有人认领这个 Issue。
评估
调研方向
针对 sbom-output.spdx.json 运行 issue 中的 Verify 命令,然后将其与由 expand-custom-context.sh 生成的 expanded-sbom-output.spdx.json 进行比较。从 Verify 命令的 JSON-LD 上下文验证入手,确定应如何处理自定义上下文映射;完成的标准是原始文档无需外部扩展脚本即可通过验证。
由索引模型根据 Issue 内容生成。
描述
According to the Serialization Information section in the SPDX 3.0.1 spec serializing NamespaceMaps within the @context field for JSON-LD serializations is valid.
When serializing a physical SpdxDocument, any property of the logical element that can be natively represented within the chosen serialization format (e.g.,
@contextprefixes in JSON-LD instead of the namespaceMap) may utilize these native mechanisms. All remaining properties shall be serialized within the SpdxDocument element itself.
[...]
Additional namespace mappings may be defined within a separate object within the context.
The java spdx tools however do not currently support this.
Take for example the following document: sbom-output.spdx.json
export SPDX_TOOLS_VERSION=2.0.2
curl -sLO "https://github.com/spdx/tools-java/releases/download/v${SPDX_TOOLS_VERSION}/tools-java-${SPDX_TOOLS_VERSION}.zip"
unzip -j "tools-java-${SPDX_TOOLS_VERSION}.zip" "tools-java-${SPDX_TOOLS_VERSION}-jar-with-dependencies.jar"
java -jar "tools-java-${SPDX_TOOLS_VERSION}-jar-with-dependencies.jar" Verify "sbom-output.spdx.json"
The java tools fail with
This SPDX Document is not valid due to:
$.@context: must be the constant value 'https://spdx.org/rdf/3.0.1/spdx-context.jsonld'
even though the document should be valid.
An easy way to fix this would be to expand the custom context before processing the SPDX document.
See for example expand-custom-context.sh
./expand-custom-context.sh sbom-output.spdx.json
This small script expands the custom context and outputs expanded-sbom-output.spdx.json which successfully gets validated by the java tools.
java -jar "tools-java-${SPDX_TOOLS_VERSION}-jar-with-dependencies.jar" Verify "expanded-sbom-output.spdx.json"
This SPDX Document is valid.
It would be helpful if this behavior could be supported directly by the java-tools.
- 主要语言
- Java
- 星标
- 101
- 派生
- 46
- 平均合并
- 15 小时 57 分钟
- 30 天内合并 PR
- 10
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
spdx/tools-java 的其他 Issue
-
enhancement
难度 4/5 3-5 天 新手友好度 45/100
spdx/tools-java#331 · 1 个 reaction ·
-
bug spdx-2.3 validation
难度 4/5 3-5 天 新手友好度 55/100
spdx/tools-java#316 · 1 条评论 · 1 个 reaction ·
-
Release 2.0.8 未关闭
难度 4/5 3-5 天 新手友好度 20/100
spdx/tools-java#313 · 1 个 reaction ·
-
spdx-2.x spdx-3.x
难度 3/5 1-2 天 新手友好度 58/100
spdx/tools-java#290 · 2 条评论 ·
-
validation
难度 3/5 1-2 天 新手友好度 48/100
spdx/tools-java#287 · 1 条评论 · 1 个 reaction ·
相似的 Issue
-
documentation
难度 2/5 1-3 小时 新手友好度 65/100
inu-appcenter/memorIN-backend#288 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
-
frontend maui-pilot pilot-ask question
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
area/plugin
难度 2/5 1-3 小时 新手友好度 75/100
kestra-io/plugin-kestra#190 ·