Skip to content

Commit

Permalink
fix(security): removing sensative env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
fiftin committed Oct 21, 2024
1 parent 06bb156 commit 089a10a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"args": ["server", "--config", "${workspaceFolder}/.devcontainer/config.json"],
"cwd": "${workspaceFolder}",
"env": {
"PATH": "${workspaceFolder}/.venv/bin:${env:PATH}"
"PATH": "${workspaceFolder}/.venv/bin:${env:PATH}",
"SEMAPHORE_ADMIN_PASSWORD": "test123"
}
},
{
Expand Down
19 changes: 14 additions & 5 deletions db_lib/LocalApp.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/ansible-semaphore/semaphore/pkg/task_logger"
)

func removeSensitiveEnvs(envs []string) (res []string) {
func isSensitiveVar(v string) bool {
sensitives := []string{
"SEMAPHORE_ACCESS_KEY_ENCRYPTION",
"SEMAPHORE_ADMIN_PASSWORD",
Expand All @@ -20,11 +20,20 @@ func removeSensitiveEnvs(envs []string) (res []string) {
"SEMAPHORE_RUNNER_ID",
}

for _, s := range sensitives {
if strings.HasPrefix(v, s+"=") {
return true
}
}

return false
}

func removeSensitiveEnvs(envs []string) (res []string) {

for _, e := range envs {
for _, s := range sensitives {
if !strings.HasPrefix(e, s+"=") {
res = append(res, e)
}
if !isSensitiveVar(e) {
res = append(res, e)
}
}

Expand Down

0 comments on commit 089a10a

Please sign in to comment.