Improve SCP username and destination path handling #1350
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.
What:
This allows the "@" symbol to be used in SCP usernames and improves the shell quoting of the destination path in the SCP alert script. It also adds a timeout in case SCP gets blocked even after establishing the target host connection.
Why:
This allows the alert to be used with Windows domain hosts as the destination for the report. It also avoids some situations where the alert would keep running indefinitely.
How:
This was tested by creating a "Username + Password" type credential for a Windows domain user with a username like "user@domain" and assigning it to an SCP alert.
When entering only the filename (e.g. "report.xml"), the report should be copied to the users home directory (e.g. "C:/Users/user") without any single quotes added to the file name.
Using a full path (like "C:\Test\report.xml") should also work and special characters like `, " or ' should not cause any problems as long as the path is valid and refers to an existing directory.
To test the timeout, the environment variable
GVMD_SCP_ALERT_TIMEOUT
was set to10s
before starting gvmd and the alert was configured to send the report to a nonexistent directory on a Windows test system, which would have otherwise blocked the alert indefinitely.Checklist: