Skip to content

Commit 3cfd1b5

Browse files
committed
C++: More test cases.
1 parent 3b844f7 commit 3cfd1b5

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
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
@@ -90,6 +90,7 @@ edges
9090
| test3.cpp:398:18:398:25 | password | test3.cpp:400:16:400:23 | password |
9191
| test3.cpp:398:18:398:25 | password | test3.cpp:400:33:400:40 | password |
9292
| test3.cpp:429:7:429:14 | password | test3.cpp:431:8:431:15 | password |
93+
| test3.cpp:465:8:465:15 | password | test3.cpp:474:11:474:18 | password |
9394
| test.cpp:41:23:41:43 | cleartext password! | test.cpp:48:21:48:27 | call to encrypt |
9495
| test.cpp:41:23:41:43 | cleartext password! | test.cpp:48:29:48:39 | thePassword |
9596
| test.cpp:66:23:66:43 | cleartext password! | test.cpp:76:21:76:27 | call to encrypt |
@@ -211,6 +212,8 @@ nodes
211212
| test3.cpp:400:33:400:40 | password | semmle.label | password |
212213
| test3.cpp:429:7:429:14 | password | semmle.label | password |
213214
| test3.cpp:431:8:431:15 | password | semmle.label | password |
215+
| test3.cpp:465:8:465:15 | password | semmle.label | password |
216+
| test3.cpp:474:11:474:18 | password | semmle.label | password |
214217
| test.cpp:41:23:41:43 | cleartext password! | semmle.label | cleartext password! |
215218
| test.cpp:48:21:48:27 | call to encrypt | semmle.label | call to encrypt |
216219
| test.cpp:48:29:48:39 | thePassword | semmle.label | thePassword |
@@ -242,3 +245,4 @@ subpaths
242245
| 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 |
243246
| test3.cpp:388:3:388:6 | call to recv | test3.cpp:386:8:386:15 | password | test3.cpp:388:15:388:22 | password | This operation receives into 'password', which may put unencrypted sensitive data into $@ | test3.cpp:386:8:386:15 | password | password |
244247
| test3.cpp:431:2:431:6 | call to fgets | test3.cpp:429:7:429:14 | password | test3.cpp:431:8:431:15 | password | This operation receives into 'password', which may put unencrypted sensitive data into $@ | test3.cpp:429:7:429:14 | password | password |
248+
| test3.cpp:474:3:474:6 | call to recv | test3.cpp:465:8:465:15 | password | test3.cpp:474:11:474:18 | password | This operation receives into 'password', which may put unencrypted sensitive data into $@ | test3.cpp:465:8:465:15 | password | password |

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

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,32 @@ int open(const char *filename, int b);
445445

446446
void test_tty()
447447
{
448-
char password[256];
449-
int f;
448+
{
449+
char password[256];
450+
int f;
451+
452+
f = open("/dev/tty", val());
453+
recv(f, password, 256, val()); // GOOD: from terminal
454+
}
450455

451-
f = open("/dev/tty", val());
452-
recv(f, password, 256, val()); // GOOD: from terminal
456+
{
457+
char password[256];
458+
int f;
459+
460+
f = STDIN_FILENO;
461+
recv(f, password, 256, val()); // GOOD: from stdin
462+
}
463+
464+
{
465+
char password[256];
466+
int f;
467+
468+
f = open("/dev/tty", val());
469+
if (f == -1)
470+
{
471+
f = STDIN_FILENO;
472+
}
473+
474+
recv(f, password, 256, val()); // GOOD: from terminal or stdin [FALSE POSITIVE]
475+
}
453476
}

0 commit comments

Comments
 (0)