Strip unused SBOM fields to reduce object size by ~52%#720
Strip unused SBOM fields to reduce object size by ~52%#720
Conversation
This change strips unnecessary fields from generated SBOMs at creation time to reduce memory consumption across the entire system (node-agent, etcd, synchronizer, storage, kubevuln). Fields stripped: - Package metadata and metadataType (JAR manifests, dpkg file lists, etc) - saves ~3.19 MB / 46% - License locations - saves ~228 KB / 3.2% - Location accessPath and annotations - saves ~159 KB / 2.2% - Package foundBy cataloger name - saves ~15 KB - Source metadata and descriptor configuration - saves ~20 KB Total savings: ~3.6 MB / 52% for large images (tested with Elasticsearch 8.7.1) These fields are not used by: - Grype/kubevuln for vulnerability matching (uses name, version, type, purl, cpes) - ARMO backend (already stripped by synchronizer) - Relevancy scanning (uses files and artifactRelationships which are preserved) Signed-off-by: Ben <ben@armosec.io> Co-authored-by: Cursor <cursoragent@cursor.com>
📝 WalkthroughWalkthroughThe SBOM manager strips non-essential fields from emitted payloads to reduce size. Modifications remove Locations from licenses, VirtualPath and Annotations from locations, Metadata and Configuration from the root document, and FoundBy from packages. Control flow and public APIs remain unchanged. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The json package is no longer used after stripping metadata marshaling. Signed-off-by: Ben <ben@armosec.io> Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
This PR strips unnecessary fields from generated SBOMs at creation time to reduce memory consumption across the entire system (node-agent, etcd, synchronizer, storage, kubevuln).
Size reduction: ~3.6 MB / 52% for large images (tested with Elasticsearch 8.7.1: 6.89 MB → 3.29 MB)
Changes
Fields stripped from
pkg/sbommanager/v1/sbom_manager.go:Why these fields are safe to remove
These fields are not used by:
Impact
This change reduces memory pressure in:
Testing
Related
This is Phase 1 of a multi-phase optimization:
Summary by CodeRabbit