Skip to content

fix:best effort to get the os info of an ELF binary#4438

Merged
wagoodman merged 16 commits intoanchore:mainfrom
VictorHuu:os-wo-version-elf
Dec 12, 2025
Merged

fix:best effort to get the os info of an ELF binary#4438
wagoodman merged 16 commits intoanchore:mainfrom
VictorHuu:os-wo-version-elf

Conversation

@VictorHuu
Copy link
Contributor

@VictorHuu VictorHuu commented Dec 5, 2025

Description

This PR requires a json-schema label though the version of the schema may change due to the conflicts across PRs.

In the newly introduced test cases for the issue, the constructor of location needs to be altered.

appCpe is just added according to the document,whose usage in Syft remains uncertain.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have added unit tests that cover changed behavior
  • I have tested my code in common scenarios and confirmed there are no regressions
  • I have added comments to my code, particularly in hard-to-understand sections

…on is empty

Signed-off-by: Yuntao Hu <victorhu493@gmail.com>
Signed-off-by: Yuntao Hu <victorhu493@gmail.com>
Signed-off-by: Yuntao Hu <victorhu493@gmail.com>
Signed-off-by: Yuntao Hu <victorhu493@gmail.com>
Signed-off-by: Yuntao Hu <victorhu493@gmail.com>
Signed-off-by: Yuntao Hu <victorhu493@gmail.com>
Signed-off-by: Yuntao Hu <victorhu493@gmail.com>
Signed-off-by: Yuntao Hu <victorhu493@gmail.com>
Signed-off-by: Yuntao Hu <victorhu493@gmail.com>
Signed-off-by: Yuntao Hu <victorhu493@gmail.com>
@github-actions github-actions bot added the json-schema Changes the json schema label Dec 5, 2025
Signed-off-by: Yuntao Hu <victorhu493@gmail.com>
Signed-off-by: Yuntao Hu <victorhu493@gmail.com>
Signed-off-by: Yuntao Hu <victorhu493@gmail.com>
Signed-off-by: Yuntao Hu <victorhu493@gmail.com>
@VictorHuu VictorHuu marked this pull request as ready for review December 12, 2025 07:40
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Copy link
Contributor

Choose a reason for hiding this comment

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

I changed this to not be a breaking change for JSON consumers. We can correct the output in syft JSON with syft v2.

Location file.Location `json:"-"`
// CorrectOSCPE has the corrected casing for the osCPE field relative to the systemd ELF package metadata "spec" https://systemd.io/ELF_PACKAGE_METADATA/ .
// Ideally in syft 2.0 this field should be replaced with the pkg.ELFBinaryPackageNoteJSONPayload.OSCPE field directly (with the struct tag corrected).
CorrectOSCPE string `json:"osCpe,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we can't change the osCPE field on the pkg.ELFBinaryPackageNoteJSONPayload struct, this adds it to the struct responsible for unmarshaling. In this way we aren't exposing out the temporary field.

return nil, err
}

func unmarshalELFPackageNotesPayload(data []byte) (*elfBinaryPackageNotes, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I made this function as a choke point as early on in processing to deal with capturing the "correct" osCPE field onto the public field.

@wagoodman wagoodman enabled auto-merge (squash) December 12, 2025 19:10
@wagoodman wagoodman merged commit 4c38ee1 into anchore:main Dec 12, 2025
12 checks passed
spiffcs added a commit that referenced this pull request Dec 19, 2025
* main: (76 commits)
  feat: snap can be queried by revision and ```track/risk/branch``` (#4439)
  fix: 4423 dotnet-deps cataloger skips project type by def
  signpost to docs site (#4483)
  chore(deps): bump github/codeql-action from 4.31.8 to 4.31.9 (#4481)
  chore(deps): bump github.com/goccy/go-yaml from 1.19.0 to 1.19.1 (#4482)
  Detect embedded deps.json in .NET binaries (#4375)
  chore(deps): bump actions/cache from 5.0.0 to 5.0.1 (#4476)
  chore(deps): bump actions/cache in /.github/actions/bootstrap (#4477)
  chore(deps): update tools to latest versions (#4473)
  unapply base path for resolver inbound requests (#4478)
  fix: golang PURL should include full module (#4395)
  fix:best effort to get the os info of an ELF binary (#4438)
  Improve PR template (#4472)
  feat: add support for Gemfile.next.lock (#4457)
  chore:cancel in-progress workflows for new commits on same PR (#4465)
  chore(deps): update tools to latest versions (#4466)
  chore(deps): bump github/codeql-action from 4.31.7 to 4.31.8 (#4468)
  chore(deps): bump actions/cache from 4.3.0 to 5.0.0 (#4469)
  chore(deps): bump github.com/anchore/stereoscope from 0.1.14 to 0.1.16 (#4470)
  chore(deps): bump actions/cache in /.github/actions/bootstrap (#4471)
  ...

Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

json-schema Changes the json schema

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ELF note cataloger does not pick up OS field, but should

2 participants