-
-
Notifications
You must be signed in to change notification settings - Fork 12
feat: add --include-otp flag to include OTP/ERTS runtime components #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Taure
wants to merge
7
commits into
erlef:main
Choose a base branch
from
Taure:feat/include-otp-components
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
defef9b
feat: add --include-otp flag to include OTP/ERTS runtime components i…
Taure c6a0010
fix: handle unicode in descriptions with unicode:characters_to_binary
Taure 4b6aab2
fix: use unicode:characters_to_list for binary-to-list conversion
Taure 9d9b1a8
fix: use unicode-safe string conversions and handle non-GitHub URLs
Taure f653782
fix: use unicode:characters_to_binary in write_file for non-ASCII sup…
Taure 1f198da
fix: use pkg:otp PURL type for OTP runtime components
Taure a2d3760
fix: add repository_url and vcs_url qualifiers to OTP PURLs
Taure File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| %% SPDX-License-Identifier: BSD-3-Clause | ||
| %% SPDX-FileCopyrightText: 2026 Erlang Ecosystem Foundation | ||
|
|
||
| -module(rebar3_sbom_otp). | ||
|
|
||
| -export([otp_components/0, otp_components/1]). | ||
|
|
||
| -include("rebar3_sbom.hrl"). | ||
|
|
||
| -define(OTP_GITHUB, <<"https://github.com/erlang/otp">>). | ||
|
|
||
| %% Returns OTP/ERTS component info in the same proplist format as dep_info. | ||
| -spec otp_components() -> [proplists:proplist()]. | ||
| otp_components() -> | ||
| otp_components(otp_apps()). | ||
|
|
||
| -spec otp_components(Apps :: [atom()]) -> [proplists:proplist()]. | ||
| otp_components(Apps) -> | ||
| OtpRelease = erlang:system_info(otp_release), | ||
| ErtsVersion = erlang:system_info(version), | ||
| OtpComponent = otp_component(OtpRelease), | ||
| ErtsComponent = erts_component(ErtsVersion, OtpRelease), | ||
| AppComponents = [app_component(App, OtpRelease) || App <- Apps], | ||
| [OtpComponent, ErtsComponent | AppComponents]. | ||
|
|
||
| %% Top-level Erlang/OTP component | ||
| otp_component(OtpRelease) -> | ||
| Name = <<"erlang/otp">>, | ||
| Version = list_to_binary(OtpRelease), | ||
| [ | ||
| {name, Name}, | ||
| {version, Version}, | ||
| {purl, rebar3_sbom_purl:otp_runtime(Name, Version)}, | ||
| {cpe, rebar3_sbom_cpe:cpe(Name, Version, ?OTP_GITHUB)}, | ||
| {authors, []}, | ||
| {description, <<"Erlang/OTP">>}, | ||
| {licenses, [<<"Apache-2.0">>]}, | ||
| {external_references, #{"vcs" => binary_to_list(?OTP_GITHUB)}}, | ||
| {dependencies, []}, | ||
| {scope, required} | ||
| ]. | ||
|
|
||
| %% ERTS component | ||
| erts_component(ErtsVersion, OtpRelease) -> | ||
| Name = <<"erts">>, | ||
| Version = list_to_binary(ErtsVersion), | ||
| [ | ||
| {name, Name}, | ||
| {version, Version}, | ||
| {purl, rebar3_sbom_purl:otp_runtime(Name, Version)}, | ||
| {cpe, rebar3_sbom_cpe:cpe(<<"erlang/otp">>, list_to_binary(OtpRelease), ?OTP_GITHUB)}, | ||
| {authors, []}, | ||
| {description, <<"Erlang Runtime System">>}, | ||
| {licenses, [<<"Apache-2.0">>]}, | ||
| {external_references, #{"vcs" => binary_to_list(?OTP_GITHUB)}}, | ||
| {dependencies, []}, | ||
| {scope, required} | ||
| ]. | ||
|
|
||
| %% Individual OTP application component | ||
| app_component(App, OtpRelease) -> | ||
| Name = atom_to_binary(App), | ||
| Version = | ||
| case application:get_key(App, vsn) of | ||
| {ok, Vsn} -> list_to_binary(Vsn); | ||
| undefined -> list_to_binary(OtpRelease) | ||
| end, | ||
| Description = | ||
| case application:get_key(App, description) of | ||
| {ok, Desc} -> unicode:characters_to_binary(Desc); | ||
| undefined -> <<>> | ||
| end, | ||
| Licenses = | ||
| case application:get_key(App, licenses) of | ||
| {ok, L} -> [unicode:characters_to_binary(Li) || Li <- L]; | ||
| undefined -> [<<"Apache-2.0">>] | ||
| end, | ||
| [ | ||
| {name, Name}, | ||
| {version, Version}, | ||
| {purl, rebar3_sbom_purl:otp_runtime(Name, Version)}, | ||
| {cpe, rebar3_sbom_cpe:cpe(<<"erlang/otp">>, list_to_binary(OtpRelease), ?OTP_GITHUB)}, | ||
| {authors, []}, | ||
| {description, Description}, | ||
| {licenses, Licenses}, | ||
| {external_references, #{"vcs" => binary_to_list(?OTP_GITHUB)}}, | ||
| {dependencies, []}, | ||
| {scope, required} | ||
| ]. | ||
|
|
||
| %% Returns OTP apps actually used by the project's dependency tree. | ||
| %% These are the standard OTP applications that come bundled with Erlang. | ||
| -spec otp_apps() -> [atom()]. | ||
| otp_apps() -> | ||
| OtpLib = code:lib_dir(), | ||
| AllLoaded = [App || {App, _, _} <- application:loaded_applications()], | ||
| [App || App <- AllLoaded, is_otp_app(App, OtpLib)]. | ||
|
|
||
| -spec is_otp_app(atom(), file:filename()) -> boolean(). | ||
| is_otp_app(App, OtpLib) -> | ||
| case code:lib_dir(App) of | ||
| {error, _} -> false; | ||
| Dir -> lists:prefix(OtpLib, Dir) | ||
| end. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the
otppurl type here:package-url/purl-spec#472
We also use this in CVEs: https://cna.erlef.org/cves/CVE-2026-23941.json
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
mix_sbomI do this by detecting the burrito runtime: https://github.com/erlef/mix_sbom/blob/58f5cb57aeff28030ead6295eeddc530787e4c9b/lib/sbom/fetcher/mix_runtime.ex#L139otppurl requires therepository_urlto be present. Otherwise we would not be able to discern BEAM vs AtomVM etc.There was a problem hiding this comment.
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