fix: No longer collect executable files #207
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
IHEDIAG-649
Infra log collection can collect .exe files
Goals
Ensure no executable files are being collected
Implementation Details
I updated the regex that is used in the Infra/Log/Collect task to be more specific. If the infra config has a log path that ends with
newrelic-infra.log
, the regex would be^newrelic-infra*
^newrelic-infra.*(.gz|.zip|.log)
I updated the FileCopyEnvelope struct with a function to check if a file is executable. For windows it just checks if the suffix is
.exe
. For Linux/Mac, it checks the file permissions as described in this stack overflow.I updated the paths we search for config files to include the paths for Infra on Mac installed via brew. Taken from this doc.
How to Test
go test ./...
I smoke tested by:
Skipping executable file:
is in the debug logging and that the log file is not in the zip