Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Rust: Recognize more sensitive data sources #19470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
May 27, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rust: Add a few more test cases involving 'map'.
  • Loading branch information
geoffw0 committed May 12, 2025
commit b907cfe468de58cd90c46d66c19e9f2fe8862bcb
29 changes: 29 additions & 0 deletions 29 rust/ql/test/library-tests/sensitivedata/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ enum ContactDetails {
FavouriteColor(String),
}

struct ContactDetails2 {
home_phone_number: String,
}

fn test_private_info(
info: &MyPrivateInfo, details: &ContactDetails,
) {
Expand Down Expand Up @@ -298,9 +302,34 @@ fn test_private_info(
sink(ContactDetails::HomePhoneNumber("123".to_string())); // $ sensitive=private
sink(ContactDetails::MobileNumber("123".to_string())); // $ sensitive=private
sink(ContactDetails::Email("a@b".to_string())); // $ MISSING: sensitive=private

let numbers = [1, 2, 3];

if let ContactDetails::MobileNumber(num) = details {
sink(num.as_str()); // $ MISSING: sensitive=private
}
let contacts = numbers.map(|number|
{
let contact = ContactDetails::MobileNumber(number.to_string());
sink(&contact); // $ sensitive=private
contact
}
);
sink(&contacts[0]); // $ MISSING: sensitive=private
if let ContactDetails::HomePhoneNumber(num) = &contacts[0] {
sink(num.as_str()); // $ MISSING: sensitive=private
}

let contacts2 = numbers.map(|number|
{
let contact = ContactDetails2 {
home_phone_number: number.to_string(),
};
sink(&contact.home_phone_number); // $ sensitive=private
contact
}
);
sink(&contacts2[0].home_phone_number); // $ sensitive=private

// not private info

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.