-
Notifications
You must be signed in to change notification settings - Fork 142
Simplify ssh config management #4453
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
base: ssh-tunnel-ide-flag
Are you sure you want to change the base?
Conversation
3617fc2 to
b563b61
Compare
| return "", fmt.Errorf("failed to check if secret scope %s exists: %w", secretScopeName, err) | ||
| } | ||
|
|
||
| if scope != nil && err == nil { |
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.
Is the scope != nil check redundant when err == nil?
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 scope can be a default value with empty secrets
| func escapeEnvValue(val string) string { | ||
| val = strings.ReplaceAll(val, "\r", "") | ||
| val = strings.ReplaceAll(val, "\n", "") | ||
| val = strings.ReplaceAll(val, "\"", "\\\"") |
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 need to escape the backslashes too, and it should before escaping the quotes. consider the following test cases:
{
name: "quote mid string",
input: `foo"bar`,
expected: `foo\"bar`,
},
{
name: "quote end of string",
input: `foo bar"`,
expected: `foo bar\"`,
},
{
name: "backslash end of string",
input: `foo bar\`,
expected: `foo bar\\`,
},
{
name: "backslash before quote",
input: `foo\"bar`,
expected: `foo\\\"bar`,
},
anton-107
left a comment
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.
please double check the escaping sequence for SetEnv
b563b61 to
fa28809
Compare
947c492 to
b5cc387
Compare
fa28809 to
f86fdf3
Compare
Changes
Simplify sshd config management, so we can easily re-use it. The main change is that we add one "include" directive to the system ssh config, and all new host configs are encapsulated in single files, which are easy to replace or add.
Here we also solve a separate logic of proper escaping env vars, as before we were letting new lines sneak into SetEnv directive, which is not allowed
Based on #4452
Why
Tests