feat(contrib): populate component tags from npm keywords - #1511
feat(contrib): populate component tags from npm keywords#1511CAOShurong wants to merge 2 commits into
Conversation
Fills component.tags from the npm package.json keywords property in ComponentBuilder, and serialises tags in both JSON and XML for CycloneDX 1.6 and later (tags were introduced in 1.6). - Add optional tags to the Component model and JSON/XML serialisation - Add supportsComponentTags to the spec protocol, gated to 1.6+ Signed-off-by: CAOShurong <170531907+CAOShurong@users.noreply.github.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | -1 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Documentation build overview
|
This comment was marked as outdated.
This comment was marked as outdated.
|
The AI Tool Disclosure section from the PR template is now filled in (OpenAI Codex CLI / GPT-5-Codex, with a summary of the prompts). Sorry for missing it — happy to adjust anything else. |
| group, | ||
| licenses, | ||
| properties, | ||
| tags: typeof data.keywords === 'string' |
There was a problem hiding this comment.
better have this collection of tags separate - just like properties above.
Also, we dont care for any keywords that is not an array ....
As the doc string says:
Intended to run on normalized data structures
suggestion:
const tags = new Set(this.#makeTags(data.keywords))* #makeTags (keywords: NodePackageJson['keywords']): Generator<string> {
if (!Array.isArray(keywords)) continue;
for (const kw of keywords) {
if (typeof kw === 'string') {
yield kw
}
}
}| purl?: string | ||
| scope?: ComponentScope | ||
| supplier?: OrganizationalEntity | ||
| tags?: string[] |
There was a problem hiding this comment.
better:
| tags?: string[] | |
| keywords?: Set<string> |
and the new property is misisng in the compare function
jkowalleck
left a comment
There was a problem hiding this comment.
tests are missing - please add the new capabilities to the createComplexStructure in file tests/_data/models.js and have the test running and snapshots updated.
see https://github.com/CycloneDX/cyclonedx-javascript-library/blob/main/tests/README.md
|
|
||
| <!-- add unreleased items here --> | ||
| * Added | ||
| * `Contrib.FromNodePackageJson.Builders.ComponentBuilder` populates component `tags` from the npm `keywords` property; `tags` are serialised in JSON and XML for CycloneDX 1.6 and later ([#1055]) |
There was a problem hiding this comment.
split those new capabilities -and make them a post shorter, if possible, see the changelog from the past .
something like
| * `Contrib.FromNodePackageJson.Builders.ComponentBuilder` populates component `tags` from the npm `keywords` property; `tags` are serialised in JSON and XML for CycloneDX 1.6 and later ([#1055]) | |
| * component model knownstags | |
| * serializers and normalizers canemit component tags | |
| * that contrib builder may populate tags ([#1055] via [#1511]) |
| * Added | ||
| * `Contrib.FromNodePackageJson.Builders.ComponentBuilder` populates component `tags` from the npm `keywords` property; `tags` are serialised in JSON and XML for CycloneDX 1.6 and later ([#1055]) | ||
|
|
||
| [#1055]: https://github.com/CycloneDX/cyclonedx-javascript-library/issues/1055 |
There was a problem hiding this comment.
| [#1055]: https://github.com/CycloneDX/cyclonedx-javascript-library/issues/1055 | |
| [#1055]: https://github.com/CycloneDX/cyclonedx-javascript-library/issues/1055 | |
| [#1511]: https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1511 |
Signed-off-by: CAOShurong <170531907+CAOShurong@users.noreply.github.com>
|
Addressed all requested changes in
Revalidated the pushed head: full Node suite 4170 passing / 4 pending, |
|
@jkowalleck, the requested model/builder, changelog, and fixture changes are now in |
Closes #1055
Summary
Adds
tagssupport to the Component model and populates it from array-form npmpackage.jsonkeywords, serializing tags in both JSON and XML for CycloneDX 1.6 and later.Changes
Component.tagsis aSet<string>with an empty default and participates in component comparison.Contrib.FromNodePackageJson.Builders.ComponentBuildercollects normalized array-form keywords through a dedicated generator, ignores non-array input, and filters non-string entries.createComplexStructurecovers tags and the JSON/XML normalization and serialization snapshots are updated for 1.6/1.7.HISTORY.mdrecords the model, serializer/normalizer, and contrib-builder capabilities separately.The unrelated entity-address work remains split into #1513.
Verification
npm run test:lint: passednpm run build:node: passednpm run build:web: passedcpypost-script reportsNo files matched)AI Tool Disclosure