Replace custom secureCompare with crypto/subtle.ConstantTimeCompare
All checks were successful
check / check (push) Successful in 2m7s
All checks were successful
check / check (push) Successful in 2m7s
Remove the hand-rolled secureCompare function and use the standard library's crypto/subtle.ConstantTimeCompare for CSRF token validation. Remove the corresponding unit test for the deleted function; CSRF token comparison is still covered by the integration tests.
This commit is contained in:
@@ -173,12 +173,3 @@ func TestGenerateCSRFToken(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.NotEqual(t, token, token2, "each generated token should be unique")
|
||||
}
|
||||
|
||||
func TestSecureCompare(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert.True(t, secureCompare("abc", "abc"))
|
||||
assert.False(t, secureCompare("abc", "abd"))
|
||||
assert.False(t, secureCompare("abc", "ab"))
|
||||
assert.False(t, secureCompare("", "a"))
|
||||
assert.True(t, secureCompare("", ""))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user