File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff 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\n 23" ),
496- wantError : true ,
497- },
498- {
499- name : "secret with carriage return" ,
500- tokenVal : []byte ("12345678901\r 23" ),
501- wantError : true ,
502- },
503- {
504- name : "secret with control character (tab)" ,
505- tokenVal : []byte ("12345678901\t 23" ),
506- wantError : true ,
507- },
508- {
509- name : "secret with null character" ,
510- tokenVal : []byte ("12345678901\x00 23" ),
511- wantError : true ,
512- },
513483 }
514484
515485 for _ , tt := range tests {
You can’t perform that action at this time.
0 commit comments