-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(panic): Enhanced Support for Diverse Image ID Formats in Hash Extraction #114
Conversation
Signed-off-by: David Wertenteil <dwertent@armosec.io>
Thanks for fixing it... It's weird that the official method doesn't account for these forms. |
Summary:
|
@matthyx Where is the common method? |
Doesn't exist yet... It would make sense to have one |
@matthyx Should we merge this or should we write such a function? Do we know if the Operator needs such a capability? |
let's merge it now, worst case we can extract it later... |
Summary:
|
Signed-off-by: David Wertenteil <dwertent@armosec.io>
…fix-issue-111 Signed-off-by: David Wertenteil <dwertent@armosec.io>
Signed-off-by: David Wertenteil <dwertent@armosec.io>
Summary:
|
fix(panic): Enhanced Support for Diverse Image ID Formats in Hash Extraction
Pull Request Description
Title: Handling of Various Image ID Formats in Hash Extraction
Resolves: #111
Background:
The current implementation of hash extraction from Image IDs assumes a certain pattern and does not account for all variations of Image IDs, specifically formats like:
There are instances where the Image ID doesn't have enough submatches (less than 3) leading to panic as the existing code tries to access an index that does not exist.
Changes:
This PR provides a robust mechanism to extract the SHA256 hash from Image IDs that can handle varying formats. The key changes include:
Adding a check for plain SHA256 hashes: If the Image ID is a plain SHA256 hash, the function will now directly return it as the hash.
Improved Error Handling: An error is now returned when there is an issue with the hash extraction, instead of the function panicking.
Fallback Mechanism: In cases where the Image ID doesn't match the usual pattern, a fallback mechanism has been implemented to parse and extract the hash using a regular expression.
Impact:
This change will make the hash extraction from Image IDs more robust and prevent unexpected panics. It also improves error handling and provides more detailed error messages to help with troubleshooting.