Skip to content

Commit 65f4ccc

Browse files
committed
C++: Another test case.
1 parent 0031ed3 commit 65f4ccc

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ edges
147147
| test3.cpp:324:11:324:14 | data | test3.cpp:324:11:324:14 | ref arg data |
148148
| test3.cpp:324:11:324:14 | ref arg data | test3.cpp:325:11:325:14 | data |
149149
| test3.cpp:325:11:325:14 | data | test3.cpp:298:20:298:23 | data |
150+
| test3.cpp:352:16:352:23 | password | test3.cpp:353:4:353:18 | call to decrypt_inplace |
151+
| test3.cpp:352:16:352:23 | password | test3.cpp:353:20:353:27 | password |
152+
| test3.cpp:352:16:352:23 | password | test3.cpp:353:20:353:27 | password |
153+
| test3.cpp:353:20:353:27 | password | test3.cpp:353:4:353:18 | call to decrypt_inplace |
150154
| test.cpp:48:29:48:39 | thePassword | test.cpp:48:21:48:27 | call to encrypt |
151155
| test.cpp:58:11:58:16 | passwd | test.cpp:61:11:61:16 | passwd |
152156
| test.cpp:76:29:76:39 | thePassword | test.cpp:76:21:76:27 | call to encrypt |
@@ -311,6 +315,12 @@ nodes
311315
| test3.cpp:324:11:324:14 | data | semmle.label | data |
312316
| test3.cpp:324:11:324:14 | ref arg data | semmle.label | ref arg data |
313317
| test3.cpp:325:11:325:14 | data | semmle.label | data |
318+
| test3.cpp:341:16:341:23 | password | semmle.label | password |
319+
| test3.cpp:352:16:352:23 | password | semmle.label | password |
320+
| test3.cpp:352:16:352:23 | password | semmle.label | password |
321+
| test3.cpp:353:4:353:18 | call to decrypt_inplace | semmle.label | call to decrypt_inplace |
322+
| test3.cpp:353:20:353:27 | password | semmle.label | password |
323+
| test3.cpp:353:20:353:27 | password | semmle.label | password |
314324
| test.cpp:45:9:45:19 | thePassword | semmle.label | thePassword |
315325
| test.cpp:48:21:48:27 | call to encrypt | semmle.label | call to encrypt |
316326
| test.cpp:48:29:48:39 | thePassword | semmle.label | thePassword |
@@ -352,3 +362,4 @@ subpaths
352362
| test3.cpp:290:2:290:5 | call to send | test3.cpp:316:11:316:18 | password | test3.cpp:290:14:290:17 | data | This operation transmits 'data', which may contain unencrypted sensitive data from $@ | test3.cpp:316:11:316:18 | password | password |
353363
| test3.cpp:295:2:295:5 | call to send | test3.cpp:316:11:316:18 | password | test3.cpp:295:14:295:17 | data | This operation transmits 'data', which may contain unencrypted sensitive data from $@ | test3.cpp:316:11:316:18 | password | password |
354364
| test3.cpp:300:2:300:5 | call to send | test3.cpp:316:11:316:18 | password | test3.cpp:300:14:300:17 | data | This operation transmits 'data', which may contain unencrypted sensitive data from $@ | test3.cpp:316:11:316:18 | password | password |
365+
| test3.cpp:341:4:341:7 | call to recv | test3.cpp:341:16:341:23 | password | test3.cpp:341:16:341:23 | password | This operation receives into 'password', which may put unencrypted sensitive data into $@ | test3.cpp:341:16:341:23 | password | password |

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,29 @@ void test_multiple_sources_source(char *password)
330330
target6(data);
331331
}
332332
}
333+
334+
void test_loops()
335+
{
336+
{
337+
while (cond())
338+
{
339+
char password[256];
340+
341+
recv(val(), password, 256, val()); // BAD: not encrypted
342+
343+
// ...
344+
}
345+
}
346+
347+
{
348+
while (cond())
349+
{
350+
char password[256];
351+
352+
recv(val(), password, 256, val()); // GOOD: password is encrypted
353+
decrypt_inplace(password); // proof that `password` was in fact encrypted
354+
355+
// ...
356+
}
357+
}
358+
}

0 commit comments

Comments
 (0)