syft icon indicating copy to clipboard operation
syft copied to clipboard

fix: [WIP]introduce Component Type Unknown in Cyclone DX for better conversion

Open VictorHuu opened this issue 7 months ago • 1 comments

Description

  1. In case of unexpected CycloneDX ComponentType, Unknown is used to prevent crash during conversion between Cyclone DX and other formats.
  2. Though Syft only support some of the ComponentType like container and file, other types defined in Cyclone DX Spec should also be included. Since most of these types share almost the same structure, a 'Unknown' type is enough to handle these types that Syft doesn't support now.

I'm not sure whether the solution is good or not,but I think a bit lossy information like 'application/library' to 'unknown' is acceptable.Otherwise,if we add types for every Component Type, quite a lot of even overwhelming test cases have to be updated.

Follow up: It seems that there are lots of issues related to the conversion, so this PR attempts to make the minimum changes in order not to introduce catastrophic results.

  • Fixes #3574 and #3575

Type of change

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)

Checklist:

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

VictorHuu avatar Apr 27 '25 06:04 VictorHuu

Troubleshoot: The so-called error line 193 and the test case TestSource_UnmarshalJSON/empty don't exist in the original file. And the CI/CD for same commit works well in my local PR.

FOLLOW UP: This is because some implicit test case for the empty string here: line. So I have to compromise a bit, but I think crashing for an SBOM with source type being empty is reasonable.

VictorHuu avatar Apr 29 '25 16:04 VictorHuu