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
|
// Remove sensitive env variables from cmd process
|
||||||
for _, env := range getSensitiveEnvs() {
|
cmd.Env = removeSensitiveEnvs(cmd.Env)
|
||||||
cmd.Env = append(cmd.Env, env+"=")
|
|
||||||
}
|
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,13 @@ package db_lib
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/ansible-semaphore/semaphore/pkg/task_logger"
|
"github.com/ansible-semaphore/semaphore/pkg/task_logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getSensitiveEnvs() []string {
|
func removeSensitiveEnvs(envs []string) (res []string) {
|
||||||
return []string{
|
sensitives := []string{
|
||||||
"SEMAPHORE_ACCESS_KEY_ENCRYPTION",
|
"SEMAPHORE_ACCESS_KEY_ENCRYPTION",
|
||||||
"SEMAPHORE_ADMIN_PASSWORD",
|
"SEMAPHORE_ADMIN_PASSWORD",
|
||||||
"SEMAPHORE_DB_USER",
|
"SEMAPHORE_DB_USER",
|
||||||
@ -16,6 +17,16 @@ func getSensitiveEnvs() []string {
|
|||||||
"SEMAPHORE_DB_PASS",
|
"SEMAPHORE_DB_PASS",
|
||||||
"SEMAPHORE_LDAP_PASSWORD",
|
"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 {
|
type LocalApp interface {
|
||||||
|
@ -53,9 +53,7 @@ func (t *ShellApp) makeCmd(command string, args []string, environmentVars *[]str
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove sensitive env variables from cmd process
|
// Remove sensitive env variables from cmd process
|
||||||
for _, env := range getSensitiveEnvs() {
|
cmd.Env = removeSensitiveEnvs(cmd.Env)
|
||||||
cmd.Env = append(cmd.Env, env+"=")
|
|
||||||
}
|
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
@ -52,9 +52,7 @@ func (t *TerraformApp) makeCmd(command string, args []string, environmentVars *[
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove sensitive env variables from cmd process
|
// Remove sensitive env variables from cmd process
|
||||||
for _, env := range getSensitiveEnvs() {
|
cmd.Env = removeSensitiveEnvs(cmd.Env)
|
||||||
cmd.Env = append(cmd.Env, env+"=")
|
|
||||||
}
|
|
||||||
|
|
||||||
return cmd
|
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