-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Heartbeat] Stop logging sensitive params #28774
Conversation
This change causes heartbeat to no longer log parameter values, instead interpolating an opaque string. Fixes elastic#28771 We now create logs like: ``` 2021-11-02T17:25:27.804-0500 INFO synthexec/synthexec.go:148 Running command: /tmp/elastic-synthetics-unzip-714880603/node_modules/.bin/elastic-synthetics /tmp/elastic-synthetics-unzip-714880603/node_modules/.bin/elastic-synthetics /tmp/elastic-synthetics-unzip-714880603 --screenshots on --rich-events --params "{1 hidden params}" in directory: '/tmp/elastic-synthetics-unzip-714880603' ```
Pinging @elastic/uptime (Team:Uptime) |
@@ -122,11 +122,6 @@ func runCmd( | |||
cmd.Env = append(os.Environ(), "NODE_ENV=production") | |||
cmd.Args = append(cmd.Args, "--rich-events") | |||
|
|||
if len(params) > 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.
I moved this lower since that we we only have to instantiate loggableCmd
once without updating args as they are added.
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
💚 Flaky test reportTests succeeded. 🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
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.
Good catch LGTM
@@ -135,14 +130,22 @@ func runCmd( | |||
cmd.Args = append(cmd.Args, "--match", filterJourneys.Match) | |||
} | |||
|
|||
// Variant of the command with no params, which could contain sensitive stuff | |||
loggableCmd := exec.Command(cmd.Path, cmd.Args...) |
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.
can we move this inside if statement and do only if user has specified params. We could initialize it with loggableCmd as cmd till this point.
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 can't do that really since we use it further down outside the if.
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.
My comment wasn't clear, I meant to move the exec command creation only when required like this.
loggableCmd := cmd
if len(params) > 0 {
loggableCmd = exec.Command(cmd.Path, cmd.Args...)
paramsBytes, _ := json.Marshal(params)
cmd.Args = append(cmd.Args, "--params", string(paramsBytes))
loggableCmd.Args = append(loggableCmd.Args, "--params", fmt.Sprintf("\"{%d hidden params}\"", len(params)))
}
* [Heartbeat] Stop logging sensitive params This change causes heartbeat to no longer log parameter values, instead interpolating an opaque string. Fixes #28771 We now create logs like: ``` 2021-11-02T17:25:27.804-0500 INFO synthexec/synthexec.go:148 Running command: /tmp/elastic-synthetics-unzip-714880603/node_modules/.bin/elastic-synthetics /tmp/elastic-synthetics-unzip-714880603/node_modules/.bin/elastic-synthetics /tmp/elastic-synthetics-unzip-714880603 --screenshots on --rich-events --params "{1 hidden params}" in directory: '/tmp/elastic-synthetics-unzip-714880603' ``` * Changelog (cherry picked from commit 40e949d)
* [Heartbeat] Stop logging sensitive params This change causes heartbeat to no longer log parameter values, instead interpolating an opaque string. Fixes #28771 We now create logs like: ``` 2021-11-02T17:25:27.804-0500 INFO synthexec/synthexec.go:148 Running command: /tmp/elastic-synthetics-unzip-714880603/node_modules/.bin/elastic-synthetics /tmp/elastic-synthetics-unzip-714880603/node_modules/.bin/elastic-synthetics /tmp/elastic-synthetics-unzip-714880603 --screenshots on --rich-events --params "{1 hidden params}" in directory: '/tmp/elastic-synthetics-unzip-714880603' ``` * Changelog (cherry picked from commit 40e949d) Co-authored-by: Andrew Cholakian <andrew@andrewvc.com>
* [Heartbeat] Stop logging sensitive params This change causes heartbeat to no longer log parameter values, instead interpolating an opaque string. Fixes #28771 We now create logs like: ``` 2021-11-02T17:25:27.804-0500 INFO synthexec/synthexec.go:148 Running command: /tmp/elastic-synthetics-unzip-714880603/node_modules/.bin/elastic-synthetics /tmp/elastic-synthetics-unzip-714880603/node_modules/.bin/elastic-synthetics /tmp/elastic-synthetics-unzip-714880603 --screenshots on --rich-events --params "{1 hidden params}" in directory: '/tmp/elastic-synthetics-unzip-714880603' ``` * Changelog (cherry picked from commit 40e949d)
* [Heartbeat] Stop logging sensitive params This change causes heartbeat to no longer log parameter values, instead interpolating an opaque string. Fixes #28771 We now create logs like: ``` 2021-11-02T17:25:27.804-0500 INFO synthexec/synthexec.go:148 Running command: /tmp/elastic-synthetics-unzip-714880603/node_modules/.bin/elastic-synthetics /tmp/elastic-synthetics-unzip-714880603/node_modules/.bin/elastic-synthetics /tmp/elastic-synthetics-unzip-714880603 --screenshots on --rich-events --params "{1 hidden params}" in directory: '/tmp/elastic-synthetics-unzip-714880603' ``` * Changelog (cherry picked from commit 40e949d) Co-authored-by: Andrew Cholakian <andrew@andrewvc.com>
This change causes heartbeat to no longer log parameter values, instead
interpolating an opaque string.
Fixes #28771
We now create logs like:
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Tested with https://github.com/elastic/synthetics-demo/blob/main/heartbeat/monitors.d/todos-zipurl.yml