Skip to content

feat(models): add address to OrganizationalEntity - #1513

Open
CAOShurong wants to merge 2 commits into
CycloneDX:mainfrom
CAOShurong:codex/add-entity-address
Open

feat(models): add address to OrganizationalEntity#1513
CAOShurong wants to merge 2 commits into
CycloneDX:mainfrom
CAOShurong:codex/add-entity-address

Conversation

@CAOShurong

@CAOShurong CAOShurong commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Closes #1251

Summary

Adds optional PostalAddress support for the OrganizationalEntity.address field introduced in CycloneDX 1.6, with correct JSON and XML serialisation.

Changes

  • Added the public Models.PostalAddress model with country, region, locality, post office box, postal code, and street address fields.
  • Added dedicated JSON/XML normalizers and factory methods for postal addresses.
  • OrganizationalEntity.address now uses PostalAddress, is emitted only for CycloneDX 1.6 and newer, and follows the schema element/property order.
  • Empty organizational contact collections remain omitted from output.
  • Extended createComplexStructure and refreshed 1.6/1.7 JSON/XML normalization and serialization snapshots.

Verification

  • Node build: passed (npm run build:node)
  • Web build: passed (npm run build:web)
  • Declaration compilation: passed (npx tsc -b tsconfig.d.json)
  • Full Node test suite: 4169 passing (npm run test:node)
  • TypeScript lint: passed (npm run test:lint)
  • ESLint standard check: passed (npm run test:standard)
  • Production dependency check: passed (npm run test:dependencies)
  • Code-style fix: passed (npm run cs-fix)

AI Tool Disclosure

  • My contribution does not include any AI-generated content
  • My contribution includes AI-generated content, as disclosed below:
    • AI Tools: OpenAI Codex CLI
    • LLMs and versions: GPT-5-Codex
    • Prompts: Asked to continue PR #1513, address reviewer feedback by introducing PostalAddress, add JSON/XML serialization coverage and snapshots, run the complete verification suite, and push the fix to the existing PR.

@CAOShurong
CAOShurong requested a review from a team as a code owner August 22, 2026 19:36
@codacy-production

codacy-production Bot commented Aug 22, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 15 complexity · 0 duplication

Metric Results
Complexity 15
Duplication 0

View in Codacy

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.

@jkowalleck

Copy link
Copy Markdown
Member

Thank you for your effort.

I see this PR mixing scopes. It addresses 2 topics at once:

  • src/contrib/fromNodePackageJson/builders.ts - adding tags
  • src/models/organizationalEntity.ts - adding address

Please split this into two independent, scoped pull requests - each targeting a single ticket/issue.

## Pullrequests
When opening a pull request, use the repository’s pull request template and complete all required fields.
Keep each pull request focused on a single topic or problem.
Every pull request must reference an existing issue that it aims to address.
If no issue exists for your topic, please create one first using the appropriate issue template, then link your pull request to it.

@jkowalleck
jkowalleck marked this pull request as draft August 24, 2026 12:48
@jkowalleck

This comment was marked as outdated.

Adds optional address field (OrganizationalContact) to
OrganizationalEntity and serialises it in JSON and XML output.

Closes CycloneDX#1251

Signed-off-by: CAOShurong <170531907+CAOShurong@users.noreply.github.com>
@CAOShurong
CAOShurong force-pushed the codex/add-entity-address branch from c72f54d to 1b3bdbf Compare August 25, 2026 18:19
@CAOShurong
CAOShurong marked this pull request as ready for review August 25, 2026 18:20
@CAOShurong

Copy link
Copy Markdown
Contributor Author

Done — the PR is now scoped to the address change only, rebased onto current main (single commit, 4 files: organizationalEntity.ts, JSON/XML normalize + types). The component-tags work lives separately in #1511 as requested.

The AI Tool Disclosure section is now filled in in the PR description (OpenAI Codex CLI / GPT-5-Codex, with the prompts used). Apologies for missing it initially — thanks for pointing it out.

@jkowalleck jkowalleck added the enhancement New feature or request label Aug 26, 2026

@jkowalleck jkowalleck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implementation seams off -- see details below.

additionally, 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

Comment thread src/serialize/xml/normalize.ts Outdated
...this._factory.makeForOrganizationalContact().normalizeIterable(data.contact, options, 'contact')
...this._factory.makeForOrganizationalContact().normalizeIterable(data.contact, options, 'contact'),
...(data.address === undefined
? []

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd rather not omit the field at all, than having an empty list.

Suggested change
? []
? undefined

Comment thread src/models/organizationalEntity.ts Outdated
name?: string
url: Set<URL | string>
contact: OrganizationalContactRepository
address?: OrganizationalContact

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, per CycloneDX spec, an org's address is not an OrganizationalContact,
but a different type PostalAddress -
see https://github.com/CycloneDX/specification/blob/4d1842b78fb394c9bf7f6c49398513adebaa0a9b/schema/bom-1.7.schema.json#L824-L827

Signed-off-by: Shurong Cao <170531907+CAOShurong@users.noreply.github.com>
@CAOShurong

Copy link
Copy Markdown
Contributor Author

Addressed the review feedback in 357253e:

  • OrganizationalEntity.address now uses the dedicated PostalAddress model.
  • JSON/XML normalizers and factories serialize all postal-address fields in schema order.
  • Address output is gated to CycloneDX 1.6+; older versions remain schema-valid.
  • Empty organizational contact collections are omitted.
  • Added the complex fixture coverage and refreshed 1.6/1.7 snapshots.

Verification completed: 4169 Node tests passing, Node/Web builds passing, declaration compilation, TypeScript lint, ESLint, dependency check, and code-style check all pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: addd address to OrganizationalEntity data models

2 participants