Skip to content

Commit 18948fe

Browse files
fix(security): resolve CodeQL code alerts
Resolves CodeQL alert(s): #320, #321, #322, #324, #325 CWE: CWE-117 (log injection), empty password in config
1 parent 834aadb commit 18948fe

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

.helm-repositories.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,18 @@ repositories:
77
keyFile: ''
88
name: bitnami
99
pass_credentials_all: false
10-
password: ''
1110
url: https://charts.bitnami.com/bitnami
12-
username: ''
1311
- caFile: ''
1412
certFile: ''
1513
insecure_skip_tls_verify: false
1614
keyFile: ''
1715
name: chainlink-qa
1816
pass_credentials_all: false
19-
password: ''
2017
url: https://raw.githubusercontent.com/smartcontractkit/qa-charts/gh-pages/
21-
username: ''
2218
- caFile: ''
2319
certFile: ''
2420
insecure_skip_tls_verify: false
2521
keyFile: ''
2622
name: grafana
2723
pass_credentials_all: false
28-
password: ''
2924
url: https://grafana.github.io/helm-charts
30-
username: ''

ops/localenv/main.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ func main() {
6666
}
6767
}
6868

69+
// sanitizeForOutput escapes newlines/carriage returns to prevent log injection (CWE-117).
70+
func sanitizeForOutput(s string) string {
71+
s = strings.ReplaceAll(s, "\\", "\\\\")
72+
s = strings.ReplaceAll(s, "\r", "\\r")
73+
s = strings.ReplaceAll(s, "\n", "\\n")
74+
return s
75+
}
76+
6977
func setEnvIfNotExists(key, defaultValue string) {
7078
value := os.Getenv(key)
7179
if value == "" {
@@ -98,7 +106,7 @@ func run(name string, f string, args ...string) {
98106
wg.Done()
99107
break
100108
}
101-
fmt.Print(string(p[:n]))
109+
fmt.Print(sanitizeForOutput(string(p[:n])))
102110
}
103111
}()
104112
go func() {
@@ -109,7 +117,7 @@ func run(name string, f string, args ...string) {
109117
wg.Done()
110118
break
111119
}
112-
fmt.Print(string(p[:n]))
120+
fmt.Print(sanitizeForOutput(string(p[:n])))
113121
}
114122
}()
115123

0 commit comments

Comments
 (0)