Skip to content

Commit 974a8b1

Browse files
committed
C++: Add a test case.
1 parent 065043b commit 974a8b1

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

cpp/ql/test/query-tests/Security/CWE/CWE-311/semmle/tests/CleartextTransmission.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ edges
8484
| test3.cpp:350:9:350:16 | password | test3.cpp:352:16:352:23 | password |
8585
| test3.cpp:350:9:350:16 | password | test3.cpp:353:4:353:18 | call to decrypt_inplace |
8686
| test3.cpp:350:9:350:16 | password | test3.cpp:353:20:353:27 | password |
87+
| test3.cpp:366:8:366:15 | password | test3.cpp:368:15:368:22 | password |
8788
| test.cpp:41:23:41:43 | cleartext password! | test.cpp:48:21:48:27 | call to encrypt |
8889
| test.cpp:41:23:41:43 | cleartext password! | test.cpp:48:29:48:39 | thePassword |
8990
| test.cpp:66:23:66:43 | cleartext password! | test.cpp:76:21:76:27 | call to encrypt |
@@ -195,6 +196,8 @@ nodes
195196
| test3.cpp:352:16:352:23 | password | semmle.label | password |
196197
| test3.cpp:353:4:353:18 | call to decrypt_inplace | semmle.label | call to decrypt_inplace |
197198
| test3.cpp:353:20:353:27 | password | semmle.label | password |
199+
| test3.cpp:366:8:366:15 | password | semmle.label | password |
200+
| test3.cpp:368:15:368:22 | password | semmle.label | password |
198201
| test.cpp:41:23:41:43 | cleartext password! | semmle.label | cleartext password! |
199202
| test.cpp:48:21:48:27 | call to encrypt | semmle.label | call to encrypt |
200203
| test.cpp:48:29:48:39 | thePassword | semmle.label | thePassword |
@@ -226,3 +229,4 @@ subpaths
226229
| test3.cpp:295:2:295:5 | call to send | test3.cpp:308:58:308:66 | password2 | test3.cpp:295:14:295:17 | data | This operation transmits 'data', which may contain unencrypted sensitive data from $@ | test3.cpp:308:58:308:66 | password2 | password2 |
227230
| test3.cpp:300:2:300:5 | call to send | test3.cpp:308:58:308:66 | password2 | test3.cpp:300:14:300:17 | data | This operation transmits 'data', which may contain unencrypted sensitive data from $@ | test3.cpp:308:58:308:66 | password2 | password2 |
228231
| test3.cpp:341:4:341:7 | call to recv | test3.cpp:339:9:339:16 | password | test3.cpp:341:16:341:23 | password | This operation receives into 'password', which may put unencrypted sensitive data into $@ | test3.cpp:339:9:339:16 | password | password |
232+
| test3.cpp:368:3:368:6 | call to recv | test3.cpp:366:8:366:15 | password | test3.cpp:368:15:368:22 | password | This operation receives into 'password', which may put unencrypted sensitive data into $@ | test3.cpp:366:8:366:15 | password | password |

cpp/ql/test/query-tests/Security/CWE/CWE-311/semmle/tests/test3.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,21 @@ void test_loops()
356356
}
357357
}
358358
}
359+
360+
void DoDisguisedOperation(char *buffer, size_t size);
361+
void SecureZeroBuffer(char *buffer, size_t size);
362+
363+
void test_securezero()
364+
{
365+
{
366+
char password[256];
367+
368+
recv(val(), password, 256, val()); // GOOD: password is (probably) encrypted [FALSE POSITIVE]
369+
370+
DoDisguisedOperation(password, 256); // decryption (disguised)
371+
372+
// ...
373+
374+
SecureZeroBuffer(password, 256); // evidence we may have been doing decryption
375+
}
376+
}

0 commit comments

Comments
 (0)