Validate Custom JSON-LD Context

Đang mở
#263 2 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
java
Lĩnh vực
cli, tooling

Hướng nghiên cứu

Chạy lệnh Verify từ issue đối với sbom-output.spdx.json, sau đó so sánh tệp này với expanded-sbom-output.spdx.json được tạo bởi expand-custom-context.sh. Bắt đầu từ bước xác thực ngữ cảnh JSON-LD của lệnh Verify và xác định cách xử lý các ánh xạ ngữ cảnh tùy chỉnh; được xem là hoàn tất khi tài liệu gốc được xác thực mà không cần đến tập lệnh mở rộng bên ngoài.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement

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., @context prefixes 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.

Ngôn ngữ chính
Java
Star
101
Fork
47
Merge trung bình
3 ngày 10 giờ
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của spdx/tools-java

Tất cả issue của spdx/tools-java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.