Skip to content

Commit cf5c6ba

Browse files
committed
C++: More test cases for salary.
1 parent 0e3e145 commit cf5c6ba

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ edges
9494
| test3.cpp:429:7:429:14 | password | test3.cpp:431:8:431:15 | password |
9595
| test3.cpp:526:44:526:54 | my_latitude | test3.cpp:527:15:527:20 | buffer |
9696
| test3.cpp:532:45:532:58 | home_longitude | test3.cpp:533:15:533:20 | buffer |
97+
| test3.cpp:551:47:551:58 | salaryString | test3.cpp:552:15:552:20 | buffer |
98+
| test3.cpp:556:19:556:30 | salaryString | test3.cpp:559:15:559:20 | buffer |
9799
| test.cpp:41:23:41:43 | cleartext password! | test.cpp:48:21:48:27 | call to encrypt |
98100
| test.cpp:41:23:41:43 | cleartext password! | test.cpp:48:29:48:39 | thePassword |
99101
| test.cpp:66:23:66:43 | cleartext password! | test.cpp:76:21:76:27 | call to encrypt |
@@ -238,6 +240,10 @@ nodes
238240
| test3.cpp:527:15:527:20 | buffer | semmle.label | buffer |
239241
| test3.cpp:532:45:532:58 | home_longitude | semmle.label | home_longitude |
240242
| test3.cpp:533:15:533:20 | buffer | semmle.label | buffer |
243+
| test3.cpp:551:47:551:58 | salaryString | semmle.label | salaryString |
244+
| test3.cpp:552:15:552:20 | buffer | semmle.label | buffer |
245+
| test3.cpp:556:19:556:30 | salaryString | semmle.label | salaryString |
246+
| test3.cpp:559:15:559:20 | buffer | semmle.label | buffer |
241247
| test.cpp:41:23:41:43 | cleartext password! | semmle.label | cleartext password! |
242248
| test.cpp:48:21:48:27 | call to encrypt | semmle.label | call to encrypt |
243249
| test.cpp:48:29:48:39 | thePassword | semmle.label | thePassword |
@@ -284,3 +290,5 @@ subpaths
284290
| test3.cpp:517:2:517:5 | call to send | test3.cpp:517:18:517:29 | medical_info | test3.cpp:517:18:517:29 | medical_info | This operation transmits 'medical_info', which may contain unencrypted sensitive data from $@ | test3.cpp:517:18:517:29 | medical_info | medical_info |
285291
| test3.cpp:527:3:527:6 | call to send | test3.cpp:526:44:526:54 | my_latitude | test3.cpp:527:15:527:20 | buffer | This operation transmits 'buffer', which may contain unencrypted sensitive data from $@ | test3.cpp:526:44:526:54 | my_latitude | my_latitude |
286292
| test3.cpp:533:3:533:6 | call to send | test3.cpp:532:45:532:58 | home_longitude | test3.cpp:533:15:533:20 | buffer | This operation transmits 'buffer', which may contain unencrypted sensitive data from $@ | test3.cpp:532:45:532:58 | home_longitude | home_longitude |
293+
| test3.cpp:552:3:552:6 | call to send | test3.cpp:551:47:551:58 | salaryString | test3.cpp:552:15:552:20 | buffer | This operation transmits 'buffer', which may contain unencrypted sensitive data from $@ | test3.cpp:551:47:551:58 | salaryString | salaryString |
294+
| test3.cpp:559:3:559:6 | call to send | test3.cpp:556:19:556:30 | salaryString | test3.cpp:559:15:559:20 | buffer | This operation transmits 'buffer', which may contain unencrypted sensitive data from $@ | test3.cpp:556:19:556:30 | salaryString | salaryString |

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ struct person_info
495495
double my_latitude;
496496
double home_longitude;
497497
int newSalary;
498-
498+
char *salaryString;
499499
// not sensitive
500500
char *license_key_hash;
501501
char *my_zip_file;
@@ -545,4 +545,17 @@ void tests2(person_info *pi)
545545
snprintf(buffer, 1024, "salary = %i\n", sal);
546546
send(val(), buffer, strlen(buffer), val()); // BAD [NOT DETECTED]
547547
}
548+
{
549+
char buffer[1024];
550+
551+
snprintf(buffer, 1024, "salary = %s\n", pi->salaryString);
552+
send(val(), buffer, strlen(buffer), val()); // BAD
553+
}
554+
{
555+
char buffer[1024];
556+
char *sal = pi->salaryString;
557+
558+
snprintf(buffer, 1024, "salary = %s\n", sal);
559+
send(val(), buffer, strlen(buffer), val()); // BAD
560+
}
548561
}

0 commit comments

Comments
 (0)