Skip to content

Conversation

@mkm29
Copy link
Contributor

@mkm29 mkm29 commented Sep 13, 2025

Summary

This PR fixes a nil pointer dereference panic in prescan when processing images that do not contain OS metadata (e.g., distroless or scratch-based images such as quay.io/prometheus/prometheus:v2.48.0).

Problem

Previously, prescan assumed that r.Metadata.OS was always non-nil. When Trivy reports no OS metadata, Helmper panics at runtime: panic: runtime error: invalid memory address or nil pointer dereference

Fix

  • Added a nil check for r.Metadata.OS in prescan.
  • If OS metadata is absent, the image is logged and skipped (added to push), rather than attempting to evaluate unsupported OS or patch logic.

Impact

  • Helmper will now safely handle distroless/scratch images (or images like alpine:latest with 0 OS vulns) and continue processing without crashing.
  • Users will see a warning in logs indicating the image could not be patched, instead of a panic.

Testing

  • Verified by:
    • Built new binary (same flags as in .goreleaser.yaml)
    • Created full helmper.yaml configuration file with prometheus-community chart (5 of the 6 images contain 0 OS vulns).
    • Ran new binary and local Zot OCI registry
  • Helmper now logs the warning and continues pushing charts and images without error.

@ChristofferNissen ChristofferNissen merged commit d68801c into ChristofferNissen:main Sep 13, 2025
3 checks passed
@ChristofferNissen
Copy link
Owner

Thank you for your contribution to Helmper!

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