Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

CycloneDX output: metadata.properties[].value emits JSON array instead of string

Đang mở Phù hợp với người mới
#5,349 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

@0Cymantek0 đang làm issue này rồi.

Từ ngày 11/10/2026.

  • #5354 của @0Cymantek0 — đang mở
  • #5356 của @0Cymantek0 — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
62/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện lỗi với lệnh --cyclonedx trong issue, sau đó chạy script kiểm tra Python để liệt kê các property có giá trị không phải chuỗi. Tìm trong mã xuất CycloneDX chỗ property scancode:options được tạo từ danh sách các tùy chọn. Xong khi mọi metadata.properties[].value đều là chuỗi và script kiểm tra không in ra gì. Nội dung payload không cho biết nên nối bằng dấu cách, dấu phẩy hay mã hóa JSON, vì vậy hãy xác nhận lựa chọn đó trước khi chỉnh sửa.

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

Mô tả

Describe the bug

When using --cyclonedx output, ScanCode produces metadata.properties[].value as a JSON array instead of a string. The CycloneDX specification (versions 1.4, 1.5, and 1.6) defines properties[].value as type: string.

This causes downstream tools like cyclonedx-cli merge to crash:

Unhandled exception: System.Text.Json.JsonException:
  The JSON value could not be converted to System.String.
  Path: $.metadata.properties[1].value
  ---> System.InvalidOperationException:
    Cannot get the value of a token type 'StartArray' as a string.
Example output (simplified)
{
  "metadata": {
    "properties": [
      {
        "name": "scancode:version",
        "value": "33.0.0"
      },
      {
        "name": "scancode:options",
        "value": ["--package", "--license", "--copyright", "--strip-root"]
      }
    ]
  }
}

The second property has value as an array ["--package", "--license", "--copyright", "--strip-root"] instead of a string like "--package --license --copyright --strip-root".

CycloneDX spec reference

The value field in a property object is defined as type: string in all CycloneDX spec versions:

  • v1.4: value: type: string
  • v1.5: value: type: string
  • v1.6: value: type: string

The spec says: "The value of the property." with type string. If multiple values need to be represented, the spec recommends duplicate property names with different values, not array-typed values.

Related
To reproduce
pip install scancode-toolkit
scancode --package --license --copyright --cyclonedx output.cdx.json /path/to/project

Then check for non-string property values:

import json
with open('output.cdx.json') as f:
    data = json.load(f)
for p in data.get('metadata', {}).get('properties', []):
    if not isinstance(p.get('value'), str):
        print(f'Non-string value: {p["name"]} = {p["value"]} (type: {type(p["value"]).__name__})')
Expected behavior

All properties[].value fields should be strings per the CycloneDX specification. Array values should be serialized as a string (e.g. comma-separated or JSON-encoded string).

Environment
  • scancode-toolkit: latest (installed via pip)
  • Output format: --cyclonedx (JSON)
  • Python: 3.12+
Ngôn ngữ chính
Python
Star
2.7k
Fork
831
Merge trung bình
3 ngày 4 giờ
Pull request đã merge (30 ngày)
7

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 aboutcode-org/scancode-toolkit

Tất cả issue của aboutcode-org/scancode-toolkit

Issue tương tự

Thêm issue về Python

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.