CycloneDX output: metadata.properties[].value emits JSON array instead of string
メンテナーはふだん 3 日以内に返信
評価
調査の方向性
まず issue にある --cyclonedx コマンドで問題を再現し、次に Python のチェックスクリプトを実行して、値が文字列でない properties を一覧表示してください。CycloneDX 出力のコードを検索し、オプションのリストから scancode:options プロパティが組み立てられている箇所を見つけてください。すべての metadata.properties[].value が文字列になり、チェックが何も出力しなくなれば完了です。ペイロードだけでは、スペースで連結するか、カンマで連結するか、JSON エンコードするかは決まらないので、編集前にその選択を確認してください。
索引モデルが issue の本文から書いたものです。
説明
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:
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
- cyclonedx-cli merge crash on array values: https://github.com/CycloneDX/cyclonedx-cli/issues/246
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+
- 主要言語
- Python
- スター
- 2.7k
- フォーク
- 831
- 平均マージ
- 3日 4時間
- マージ済み PR(30日)
- 7
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
aboutcode-org/scancode-toolkit のほかの issue
-
bug: Unreachable JSON extension and format validation in validate_input_path対応中かも @0Cymantek0 が 18 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
aboutcode-org/scancode-toolkit#5351 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
Duplicate 'COPYLEFT' entries in legal file classification names in legal.py and classify.py対応中かも @Pradeepbeleri が 45 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
aboutcode-org/scancode-toolkit#5319 · コメント 2 件 ·
メンテナーはふだん 3 日以内に返信
-
Duplicate autogen.sh entry in commoncode default ignores対応中かも @Daksha1611 が 48 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
aboutcode-org/scancode-toolkit#5316 ·
メンテナーはふだん 3 日以内に返信
-
Duplicate LGPL key in rubygems LICENSES_MAPPING makes one mapping unreachable対応中かも @Daksha1611 が 48 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
aboutcode-org/scancode-toolkit#5314 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
Duplicate keys in alpine DECLARED_TO_SPDX silently discard two license mappings対応中かも @Daksha1611 が 48 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
aboutcode-org/scancode-toolkit#5312 ·
メンテナーはふだん 3 日以内に返信
aboutcode-org/scancode-toolkit の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
ClockGU/clockwork-backend#169 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
aws-samples/sample-per-model-bedrock#616 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
chnm/teachinghistory-hugo#47 ·
-
good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
pandas-dev/pandas-stubs#2047 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信