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

Added AWS Credentials Support for Scanning Private Registry #1062

Closed
wants to merge 3 commits into from

Conversation

VF-mbrauer
Copy link
Contributor

Added support for scanning the private registry of AWS-ECR.
Feature still in Beta-mode but usable when prerequisites are met.

Prerequisite:
K8S-Kiam or any other method IRSA (Future) to be used to allow Assuming Instance Roles.

Configurations:
Annotate the Starboard Namespace to be allowed to use KIAM:
Annotations: iam.amazonaws.com/permitted: .*

Add the Role you want to Assume which has the proper right to create ECR-Credentials

podAnnotations: 
    # iam.amazonaws.com/role: <yourRolewithPermissions>

Configuration in HELM value file to enable the feature
trivy.useEcrRoleCreds: false

if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case ecr.ErrCodeServerException:
fmt.Println(ecr.ErrCodeServerException, aerr.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

better pass logger and use it: log.V(1).Error(aerr,ecr.ErrCodeServerException,"error somthing")

case ecr.ErrCodeInvalidParameterException:
fmt.Println(ecr.ErrCodeInvalidParameterException, aerr.Error())
default:
fmt.Println(aerr.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

same here use logger

case ecr.ErrCodeServerException:
fmt.Println(ecr.ErrCodeServerException, aerr.Error())
case ecr.ErrCodeInvalidParameterException:
fmt.Println(ecr.ErrCodeInvalidParameterException, aerr.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

same here use logger

fmt.Println(aerr.Error())
}
} else {
fmt.Println(err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

^


var credentials = *result.AuthorizationData[0].AuthorizationToken

sDec, _ := base64.StdEncoding.DecodeString(credentials)
Copy link
Contributor

Choose a reason for hiding this comment

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

error should not be ignored

registryPasswordKey := fmt.Sprintf("%s.password", c.Name)
if config.UseECRCredentials() {
var aws_creds = GetAuthorizationToken(c.Image)
var creds (ecr_credentials) = ecr_credentials{aws_creds[0][1], aws_creds[0][2]}
Copy link
Contributor

@chen-keinan chen-keinan Mar 28, 2022

Choose a reason for hiding this comment

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

check matrix size both row and column to avoid index out of range

registryPasswordKey := fmt.Sprintf("%s.password", container.Name)
if config.UseECRCredentials() {
var aws_creds = GetAuthorizationToken(container.Image)
var creds (ecr_credentials) = ecr_credentials{aws_creds[0][1], aws_creds[0][2]}
Copy link
Contributor

Choose a reason for hiding this comment

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

check matrix size both row and column to avoid index out of range

@chen-keinan
Copy link
Contributor

@VF-mbrauer thank you for the contribution, added a few comments

@chen-keinan chen-keinan added the managed container registry Issue is related to a manager container registry (e.g. ECR, GCR, Harbor, etc.) label Mar 29, 2022
@CLAassistant
Copy link

CLAassistant commented Apr 2, 2022

CLA assistant check
All committers have signed the CLA.

@VF-mbrauer
Copy link
Contributor Author

Due to the new Release 0.15.0 the PR needed to be rebased. For this, a new PR has been created #1103
This PR can be closed.

@VF-mbrauer VF-mbrauer closed this Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
managed container registry Issue is related to a manager container registry (e.g. ECR, GCR, Harbor, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants