Skip to content

Commit 776df33

Browse files
committed
Swift: fix typos and comments in testCrypto.swift
1 parent a8a34ad commit 776df33

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

swift/ql/test/query-tests/Security/CWE-328/testCrypto.swift

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,23 @@ func testHashMethods(passwd : UnsafeRawBufferPointer, cert: String, encrypted_pa
6666
hash = Crypto.Insecure.SHA1.hash(data: account_no) // BAD [NOT DETECTED]
6767
hash = Crypto.Insecure.SHA1.hash(data: credit_card_no) // BAD
6868

69-
hash = Crypto.SHA256.hash(data: passwd) // BAD [NOT DETECTED] not a computationally hard hash
70-
hash = Crypto.SHA256.hash(data: cert) // GOOD
71-
hash = Crypto.SHA256.hash(data: account_no) // GOOD
72-
hash = Crypto.SHA256.hash(data: credit_card_no) // GOOD
73-
hash = Crypto.SHA256.hash(data: credit_card_no) // GOOD
74-
75-
hash = Crypto.SHA256.hash(data: passwd) // BAD [NOT DETECTED] not a computationally hard hash
76-
hash = Crypto.SHA384.hash(data: cert) // GOOD
77-
hash = Crypto.SHA384.hash(data: account_no) // GOOD
78-
hash = Crypto.SHA384.hash(data: credit_card_no) // GOOD
79-
hash = Crypto.SHA384.hash(data: credit_card_no) // GOOD
80-
81-
hash = Crypto.SHA256.hash(data: passwd) // BAD [NOT DETECTED] not a computationally hard hash
82-
hash = Crypto.SHA512.hash(data: cert) // GOOD
83-
hash = Crypto.SHA512.hash(data: account_no) // GOOD
84-
hash = Crypto.SHA512.hash(data: credit_card_no) // GOOD
85-
hash = Crypto.SHA512.hash(data: credit_card_no) // GOOD
69+
hash = Crypto.SHA256.hash(data: passwd) // BAD [NOT DETECTED] not a computationally expensive hash
70+
hash = Crypto.SHA256.hash(data: cert) // GOOD, computationally expensive hash not required
71+
hash = Crypto.SHA256.hash(data: account_no) // GOOD, computationally expensive hash not required
72+
hash = Crypto.SHA256.hash(data: credit_card_no) // GOOD, computationally expensive hash not required
73+
hash = Crypto.SHA256.hash(data: credit_card_no) // GOOD, computationally expensive hash not required
74+
75+
hash = Crypto.SHA384.hash(data: passwd) // BAD [NOT DETECTED] not a computationally expensive hash
76+
hash = Crypto.SHA384.hash(data: cert) // GOOD, computationally expensive hash not required
77+
hash = Crypto.SHA384.hash(data: account_no) // GOOD, computationally expensive hash not required
78+
hash = Crypto.SHA384.hash(data: credit_card_no) // GOOD, computationally expensive hash not required
79+
hash = Crypto.SHA384.hash(data: credit_card_no) // GOOD, computationally expensive hash not required
80+
81+
hash = Crypto.SHA512.hash(data: passwd) // BAD [NOT DETECTED] not a computationally expensive hash
82+
hash = Crypto.SHA512.hash(data: cert) // GOOD, computationally expensive hash not required
83+
hash = Crypto.SHA512.hash(data: account_no) // GOOD, computationally expensive hash not required
84+
hash = Crypto.SHA512.hash(data: credit_card_no) // GOOD, computationally expensive hash not required
85+
hash = Crypto.SHA512.hash(data: credit_card_no) // GOOD, computationally expensive hash not required
8686
}
8787

8888
func testMD5UpdateWithData(passwd : String, cert: String, encrypted_passwd : String, account_no : String, credit_card_no : String) {
@@ -105,23 +105,23 @@ func testSHA1UpdateWithData(passwd : String, cert: String, encrypted_passwd : St
105105

106106
func testSHA256UpdateWithData(passwd : String, cert: String, encrypted_passwd : String, account_no : String, credit_card_no : String) {
107107
var hash = Crypto.SHA256()
108-
hash.update(data: passwd) // BAD [NOT DETECTED] not a computationally hard hash
108+
hash.update(data: passwd) // BAD [NOT DETECTED] not a computationally expensive hash
109109
hash.update(data: cert) // GOOD
110110
hash.update(data: account_no) // GOOD
111111
hash.update(data: credit_card_no) // GOOD
112112
}
113113

114114
func testSHA384UpdateWithData(passwd : String, cert: String, encrypted_passwd : String, account_no : String, credit_card_no : String) {
115115
var hash = Crypto.SHA384()
116-
hash.update(data: passwd) // BAD [NOT DETECTED] not a computationally hard hash
116+
hash.update(data: passwd) // BAD [NOT DETECTED] not a computationally expensive hash
117117
hash.update(data: cert) // GOOD
118118
hash.update(data: account_no) // GOOD
119119
hash.update(data: credit_card_no) // GOOD
120120
}
121121

122122
func testSHA512UpdateWithData(passwd : String, cert: String, encrypted_passwd : String, account_no : String, credit_card_no : String) {
123123
var hash = Crypto.SHA512()
124-
hash.update(data: passwd) // BAD [NOT DETECTED] not a computationally hard hash
124+
hash.update(data: passwd) // BAD [NOT DETECTED] not a computationally expensive hash
125125
hash.update(data: cert) // GOOD
126126
hash.update(data: account_no) // GOOD
127127
hash.update(data: credit_card_no) // GOOD
@@ -147,23 +147,23 @@ func testSHA1UpdateWithUnsafeRawBufferPointer(passwd : UnsafeRawBufferPointer, c
147147

148148
func testSHA256UpdateWithUnsafeRawBufferPointer(passwd : UnsafeRawBufferPointer, cert: UnsafeRawBufferPointer, encrypted_passwd : UnsafeRawBufferPointer, account_no : UnsafeRawBufferPointer, credit_card_no : UnsafeRawBufferPointer) {
149149
var hash = Crypto.SHA256()
150-
hash.update(bufferPointer: passwd) // BAD [NOT DETECTED] not a computationally hard hash
150+
hash.update(bufferPointer: passwd) // BAD [NOT DETECTED] not a computationally expensive hash
151151
hash.update(bufferPointer: cert) // GOOD
152152
hash.update(bufferPointer: account_no) // GOOD
153153
hash.update(bufferPointer: credit_card_no) // GOOD
154154
}
155155

156156
func testSHA384UpdateWithUnsafeRawBufferPointer(passwd : UnsafeRawBufferPointer, cert: UnsafeRawBufferPointer, encrypted_passwd : UnsafeRawBufferPointer, account_no : UnsafeRawBufferPointer, credit_card_no : UnsafeRawBufferPointer) {
157157
var hash = Crypto.SHA384()
158-
hash.update(bufferPointer: passwd) // BAD [NOT DETECTED] not a computationally hard hash
158+
hash.update(bufferPointer: passwd) // BAD [NOT DETECTED] not a computationally expensive hash
159159
hash.update(bufferPointer: cert) // GOOD
160160
hash.update(bufferPointer: account_no) // GOOD
161161
hash.update(bufferPointer: credit_card_no) // GOOD
162162
}
163163

164164
func testSHA512UpdateWithUnsafeRawBufferPointer(passwd : UnsafeRawBufferPointer, cert: UnsafeRawBufferPointer, encrypted_passwd : UnsafeRawBufferPointer, account_no : UnsafeRawBufferPointer, credit_card_no : UnsafeRawBufferPointer) {
165165
var hash = Crypto.SHA512()
166-
hash.update(bufferPointer: passwd) // BAD [NOT DETECTED] not a computationally hard hash
166+
hash.update(bufferPointer: passwd) // BAD [NOT DETECTED] not a computationally expensive hash
167167
hash.update(bufferPointer: cert) // GOOD
168168
hash.update(bufferPointer: account_no) // GOOD
169169
hash.update(bufferPointer: credit_card_no) // GOOD

0 commit comments

Comments
 (0)