Skip to content

Commit 61c18b5

Browse files
committed
remove space and newline checks
1 parent f664745 commit 61c18b5

2 files changed

Lines changed: 0 additions & 49 deletions

File tree

pkg/splunk/util/util.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -173,25 +173,6 @@ func ValidateSecret(tokenValue []byte) error {
173173
return fmt.Errorf("secret is empty")
174174
}
175175

176-
secretStr := string(tokenValue)
177-
178-
// Check for leading or trailing whitespace
179-
if secretStr != strings.TrimSpace(secretStr) {
180-
return fmt.Errorf("secret has leading or trailing whitespace")
181-
}
182-
183-
// Check for newlines
184-
if strings.Contains(secretStr, "\n") || strings.Contains(secretStr, "\r") {
185-
return fmt.Errorf("secret contains newlines")
186-
}
187-
188-
// Check for control characters (ASCII 0-31 and 127)
189-
for _, ch := range secretStr {
190-
if ch < 32 || ch == 127 {
191-
return fmt.Errorf("secret contains control characters")
192-
}
193-
}
194-
195176
// Minimum length for secrets (at least 12 characters)
196177
const minLength = 12
197178
if len(tokenValue) < minLength {

pkg/splunk/util/util_test.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -480,36 +480,6 @@ func TestValidateSecret(t *testing.T) {
480480
tokenVal: []byte("12345678901"),
481481
wantError: true,
482482
},
483-
{
484-
name: "secret with leading whitespace",
485-
tokenVal: []byte(" 123456789012"),
486-
wantError: true,
487-
},
488-
{
489-
name: "secret with trailing whitespace",
490-
tokenVal: []byte("123456789012 "),
491-
wantError: true,
492-
},
493-
{
494-
name: "secret with newline",
495-
tokenVal: []byte("12345678901\n23"),
496-
wantError: true,
497-
},
498-
{
499-
name: "secret with carriage return",
500-
tokenVal: []byte("12345678901\r23"),
501-
wantError: true,
502-
},
503-
{
504-
name: "secret with control character (tab)",
505-
tokenVal: []byte("12345678901\t23"),
506-
wantError: true,
507-
},
508-
{
509-
name: "secret with null character",
510-
tokenVal: []byte("12345678901\x0023"),
511-
wantError: true,
512-
},
513483
}
514484

515485
for _, tt := range tests {

0 commit comments

Comments
 (0)