-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Rust: Models for log_err #19546
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
Rust: Models for log_err #19546
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds support for modeling the log_err crate’s logging sinks and updates tests accordingly
- Introduce tests in
test_logging.rsforlog_expectandlog_unwrapon bothOptionandResult - Add
log_erras a dependency in the test harness - Extend
log.model.ymlto marklog_errmethods as potential cleartext-logging sources
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| rust/ql/test/query-tests/security/CWE-312/test_logging.rs | Added imports and tests covering log_expect/log_unwrap sinks |
| rust/ql/test/query-tests/security/CWE-312/options.yml | Added log_err = { version = "1.1.1" } as a dependency |
| rust/ql/lib/codeql/rust/frameworks/log.model.yml | Extended the logging model to include log_err sink signatures |
Comments suppressed due to low confidence (2)
rust/ql/lib/codeql/rust/frameworks/log.model.yml:20
- The model currently covers
Option::log_expectbut lacks an entry forOption::log_unwrap. Iflog_unwrappanics onNone, it may log cleartext; add a corresponding extension entry for<crate::option::Option as crate::LogErrOption>::log_unwrapto capture that.
- - ["repo:https://github.com/DesmondWillowbrook/rs-log_err:log_err", "<crate::option::Option as crate::LogErrOption>::log_expect", "Argument[0]", "log-injection", "manual"]
rust/ql/test/query-tests/security/CWE-312/test_logging.rs:163
- No test case covers
Option::log_unwrapon aNonevalue. Add a test forNone.log_unwrap()to verify the model flags a cleartext-logging alert when unwrapping fails.
let _ = sensitive_opt2.log_unwrap();
|
|
||
| // test `log_expect` with sensitive `Result.Err` | ||
| let err_result2: Result<String, String> = Err(password2.clone()); | ||
| let _ = err_result2.log_expect(""); // $ MISSING: Alert[rust/cleartext-logging] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason we don't find this result is because the model for clone assumes self would be a reference, but here we do not realize that password2 is (I believe) implicitly converted to a reference, so we lose the flow. We've seen similar issues a few times before.
|
No changes on the DCA run. Just waiting for approval. |
Model logging sinks for
log_err. The test is based on the code I generated in the demo last week.