-
Notifications
You must be signed in to change notification settings - Fork 8
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: do not use image url to get registry auth data. #180
Conversation
Updates the function used to verify container image signature to use only the registry name to get the auth data from docker config.json file. The current implementation uses the whole container image URL. Which failed to find the relevant auth data falling back to a anonymous authentication. This is a problem with private registries where access credentials must be used. To fix this problem, this commit extract the registry name from the container image URL and use it to get the auth data from the config.json file. Signed-off-by: José Guilherme Vanz <jguilhermevanz@suse.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main kubewarden/policy-fetcher#180 +/- ##
==========================================
- Coverage 41.35% 41.29% -0.06%
==========================================
Files 12 12
Lines 723 724 +1
==========================================
Hits 299 299
- Misses 424 425 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
The change looks good to me, step number 7 is wrong though, because you're pulling the policy from the ghcr, not from a private registry. It would also be great to extend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I would also like to have a test for it.
@flavio @jvanz we already use this in pattern in kwctl e2e tests, see https://github.com/kubewarden/kwctl/blob/1de2f0a7db81e38d4bb5a42cbea059805626b558/tests/e2e.rs#L330 |
It's not wrong. The policy does not need to be in the private registry. We are verifying the container image from the admission request, |
Description
Updates the function used to verify container image signature to use only the registry name to get the auth data from docker config.json file. The current implementation uses the whole container image URL. Which failed to find the relevant auth data falling back to a anonymous authentication. This is a problem with private registries where access credentials must be used.
To fix this problem, this commit extract the registry name from the container image URL and use it to get the auth data from the config.json file.
Fix kubewarden/policy-server#912
Test
To test this pull request, you can build kwctl using this changes, execute a docker login in the private registry
demo.goharbor.io
docker login ...
kwctl run --settings-path settings.yaml --request-path pod_creation_signed.json registry://ghcr.io/kubewarden/policies/verify-image-signatures:v0.2.8
settings.yaml
pod_creation_signed.json