Skip to content

Commit a0ea714

Browse files
committed
Swift: Add GOOD and BAD comments in the sensitive data hashing examples as well.
1 parent 80afa65 commit a0ea714

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

swift/ql/src/queries/Security/CWE-328/WeakSensitiveDataHashingBad.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ func getContentsAndHash(url: URL) -> (Data, String)? {
33
return nil
44
}
55

6-
let digest = Insecure.MD5.hash(data: data)
6+
let digest = Insecure.MD5.hash(data: data) // BAD: MD5 is not suitable for hashing sensitive data.
77
let hash = digest.map { String(format: "%02hhx", $0) }.joined()
88

99
return (data, hash)
10-
}
10+
}

swift/ql/src/queries/Security/CWE-328/WeakSensitiveDataHashingGood.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ func getContentsAndHash(url: URL) -> (Data, String)? {
33
return nil
44
}
55

6-
let digest = SHA512.hash(data: data)
6+
let digest = SHA512.hash(data: data) // GOOD: SHA-512 is suitable for hashing sensitive data.
77
let hash = digest.map { String(format: "%02hhx", $0) }.joined()
88

99
return (data, hash)
10-
}
10+
}

0 commit comments

Comments
 (0)