Skip to content

feat: add --include-otp flag to include OTP/ERTS runtime components#45

Open
Taure wants to merge 7 commits intoerlef:mainfrom
Taure:feat/include-otp-components
Open

feat: add --include-otp flag to include OTP/ERTS runtime components#45
Taure wants to merge 7 commits intoerlef:mainfrom
Taure:feat/include-otp-components

Conversation

@Taure
Copy link
Copy Markdown

@Taure Taure commented Mar 15, 2026

Summary

  • Adds --include-otp CLI flag and {include_otp, true} rebar.config option to include Erlang/OTP runtime components in the generated SBoM
  • When enabled, the SBoM includes erlang/otp, erts, and all loaded OTP applications (kernel, stdlib, crypto, ssl, etc.) as components with proper PURL, CPE, and license metadata
  • This addresses a vulnerability scanning blind spot: OTP itself has CVEs (e.g. CVE-2025-26618, CVE-2024-53846) that are invisible without these components in the SBoM

Usage

rebar3 sbom --include-otp

Or in rebar.config:

{rebar3_sbom, [{include_otp, true}]}.

New files

  • src/rebar3_sbom_otp.erl — Collects OTP runtime info and produces component proplists with PURL, CPE, licenses, and external references
  • test/rebar3_sbom_otp_SUITE.erl — 19 tests (16 unit + 3 integration)

Modified files

  • src/rebar3_sbom_prv.erl — Added --include-otp CLI flag + config option
  • src/rebar3_sbom_purl.erl — Added otp_runtime/2 for pkg:generic/erlang-* PURLs
  • test/rebar3_sbom_purl_SUITE.erl — Added otp_runtime_purl_test

Test plan

  • All 69 tests pass (50 existing + 19 new OTP suite + 1 new PURL test)
  • rebar3 fmt --check clean
  • rebar3 dialyzer clean
  • rebar3 xref — no new warnings (only pre-existing rebar3 API warnings)
  • Verify CycloneDX CLI validation passes with OTP components included
  • Test with a real project to confirm OTP CVEs are detected by Grype/Trivy

Taure added 2 commits March 15, 2026 17:01
…n SBoM

When enabled via `--include-otp` CLI flag or `{include_otp, true}` in
rebar.config, the generated SBoM includes Erlang/OTP, ERTS, and all
loaded OTP applications (kernel, stdlib, crypto, ssl, etc.) as
components with proper PURL, CPE, and license metadata.

This addresses a significant vulnerability scanning blind spot: OTP
itself has CVEs that are invisible without these components in the SBoM.
list_to_binary/1 crashes on codepoints > 255 (e.g. em dash in app
descriptions). Use unicode:characters_to_binary/1 instead.
@Taure
Copy link
Copy Markdown
Author

Taure commented Mar 15, 2026

Taure/kura#44 I am testing this with this PR.

binary:bin_to_list/1 produces raw byte lists from UTF-8 binaries,
which causes badarg in xmerl export and list_to_binary in JSON
encoding. Use unicode:characters_to_list/1 to preserve codepoints.
@Taure Taure force-pushed the feat/include-otp-components branch from 6d5bafc to c7675ba Compare March 15, 2026 19:37
Replace all list_to_binary, binary_to_list, and binary:bin_to_list
calls with unicode:characters_to_binary/1 and
unicode:characters_to_list/1 where input data may contain Unicode
codepoints > 255 (e.g. em dash in app descriptions).

Also handle non-GitHub URLs gracefully in CPE generation instead of
crashing with function_clause.
@Taure Taure force-pushed the feat/include-otp-components branch from c7675ba to 9d9b1a8 Compare March 15, 2026 19:39
@Taure Taure force-pushed the feat/include-otp-components branch from 9b8edbc to f653782 Compare March 15, 2026 20:38
local(Name, Version) ->
purl(["generic", string:lowercase(Name)], Version).

otp_runtime(Name, Version) ->
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.

Use the otp purl type here:

package-url/purl-spec#472

We also use this in CVEs: https://cna.erlef.org/cves/CVE-2026-23941.json

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think I got it correct now.

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.

Sorry for the wait @Taure.

There's two things we need to be careful of:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ok, will try to see if I can make it better and see that these tools also work

Taure added 2 commits March 16, 2026 19:32
Switch from pkg:generic/erlang-{name} to pkg:otp/{name} per the merged
purl-spec PR#472. This aligns with the PURL format used in ERLEF CVE
disclosures (e.g. CVE-2026-23941) so that vulnerability scanners can
correctly match OTP components against known CVEs.
The otp purl type requires repository_url to distinguish BEAM
runtimes (Erlang/OTP) from others (AtomVM). Update otp_runtime
to accept a repository URL and emit qualifiers per purl-spec.

Output format now matches ERLEF CVE data:
  pkg:otp/erts@16.3?repository_url=https%3A%2F%2Fgithub.com%2Ferlang%2Fotp&vcs_url=git%2Bhttps%3A%2F%2Fgithub.com%2Ferlang%2Fotp.git

- otp_runtime/2 -> otp_runtime/3 (added RepositoryUrl parameter)
- New purl_with_qualifiers/3 helper for appending query string
- Updated tests to verify qualifier presence
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.

2 participants