CycloneDX / CycloneDX/cyclonedx-cli

`merge` output includes UTF-8 byte-order-marks

Open
#178 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
541
Forks
82
PR merge metrics
No merged PRs in 30d

Description

After upgrading `cyclonedx-cli` from v0.16.0 to v0.19.0, it was observed that XML BOMs produced by the `merge` command started being rejected when uploaded to Dependency Track v4.3.6.

The issue is that `cyclonedx-cli merge` now produces XML BOM files *with UTF-8 byte-order-marks*, unlike the earlier version, and Dependency Track rejects such files as invalid. Arguably, that's a DT bug, reported separately (https://github.com/DependencyTrack/dependency-track/issues/1214)

### Steps to reproduce

Merge two XML BOM files using `cyclonedx-cli` v0.19.0 and 0.16.0, respectively, and compare the outputs. The two files are identical, except for the UTF-8 byte-order-mark present in the later version.

The attached ZIP file includes sample input (`bom1.xml` and `bom2.xml`) and output files: [merge-sample-with-byte-order-mark.zip](https://github.com/CycloneDX/cyclonedx-cli/files/7296569/merge-sample-with-byte-order-mark.zip)

```cmd
> cyclonedx-win-x64 --version
0.16.0
> cyclonedx-win-x64 merge --input-files bom1.xml bom2.xml --output-file output-0.16.xml
```

The `output-0.16.xml` file has no UTF-8 byte-order-mark:

![merge-output-0 16-no-utf-8-bom](https://user-images.githubusercontent.com/139133/136268916-03d8aca5-d84b-4f3e-b4ff-68ba7925bd4d.png)

When uploaded to DT, it is processed as expected:
> INFO [BomUploadProcessingTask] Processing CycloneDX BOM uploaded to project: dcb2d96d-2387-4f39-9c8d-33d195040d90

Repeat these steps with the latest version, and note that now a UTF-8 byte-order-mark is present:

```cmd
> cyclonedx-win-x64 --version
0.19.0
> cyclonedx-win-x64 merge --input-files bom1.xml bom2.xml --output-file output-0.19.xml
```

![merge-output-0 19-with-utf-8-bom](https://user-images.githubusercontent.com/139133/136269514-563ddd44-4687-4ca4-8624-8ffac5972878.png)

When uploading this `output-0.19.xml` file to DT, it is rejected:
> WARN [BomUploadProcessingTask] The BOM uploaded is not in a supported format. Supported formats include CycloneDX XML and JSON

The only difference between the accepted and rejected BOM files is the presence or absence of the UTF-8 byte-order-mark.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.