XML output writes a vulnerability's `created` date as `published` and `updated`

オープン 初心者向け
#1,537 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 7 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, typescript, xml
領域
backend, data

調査の方向性

src/serialize/xml/normalize.ts の VulnerabilityNormalizer から始めて、日付要素の構築を確認してください。XML 出力をモデルの日付および既存の JSON 出力と比較してください。XML ノーマライザーを更新し、異なる日付と欠落した日付を対象とするカバレッジを追加または調整してください。XML では各日付がそれぞれ独立して保持され、関連するスナップショットが一致するようにしてください。

索引モデルが issue の本文から書いたものです。

説明

Describe the bug

The XML normalizer writes a vulnerability's created date into all three date elements. published and updated are never read, so in XML they are wrong, missing, or made up. The JSON output is correct.

To reproduce

const { Models, Serialize, Spec } = require('@cyclonedx/cyclonedx-library')

const bom = new Models.Bom()
bom.vulnerabilities.add(new Models.Vulnerability.Vulnerability({
  bomRef: 'v1',
  created: new Date('2021-01-01T00:00:00Z'),
  published: new Date('2022-02-02T00:00:00Z'),
  updated: new Date('2023-03-03T00:00:00Z')
}))

const serializer = new Serialize.XmlSerializer(
  new Serialize.XML.Normalize.Factory(Spec.Spec1dot6))
console.log(serializer.serialize(bom, { space: 2 }))

Output:

<created>2021-01-01T00:00:00.000Z</created>
<published>2021-01-01T00:00:00.000Z</published>
<updated>2021-01-01T00:00:00.000Z</updated>

Two more cases:

Dates set on the model XML output
only published and updated no date elements at all
only created created, plus published and updated with the same value

Expected behaviour

Each element carries its own value, as in the JSON output:

<created>2021-01-01T00:00:00.000Z</created>
<published>2022-02-02T00:00:00.000Z</published>
<updated>2023-03-03T00:00:00.000Z</updated>

Cause

src/serialize/xml/normalize.ts, in VulnerabilityNormalizer:

makeOptionalDateTimeElement(data.created, 'created'),
makeOptionalDateTimeElement(data.created, 'published'),
makeOptionalDateTimeElement(data.created, 'updated'),

The stored snapshots show it too: tests/_data/models.js sets published to ...00:00:41 and updated to ...00:00:42, and tests/_data/serializeResults/xml_complex_spec1.6.xml.bin has ...00:00:40 three times.

Environment

  • Library version: 10.5.0 (main at 7456cad)
  • Node.js 24.18.0, Windows 11

I can open a PR with the fix and the regenerated snapshots.

AI disclosure: this was found with the help of Claude Code. The snippet was run against the built library.

主要言語
TypeScript
スター
25
フォーク
16
平均マージ
5日 17時間
マージ済み PR(30日)
9

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

CycloneDX/cyclonedx-javascript-library のほかの issue

CycloneDX/cyclonedx-javascript-library の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。