@@ -13,7 +13,7 @@ import (
13
13
cristal "github.com/cristalhq/jwt/v3"
14
14
)
15
15
16
- func cristalhq () (interface {}, error ) {
16
+ func check_ok () (interface {}, error ) {
17
17
key := []byte (`key` )
18
18
return cristal .NewSignerHS (cristal .HS256 , key ) // BAD
19
19
}
@@ -40,6 +40,7 @@ func GenerateCryptoString2(n int) (string, error) {
40
40
}
41
41
return string (ret ), nil
42
42
}
43
+
43
44
func GenerateRandomString3 (size int ) string {
44
45
const characters = `0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`
45
46
var bytes = make ([]byte , size )
@@ -72,45 +73,44 @@ func RandString(length int64) string {
72
73
73
74
return string (result )
74
75
}
75
- func genKey (size int ) (string , error ) {
76
- err := errors .New ("size too small" )
77
- return "" , err
78
- }
79
- func test1 () {
76
+
77
+ func randIntSanitizerModulo_test () (interface {}, error ) {
80
78
key := GenerateRandomString (32 )
81
- return cristal .NewSignerHS (cristal .HS256 , key ) // GOOD
79
+ return cristal .NewSignerHS (cristal .HS256 , [] byte ( key ) ) // GOOD
82
80
}
83
81
84
- func test2 ( ) {
82
+ func randIntSanitizer_test () ( interface {}, error ) {
85
83
key2 , _ := GenerateCryptoString2 (32 )
86
- return cristal .NewSignerHS (cristal .HS256 , key2 ) // GOOD
84
+ return cristal .NewSignerHS (cristal .HS256 , [] byte ( key2 ) ) // GOOD
87
85
}
88
86
89
- func test3 ( ) {
87
+ func formattingSanitizer_test () ( interface {}, error ) {
90
88
key3 := RandAuthToken ()
91
- return cristal .NewSignerHS (cristal .HS256 , key3 ) // GOOD
89
+ return cristal .NewSignerHS (cristal .HS256 , [] byte ( key3 ) ) // GOOD
92
90
}
93
91
94
- func test4 () (interface {} , error ) {
95
- key4 , err := genKey ( 21 )
96
- if err != nil {
97
- return nil , err
98
- }
92
+ func genKey () (string , error ) {
93
+ k := "asd"
94
+ e := errors . New ( "no key" )
95
+ return k , e
96
+ }
99
97
100
- return cristal .NewSignerHS (cristal .HS256 , key4 ) // BAD
98
+ func emptyErrorSanitizer_test () (interface {}, error ) {
99
+ key4 , _ := genKey ()
100
+ return cristal .NewSignerHS (cristal .HS256 , []byte (key4 )) // GOOD
101
101
}
102
102
103
- func test5 () (interface {}, error ) {
104
- temp := "test"
105
- if temp != "test" {
106
- return cristal .NewSignerHS (cristal .HS256 , []byte (temp )), nil // GOOD
107
- } else {
108
- return nil , nil
103
+ func compareSanitizerTest () (interface {}, error ) {
104
+ key5 := ""
105
+ if key5 != "" {
106
+ return cristal .NewSignerHS (cristal .HS256 , []byte (key5 )) // GOOD
109
107
}
108
+ return "" , nil
110
109
}
111
- func test6 () {
112
- key := GenerateRandomString3 (32 )
113
- return cristal .NewSignerHS (cristal .HS256 , key ) // GOOD
110
+
111
+ func randReadSanitizer_test () (interface {}, error ) {
112
+ key6 := GenerateRandomString3 (32 )
113
+ return cristal .NewSignerHS (cristal .HS256 , []byte (key6 )) // GOOD
114
114
}
115
115
116
116
func main () {
0 commit comments