Skip to content

merge: add --input-files-list / --input-files-nul-list to exceed CLI arg limits - #512

Open
jimklimov wants to merge 5 commits into
CycloneDX:mainfrom
jimklimov:merge-input-files-list
Open

jimklimov wants to merge 5 commits into
CycloneDX:mainfrom
jimklimov:merge-input-files-list

Conversation

@jimklimov

@jimklimov jimklimov commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

What

Adds merge --input-files-list NAME / --input-files-nul-list NAME (newline- or NUL-separated list of
input file paths in a text file), as an alternative to passing them all as --input-files CLI
arguments — useful when the number of input BOMs is large enough to exceed OS/shell command-line
length limits, and to handle filenames containing spaces without shell-quoting headaches.

Why

Supersedes #328, which proposed the same thing; closing that in favor of this PR. Stacked on #511
(merge-conflict-resolution) — must merge first (its diff context overlaps MergeCommand.cs).

MergeCommand now calls CycloneDXUtils.FlatMerge/HierarchicalMerge with
MergeStrategy.Default() when built against a library that has it
(#if NET8_0_OR_GREATER, matching the library's own guard -- CLI is
net10.0-only today but this keeps the two projects' conditional
compilation symmetric and self-documenting), falling back to the
plain overload otherwise. No new CLI flags: strategy toggles are not
yet exposed at the command-line layer, so this only changes default
merge behavior, not the command's surface.

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
Adds a "rename-entity" command that renames a bom-ref and every
back-reference to it throughout a BOM document, built on the
library's new BomRefWalker-based Bom.RenameRef(old, new) API. Follows
current System.CommandLine conventions
(System.CommandLine.NamingConventionBinder, not the older
System.CommandLine.Invocation namespace) and matches Convert/
MergeCommand's internal (not public) visibility.

Verified end-to-end against a real fixture: renaming a component's
bom-ref correctly rewrites both the dependsOn back-reference and the
dependency's own ref entry, and stamps fresh SerialNumber/Timestamp/
Tools metadata via BomMetadataUpdate/BomMetadataReferThisToolkit.

Wired into Program.cs (alphabetical position, between Merge and Sign),
guarded by #if NET8_0_OR_GREATER to match the library capability it
depends on.

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
Follows MergeTests.cs conventions: direct handler call, TempDirectory,
Snapshooter with serialNumber/timestamp stripped (plus the tools list,
whose contents are build/environment-specific -- assembly versions and
"testhost" vs. the real CLI name under `dotnet test`). Covers a JSON
and an XML output round-trip of the rewrite-identifier-and-back-refs
case, plus a no-op case when the requested old-ref isn't present.

Full suite: 132 passed / 0 failed (129 pre-existing + 3 new).

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
…usal

merge gains --component-conflict-resolution
<KeepSeparate|Squash_UpgradeScope|Squash_DowngradeScope|Squash_RenameByScope>,
defaulting to the library's MergeStrategy.Default() (Squash_UpgradeScope)
when not specified. This closes a pre-existing gap: the library-side
strategy was never selectable from the CLI at all -- it was always
hardcoded to Default() internally. Verified end-to-end: merging two
BOMs where the same component is "required" in one and "excluded" in
the other with --component-conflict-resolution Squash_RenameByScope
produces two distinct components (lp:scope=Required /
lp:scope=Excluded) with each source's dependsOn correctly pointing at
its own variant.

rename-entity now catches the InvalidOperationException
Bom.RenameRef throws when the requested new-ref collides with an
existing identifier, reporting it as a clean parameter-validation
error instead of an unhandled crash.

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
This lets callers pass files listing BOM filenames (one per line,
or 0x00-separated for the --input-files-nul-list variant, e.g. from
`find -print0`) instead of one --input-files argument per BOM, to
avoid OS/shell command-line length or argument-count limits when
merging many BOMs, a real constraint once the number of input files
grows large.

Entries are deduplicated against --input-files and each other as
they are collected. Non-absolute paths are resolved relative to
the current working directory. No library changes needed -- this
feature only builds a longer input-file list before the existing
InputBoms(...) call.

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant