Skip to content

Commit a71bb4b

Browse files
committed
Convert test to inline expectations
1 parent 2c20d3f commit a71bb4b

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

go/ql/test/query-tests/Security/CWE-327/Crypto.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@ func crypto() {
1313
public := []byte("hello")
1414

1515
password := []byte("123456")
16-
buf := password // testing dataflow by passing into different variable
16+
17+
// testing dataflow by passing into different variable
18+
buf := password // $ Source
1719

1820
// BAD, des is a weak crypto algorithm and password is sensitive data
19-
des.NewTripleDESCipher(buf)
21+
des.NewTripleDESCipher(buf) // $ Alert
2022

2123
// BAD, md5 is a weak crypto algorithm and password is sensitive data
22-
md5.Sum(buf)
24+
md5.Sum(buf) // $ Alert
2325

2426
// BAD, rc4 is a weak crypto algorithm and password is sensitive data
25-
rc4.NewCipher(buf)
27+
rc4.NewCipher(buf) // $ Alert
2628

2729
// BAD, sha1 is a weak crypto algorithm and password is sensitive data
28-
sha1.Sum(buf)
30+
sha1.Sum(buf) // $ Alert
2931

3032
// GOOD, password is sensitive data but aes is a strong crypto algorithm
3133
aes.NewCipher(buf)
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1+
#select
2+
| Crypto.go:21:25:21:27 | buf | Crypto.go:18:9:18:16 | password | Crypto.go:21:25:21:27 | buf | $@ is used in a weak cryptographic algorithm. | Crypto.go:18:9:18:16 | password | Sensitive data |
3+
| Crypto.go:24:10:24:12 | buf | Crypto.go:18:9:18:16 | password | Crypto.go:24:10:24:12 | buf | $@ is used in a weak cryptographic algorithm. | Crypto.go:18:9:18:16 | password | Sensitive data |
4+
| Crypto.go:27:16:27:18 | buf | Crypto.go:18:9:18:16 | password | Crypto.go:27:16:27:18 | buf | $@ is used in a weak cryptographic algorithm. | Crypto.go:18:9:18:16 | password | Sensitive data |
5+
| Crypto.go:30:11:30:13 | buf | Crypto.go:18:9:18:16 | password | Crypto.go:30:11:30:13 | buf | $@ is used in a weak cryptographic algorithm. | Crypto.go:18:9:18:16 | password | Sensitive data |
16
edges
2-
| Crypto.go:16:9:16:16 | password | Crypto.go:19:25:19:27 | buf | provenance | |
3-
| Crypto.go:16:9:16:16 | password | Crypto.go:22:10:22:12 | buf | provenance | |
4-
| Crypto.go:16:9:16:16 | password | Crypto.go:25:16:25:18 | buf | provenance | |
5-
| Crypto.go:16:9:16:16 | password | Crypto.go:28:11:28:13 | buf | provenance | |
7+
| Crypto.go:18:9:18:16 | password | Crypto.go:21:25:21:27 | buf | provenance | |
8+
| Crypto.go:18:9:18:16 | password | Crypto.go:24:10:24:12 | buf | provenance | |
9+
| Crypto.go:18:9:18:16 | password | Crypto.go:27:16:27:18 | buf | provenance | |
10+
| Crypto.go:18:9:18:16 | password | Crypto.go:30:11:30:13 | buf | provenance | |
611
nodes
7-
| Crypto.go:16:9:16:16 | password | semmle.label | password |
8-
| Crypto.go:19:25:19:27 | buf | semmle.label | buf |
9-
| Crypto.go:22:10:22:12 | buf | semmle.label | buf |
10-
| Crypto.go:25:16:25:18 | buf | semmle.label | buf |
11-
| Crypto.go:28:11:28:13 | buf | semmle.label | buf |
12+
| Crypto.go:18:9:18:16 | password | semmle.label | password |
13+
| Crypto.go:21:25:21:27 | buf | semmle.label | buf |
14+
| Crypto.go:24:10:24:12 | buf | semmle.label | buf |
15+
| Crypto.go:27:16:27:18 | buf | semmle.label | buf |
16+
| Crypto.go:30:11:30:13 | buf | semmle.label | buf |
1217
subpaths
13-
#select
14-
| Crypto.go:19:25:19:27 | buf | Crypto.go:16:9:16:16 | password | Crypto.go:19:25:19:27 | buf | $@ is used in a weak cryptographic algorithm. | Crypto.go:16:9:16:16 | password | Sensitive data |
15-
| Crypto.go:22:10:22:12 | buf | Crypto.go:16:9:16:16 | password | Crypto.go:22:10:22:12 | buf | $@ is used in a weak cryptographic algorithm. | Crypto.go:16:9:16:16 | password | Sensitive data |
16-
| Crypto.go:25:16:25:18 | buf | Crypto.go:16:9:16:16 | password | Crypto.go:25:16:25:18 | buf | $@ is used in a weak cryptographic algorithm. | Crypto.go:16:9:16:16 | password | Sensitive data |
17-
| Crypto.go:28:11:28:13 | buf | Crypto.go:16:9:16:16 | password | Crypto.go:28:11:28:13 | buf | $@ is used in a weak cryptographic algorithm. | Crypto.go:16:9:16:16 | password | Sensitive data |
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
experimental/CWE-327/WeakCryptoAlgorithm.ql
1+
query: Security/CWE-327/WeakCryptoAlgorithm.ql
2+
postprocess:
3+
- utils/test/PrettyPrintModels.ql
4+
- utils/test/InlineExpectationsTestQuery.ql

0 commit comments

Comments
 (0)