Skip to content

Check if frs Map is nil before ranging over it#462

Merged
egibs merged 2 commits intochainguard-dev:mainfrom
egibs:more-nil-fixes
Sep 16, 2024
Merged

Check if frs Map is nil before ranging over it#462
egibs merged 2 commits intochainguard-dev:mainfrom
egibs:more-nil-fixes

Conversation

@egibs
Copy link
Member

@egibs egibs commented Sep 16, 2024

Closes #458

The .jar file in the aforementioned issue failed to extract:

time=2024-09-15T21:08:02.374-04:00 level=ERROR source=/Users/t/src/bincapz/pkg/action/scan.go:233 msg="unable to process ../malware/Downloads/909a19d0de5476e249c133f73c4afa288982d05dcf4ca597fa8357d93f435c47.jar: extract to temp: failed to extract ../malware/Downloads/909a19d0de5476e249c133f73c4afa288982d05dcf4ca597fa8357d93f435c47.jar: failed to open zip file ../malware/Downloads/909a19d0de5476e249c133f73c4afa288982d05dcf4ca597fa8357d93f435c47.jar: zip: not a valid zip file"

Which means the frs Map was not populated (i.e., was still nil) before we tried to use the Range() method (and we're passing in a pointer to the Map via frs *sync.Map):

frs.Range(func(_, value any) bool {
    ...
}

This PR should handle cases like this more resiliently.

Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
@egibs egibs requested a review from tstromberg September 16, 2024 15:42
Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
@egibs egibs merged commit 8e760ba into chainguard-dev:main Sep 16, 2024
@egibs egibs deleted the more-nil-fixes branch September 16, 2024 15:49
egibs added a commit to egibs/malcontent that referenced this pull request Sep 25, 2024
* Check if frs Map is nil before ranging over it

Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>

* Appease the linter

Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>

---------

Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
imjasonh pushed a commit to wolfi-dev/os that referenced this pull request Sep 30, 2024
While troubleshooting the `wolfictl check diff` panics in #29705, I
noticed that the SDK image digest was fairly out of date (3+ weeks).

This means that all of the recent `bincapz`/`malcontent` changes were
not captured, including
[this](chainguard-dev/malcontent#462) PR which
resolves panics like the one seen in the aforementioned PR.

This PR updates the SDK image digest to an image with the latest version
of `malcontent` and the most recent `wolfictl`
[commit](wolfi-dev/wolfictl@8f6fc7a)
which will correctly locate the `malcontent` binary in SDK containers.

Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
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.

action.errIfHitOrMiss: panic: runtime error: invalid memory address or nil pointer dereference

2 participants