- Notifications
You must be signed in to change notification settings - Fork928
provisioner: don't pass CODER_ variables#4638
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package terraform | ||
import ( | ||
"os" | ||
"strings" | ||
) | ||
// We must clean CODER_ environment variables to avoid accidentally passing in | ||
// secrets like the Postgres connection string. See | ||
// https://github.com/coder/coder/issues/4635. | ||
// | ||
// safeEnviron() is provided as an os.Environ() alternative that strips CODER_ | ||
// variables. As an additional precaution, we check a canary variable before | ||
// provisioner exec. | ||
// | ||
// We cannot strip all CODER_ variables at exec because some are used to | ||
// configure the provisioner. | ||
const unsafeEnvCanary = "CODER_DONT_PASS" | ||
func init() { | ||
os.Setenv(unsafeEnvCanary, "true") | ||
} | ||
func envName(env string) string { | ||
parts := strings.SplitN(env, "=", 1) | ||
if len(parts) > 0 { | ||
return parts[0] | ||
} | ||
return "" | ||
} | ||
func isCanarySet(env []string) bool { | ||
for _, e := range env { | ||
if envName(e) == unsafeEnvCanary { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
// safeEnviron wraps os.Environ but removes CODER_ environment variables. | ||
func safeEnviron() []string { | ||
env := os.Environ() | ||
strippedEnv := make([]string, 0, len(env)) | ||
for _, e := range env { | ||
name := envName(e) | ||
if strings.HasPrefix(name, "CODER_") { | ||
continue | ||
} | ||
strippedEnv = append(strippedEnv, e) | ||
} | ||
return strippedEnv | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -68,8 +68,8 @@ export const AgentLatency: FC<{ agent: WorkspaceAgent }> = ({ agent }) => { | ||||||
> | ||||||
<HelpTooltipTitle>Latency</HelpTooltipTitle> | ||||||
<HelpTooltipText> | ||||||
This is the latency overhead on non peer to peerconnections. The star | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change
| ||||||
indicates the preferred relay. | ||||||
</HelpTooltipText> | ||||||
<HelpTooltipText> | ||||||
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.