Skip to content
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

Improve SCP username and destination path handling #1350

Merged
merged 6 commits into from
Nov 23, 2020

Conversation

timopollmeier
Copy link
Member

@timopollmeier timopollmeier commented Nov 10, 2020

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 to 10s 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:

This is required for domain usernames to work.
When using the SCP alert with Windows hosts, simply putting the
destination paths in single quotes does not work correctly,
so the bash builtin printf is used to escape the path instead.
This also changes the shell used to run the script from /bin/sh
to /bin/bash.
Under some conditions scp be blocked indefinitely after the connection
to the target host has been established, so the alert will now time out
eventually.
@timopollmeier timopollmeier marked this pull request as ready for review November 19, 2020 14:05
@mattmundell mattmundell merged commit 1c7c372 into greenbone:gvmd-20.08 Nov 23, 2020
@timopollmeier timopollmeier deleted the scp-alert-fix-20.08 branch October 15, 2021 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants