Skip to content

Commit d95001f

Browse files
committed
Rust: Additional test cases for sensitive data heuristics.
1 parent dc863c3 commit d95001f

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

  • rust/ql/test/library-tests/sensitivedata

rust/ql/test/library-tests/sensitivedata/test.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@ impl MyStruct {
2323
fn get_password() -> String { get_string() }
2424

2525
fn test_passwords(
26-
password: &str, pass_word: &str, passwd: &str, my_password: &str, password_str: &str, password_confirmation: &str,
26+
password: &str, pass_word: &str, passwd: &str, my_password: &str, password_str: &str, password_confirmation: &str, profile_password: &str,
2727
pass_phrase: &str, passphrase: &str, passPhrase: &str, backup_code: &str,
2828
auth_key: &str, authkey: &str, authKey: &str, authentication_key: &str, authenticationkey: &str, authenticationKey: &str, oauth: &str,
29-
one_time_code: &str,
30-
harmless: &str, encrypted_password: &str, password_hash: &str, passwordFile: &str,
29+
one_time_code: &str, api_token: &str, api_tok: &str,
30+
harmless: &str,
31+
encrypted_password: &str, unencrypted_password: &str, encoded_password: &str, unencoded_password: &str,
32+
password_hash: &str, passwordFile: &str, coauthor: &str,
33+
3134
ms: &MyStruct
3235
) {
3336
// passwords
@@ -38,6 +41,9 @@ fn test_passwords(
3841
sink(my_password); // $ sensitive=password
3942
sink(password_str); // $ sensitive=password
4043
sink(password_confirmation); // $ sensitive=password
44+
sink(profile_password); // $ MISSING: sensitive=password
45+
sink(unencrypted_password); // $ MISSING: sensitive=password
46+
sink(unencoded_password); // $ MISSING: sensitive=password
4147
sink(pass_phrase); // $ sensitive=password
4248
sink(passphrase); // $ sensitive=password
4349
sink(passPhrase); // $ sensitive=password
@@ -51,6 +57,8 @@ fn test_passwords(
5157
sink(authenticationKey); // $ sensitive=password
5258
sink(oauth); // $ sensitive=password
5359
sink(one_time_code); // $ MISSING: sensitive=password
60+
sink(api_token); // $ sensitive=password
61+
sink(api_tok); // $ MISSING: sensitive=password
5462

5563
sink(ms); // $ MISSING: sensitive=password
5664
sink(ms.password.as_str()); // $ sensitive=password
@@ -67,8 +75,10 @@ fn test_passwords(
6775

6876
sink(harmless);
6977
sink(encrypted_password);
78+
sink(encoded_password);
7079
sink(password_hash);
7180
sink(passwordFile);
81+
sink(coauthor); // $ SPURIOUS: sensitive=password
7282

7383
sink(ms.harmless.as_str());
7484
sink(ms.password_file_path.as_str());
@@ -187,6 +197,10 @@ struct Financials {
187197
harmless: String,
188198
my_bank_account_number: String,
189199
credit_card_no: String,
200+
card_no: String,
201+
cardNumber: String,
202+
card_security_code: String,
203+
190204
credit_rating: i32,
191205
user_ccn: String,
192206
cvv: String,
@@ -201,6 +215,7 @@ struct Financials {
201215
accounting: i32,
202216
unaccounted: bool,
203217
multiband: bool,
218+
wildcard_not_matched: bool,
204219
}
205220

206221
enum Gender {
@@ -298,6 +313,9 @@ fn test_private_info(
298313

299314
sink(info.financials.my_bank_account_number.as_str()); // $ sensitive=private SPURIOUS: sensitive=id
300315
sink(info.financials.credit_card_no.as_str()); // $ sensitive=private
316+
sink(info.financials.card_no.as_str()); // $ MISSING: sensitive=private
317+
sink(info.financials.cardNumber.as_str()); // $ MISSING: sensitive=private
318+
sink(info.financials.card_security_code.as_str()); // $ MISSING: sensitive=private
301319
sink(info.financials.credit_rating); // $ sensitive=private
302320
sink(info.financials.user_ccn.as_str()); // $ sensitive=private
303321
sink(info.financials.cvv.as_str()); // $ sensitive=private
@@ -350,6 +368,7 @@ fn test_private_info(
350368
sink(info.financials.accounting);
351369
sink(info.financials.unaccounted);
352370
sink(info.financials.multiband);
371+
sink(info.financials.wildcard_not_matched);
353372

354373
sink(ContactDetails::FavouriteColor("blue".to_string()));
355374
}

0 commit comments

Comments
 (0)