Skip to content
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

Don't use Trivy auth helpers when using Azure #14

Closed
wants to merge 1 commit into from
Closed

Conversation

asankov
Copy link

@asankov asankov commented Apr 26, 2024

and user has provider username and pass in pull secret

and user has provider username and pass in pull secret
@asankov asankov self-assigned this Apr 26, 2024
@@ -42,6 +42,23 @@ func NewFromRemote(ctx context.Context, imageName string, option types.ImageOpti
return img, nil
}

func getToken(ctx context.Context, domain string, opt types.RegistryOptions) (auth authn.Basic) {
// if the registry is Azure AND the user configured a pull secret with username and password
// just return them as basic auth and don't user trivy's GetToken function
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/user/use

@patrickpichler
Copy link
Contributor

By looking at the code, I guess this issue is not just ACR specific, you have the same thing with GCR/ECR.
https://github.com/aquasecurity/trivy/blob/main/pkg/fanal/image/registry/google/google.go#L37

You mentioned in your discord message, that in order to use azure workload identity, we need to specify a special label on the scanner pod. In my opinion the better fix would be to extend kvisor-controller to make the scanner labels configurable.

@asankov
Copy link
Author

asankov commented Apr 29, 2024

@patrickpichler

By looking at the code, I guess this issue is not just ACR specific, you have the same thing with GCR/ECR.

For GCP - probably yes, need to investigate. For sure, we cannot use username/pass there, but maybe workload identity works out of the box for GCP.
For AWS - no. We have the workload ID setup for AWS. AFAIK AWS does not support username/pass at all, so this is a non-issue for AWS.

@patrickpichler
Copy link
Contributor

What you can do in AWS ECR is to use a login password (see here), but iMHO we should discourage this. One thing we should be thinking about is, if we want to support cases where you haven an EKS cluster and e.g. pull images from GCR, as in such cases you can not use any of the workload identity solutions (I guess in theory you can setup OIDC to assume identities in other cloud providers via the identity from your kubernetes cluster, but I have no idea if this is actually supported 😅).

}
}

return registry.GetToken(ctx, domain, opt)
Copy link
Contributor

@anjmao anjmao Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be due to upgrade https://github.com/castai/image-analyzer/pull/11/files
Before it would use token.GetToken and under the hood it handled this case.

@asankov
Copy link
Author

asankov commented Apr 29, 2024

Closing this, because we opted to go the Workload ID way, and these changes are not needed for now

See castai/kvisor#265

@asankov asankov closed this Apr 29, 2024
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.

None yet

4 participants