-
Notifications
You must be signed in to change notification settings - Fork 383
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
Set a default User-Agent if unset #1115
Conversation
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.
Thanks! This captures the most important part of containers/skopeo#1109 .
LGTM, hoping for a second pair of eyes to review for possible risks we might have missed.
Yeah. I wouldn’t mind a test for OTOH the cost/benefit ratio of writing tests for this really is pretty bad — if this will ever be broken, it will probably not be individually broken, but just moved or bypassed in a way that a unit test would not detect. It would make more sense to incorporate a test into something a bit more end-to-end, at least like #254, but that has proven to be a nightmare to maintain and is probably not going to happen in this repo. |
a28fe94
to
70fd656
Compare
I've added the simplest test I can imagine (that actually involves sending an http request). |
LGTM |
docker/docker_client.go
Outdated
@@ -277,9 +279,15 @@ func newDockerClient(sys *types.SystemContext, registry, reference string) (*doc | |||
} | |||
tlsClientConfig.InsecureSkipVerify = skipVerify | |||
|
|||
userAgent := "containers-image/" + version.Version |
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.
Any chance we can do something like "github.com/containers/image"? Not sure that's allowed but the source would be more explicit.
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.
Any chance we can do something like "github.com/containers/image"? Not sure that's allowed but the source would be more explicit.
I believe "something like", yes, but not exactly:
User-Agent = "User-Agent" ":" 1*( product | comment )
product = token ["/" product-version]
product-version = token
token = 1*<any CHAR except CTLs or tspecials>
tspecials = "(" | ")" | "<" | ">" | "@"
| "," | ";" | ":" | "\" | <">
| "/" | "[" | "]" | "?" | "="
| "{" | "}" | SP | HT
comment = "(" *( ctext | comment ) ")"
ctext = <any TEXT excluding "(" and ")">
TEXT = <any OCTET except CTLs,
but including LWS>
From https://tools.ietf.org/html/rfc1945#section-2.2 and https://tools.ietf.org/html/rfc1945#section-3.7 and https://tools.ietf.org/html/rfc1945#section-10.15
token
forbids /
, but we could add it to the comment
, which can include anything other than (
, )
, control characters, and newlines.
How about this?
User-Agent: containers/$VERSION (github.com/containers/image)
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.
70fd656
to
d40fc55
Compare
Updated the PR description and pushed the suggestion of Let me know if you'd prefer I squash the commits so that the commit message makes more sense. |
Currently, the User-Agent defaults to a golang default of either: Go-http-client/1.1 Go-http-client/2.0 This makes it rather difficult to distinguish this client from any other random golang program in registry logs. Instead, set the default User-Agent to: containers/$VERSION (github.com/containers/image) Signed-off-by: Jon Johnson <[email protected]>
d40fc55
to
340d609
Compare
LGTM |
Currently, the User-Agent defaults to a golang default of either:
Go-http-client/1.1
Go-http-client/2.0
This makes it rather difficult to distinguish this client from any other
random golang program in registry logs.
Instead, set the default User-Agent to
"containers/$VERSION (github.com/containers/image)"
.Context: containers/skopeo#1109
Signed-off-by: Jon Johnson [email protected]