mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-24 22:06:43 +01:00
fix(be): remove sensitive env vars instead of set empty
This commit is contained in:
parent
d617280bc7
commit
8f77fde638
@ -38,9 +38,7 @@ func (p AnsiblePlaybook) makeCmd(command string, args []string, environmentVars
|
||||
}
|
||||
|
||||
// Remove sensitive env variables from cmd process
|
||||
for _, env := range getSensitiveEnvs() {
|
||||
cmd.Env = append(cmd.Env, env+"=")
|
||||
}
|
||||
cmd.Env = removeSensitiveEnvs(cmd.Env)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
@ -2,12 +2,13 @@ package db_lib
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/ansible-semaphore/semaphore/pkg/task_logger"
|
||||
)
|
||||
|
||||
func getSensitiveEnvs() []string {
|
||||
return []string{
|
||||
func removeSensitiveEnvs(envs []string) (res []string) {
|
||||
sensitives := []string{
|
||||
"SEMAPHORE_ACCESS_KEY_ENCRYPTION",
|
||||
"SEMAPHORE_ADMIN_PASSWORD",
|
||||
"SEMAPHORE_DB_USER",
|
||||
@ -16,6 +17,16 @@ func getSensitiveEnvs() []string {
|
||||
"SEMAPHORE_DB_PASS",
|
||||
"SEMAPHORE_LDAP_PASSWORD",
|
||||
}
|
||||
|
||||
for _, e := range envs {
|
||||
for _, s := range sensitives {
|
||||
if !strings.HasPrefix(e, s+"=") {
|
||||
res = append(res, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
type LocalApp interface {
|
||||
|
@ -53,9 +53,7 @@ func (t *ShellApp) makeCmd(command string, args []string, environmentVars *[]str
|
||||
}
|
||||
|
||||
// Remove sensitive env variables from cmd process
|
||||
for _, env := range getSensitiveEnvs() {
|
||||
cmd.Env = append(cmd.Env, env+"=")
|
||||
}
|
||||
cmd.Env = removeSensitiveEnvs(cmd.Env)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
@ -52,9 +52,7 @@ func (t *TerraformApp) makeCmd(command string, args []string, environmentVars *[
|
||||
}
|
||||
|
||||
// Remove sensitive env variables from cmd process
|
||||
for _, env := range getSensitiveEnvs() {
|
||||
cmd.Env = append(cmd.Env, env+"=")
|
||||
}
|
||||
cmd.Env = removeSensitiveEnvs(cmd.Env)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
@ -828,3 +828,13 @@ func CheckDefaultApps() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func PrintDebug() {
|
||||
envs := os.Environ()
|
||||
for _, e := range envs {
|
||||
fmt.Println(e)
|
||||
}
|
||||
|
||||
b, _ := Config.ToJSON()
|
||||
fmt.Println(string(b))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user