-
Notifications
You must be signed in to change notification settings - Fork 6
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 flag to skip TLS verification when connection to ES #5
base: master
Are you sure you want to change the base?
Conversation
func addVCS(pkgpath string, doc map[string]interface{}) { | ||
pkg, err := build.Import(pkgpath, "", build.FindOnly) | ||
func addVCS(pkgpath string, doc map[string]interface{}) error { | ||
pkg, err := build.Import(pkgpath, "", build.IgnoreVendor) |
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.
Should this be build.FindOnly | build.IgnoreVendor
?
} | ||
resp, err := http.DefaultClient.Do(req) | ||
|
||
req.WithContext(ctx) |
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.
req.WithContext(ctx) | |
req = req.WithContext(ctx) |
@@ -279,7 +330,10 @@ func createMapping(cfg elasticsearchConfig) error { | |||
req.SetBasicAuth(cfg.user, cfg.pass) | |||
} | |||
req.Header.Set("Content-Type", "application/json") | |||
resp, err := http.DefaultClient.Do(req) | |||
|
|||
req.WithContext(ctx) |
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.
req.WithContext(ctx) | |
req = req.WithContext(ctx) |
WithContext does not mutate the original context.
flag.BoolVar(&cfg.shouldSkipTlsVerify, "tls-verify", true, | ||
"Should skip TLS verification.", | ||
) |
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.
The flag says "should skip ...", but the name presented to the user is "tls-verify" -- the name implies the reverse of what it's doing.
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.
BTW in #3 (comment), I said that the default should be true
. I misread the flag as "should verify" because of the name. So what I actually want is to verify by default, and users can opt out if they like.
This PR is a continuation of my last PR in this repository -> Original declined PR and I tried to implement the proposed changes.
Since Elastic 8.0 onwards Security is enabled by default Security settings in Elasticsearch .
Currently this tool has no means to handle some pretty common cases related to HTTPS communication, such as certificate verification. Currently it skips the whole certificate verification. Could be extented if the need arises.
Also, another drawback I encountered was the usage of the default http client in Go.
The way it is implemented it never timeouts, which could be a problem. I added a default limit of 600 seconds (10 minutes) to the command.
For our usecase we needed a way to identify the git author and thus added it to the mapping.
It's enabled by default for everyone, since I decided that this may be pretty common scenario, if needed I can flag it.