-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Go: Support private registries via GOPROXY
#19248
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
Conversation
go/extractor/util/registryproxy.go
Outdated
} else { | ||
// We only care about private registry configurations that are relevant to Go and | ||
// filter others out at this point. | ||
proxy_configs = make([]RegistryConfig, 0) |
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.
You could use the length of val
as a third argument to make, which specifies the capacity of the underlying array. Or maybe it isn't worth it if you only ever expect very few.
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 only expect a few (indeed, the UI only supports configuring one at the moment). That said, I have noticed since that calling make
to initialise the array isn't necessary since append
will apparently do this if it is nil
anyway.
425ea73
to
e805d1e
Compare
// The address of the proxy including protocol and port (e.g. http://localhost:1234) | ||
var proxy_address string | ||
|
||
// The path to the temporary file that stores the proxy certificate, if any. | ||
var proxy_cert_file string | ||
|
||
// An array of registry configurations that are relevant to Go. | ||
// This excludes other registry configurations that may be available, but are not relevant to Go. | ||
var proxy_configs []RegistryConfig |
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.
These no longer need to be global variables. I think it would be clearer if they were just local variables.
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.
I somewhat intentionally left these as global variables so that we can access their values elsewhere if needed going forward.
I don't feel strongly about this though, so if you would prefer it to be locals for now while they don't have to be globals, then I can make that change.
This PR is part of work to enable private package registries to be used in Default Setup. See prior work for C#: #18029 and #18850
The existing Default Setup workflow will initialise the Dependabot package proxy, if a private package registry configuration is set. The host, port, certificate, and configurations used by the proxy are then passed to CodeQL in the
analyze
step. For Go, we will likely need to modify this to make these environment variables available to theautobuild
step as well.The changes in this PR modify the Go extractor to recognise when the corresponding environment variables are set. If so, we use the data from those environment variables to:
go
via theHTTP_PROXY
andHTTPS_PROXY
environment variables.go
viaSSL_CERT_FILE
.goproxy_server
configurations and use them to set an appropriate value for theGOPROXY
environment variable.This has the effect that
go
will attempt to make requests to obtain packages to theGOPROXY
servers. These will go via the Dependabot proxy configured byHTTP_PROXY
andHTTPS_PROXY
, which handles the needed authentication for theGOPROXY
servers.