-
Notifications
You must be signed in to change notification settings - Fork 617
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
Redact ECR layer URLs from container pull errors #3885
Conversation
154de97
to
7624c56
Compare
7624c56
to
fd29a7a
Compare
if err == nil { | ||
return nil | ||
} | ||
urlRegex := regexp.MustCompile(`\"?https[^\s]+starport-layer-bucket[^\s]+`) |
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.
we're being very prescriptive in this redact function (ie this applies only to ECR). This is fine for now. I can see this being applicable to more cases in future.
Also nit maybe we call this not str
, but image
so it's clear that the error returns the image in place of the redacted URL?
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.
synced up offline with @prateekchaudhry, for now we are restricting redacting only ECR's URLs containing starport-layer-bucket
bucket name and cannot make this regex expression more generic as there is no evidence of other URLs containing security token and might need them for debugging purpose.
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.
That is right, being prescriptive is the intention - we can make it more generic if we have to in future.
Ack, I'll replace str
with overrideStr
to keep the function usage generic and more clear, if that is fine.
Summary
Redact error messages with URLs containing references to string
starport-layer-bucket
(ECR buckets). ECR buckets named asprod-region-starport-layer-bucket
are used to fetch image layers from.This redaction is done because container runtime's request may sometimes contain security tokens when accessing ECR buckets for pulling layers. When these requests error out, the URLs with secrets may get bubbled up to Agent logs and ECS logs through
Reason
field in Submit Task State Change calls. So we redact the otherwise hidden URLs for security.Implementation details
Replace regex
\"?https[^\s]+starport-layer-bucket[^\s]+
with a string message containing image referenceTesting
New tests cover the changes:
Yes
Description for the changelog
Redact ECR layer URLs from container pull errors
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.