mirror of
https://github.com/github/codeql.git
synced 2026-05-04 13:15:21 +02:00
Merge pull request #18582 from geoffw0/logging
Rust: Query for cleartext logging of sensitive information
This commit is contained in:
@@ -776,7 +776,7 @@ final class ElementContent extends Content, TElementContent {
|
||||
* NOTE: Unlike `struct`s and `enum`s tuples are structural and not nominal,
|
||||
* hence we don't store a canonical path for them.
|
||||
*/
|
||||
private class TuplePositionContent extends Content, TTuplePositionContent {
|
||||
final class TuplePositionContent extends Content, TTuplePositionContent {
|
||||
private int pos;
|
||||
|
||||
TuplePositionContent() { this = TTuplePositionContent(pos) }
|
||||
|
||||
17
rust/ql/lib/codeql/rust/frameworks/log.model.yml
Normal file
17
rust/ql/lib/codeql/rust/frameworks/log.model.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
extensions:
|
||||
- addsTo:
|
||||
pack: codeql/rust-all
|
||||
extensible: sinkModel
|
||||
data:
|
||||
- ["repo:https://github.com/rust-lang/log:log", "crate::__private_api::log", "Argument[0]", "log-injection", "manual"] # args
|
||||
- ["repo:https://github.com/rust-lang/log:log", "crate::__private_api::log", "Argument[2]", "log-injection", "manual"] # target
|
||||
- ["repo:https://github.com/rust-lang/log:log", "crate::__private_api::log", "Argument[3]", "log-injection", "manual"] # key value
|
||||
- ["lang:std", "crate::io::stdio::_print", "Argument[0]", "log-injection", "manual"]
|
||||
- ["lang:std", "crate::io::stdio::_eprint", "Argument[0]", "log-injection", "manual"]
|
||||
- ["lang:std", "<crate::io::stdio::StdoutLock as crate::io::Write>::write", "Argument[0]", "log-injection", "manual"]
|
||||
- ["lang:std", "<crate::io::stdio::StdoutLock as crate::io::Write>::write_all", "Argument[0]", "log-injection", "manual"]
|
||||
- ["lang:std", "<crate::io::stdio::StderrLock as crate::io::Write>::write", "Argument[0]", "log-injection", "manual"]
|
||||
- ["lang:std", "<crate::io::stdio::StderrLock as crate::io::Write>::write_all", "Argument[0]", "log-injection", "manual"]
|
||||
- ["lang:core", "crate::panicking::panic_fmt", "Argument[0]", "log-injection", "manual"]
|
||||
- ["lang:core", "crate::panicking::assert_failed", "Argument[3].Variant[crate::option::Option::Some(0)]", "log-injection", "manual"]
|
||||
- ["lang:core", "<crate::option::Option>::expect", "Argument[0]", "log-injection", "manual"]
|
||||
@@ -13,6 +13,7 @@ extensions:
|
||||
- ["lang:core", "<crate::result::Result>::unwrap_or", "Argument[0]", "ReturnValue", "value", "manual"]
|
||||
# String
|
||||
- ["lang:alloc", "<crate::string::String>::as_str", "Argument[self]", "ReturnValue", "taint", "manual"]
|
||||
- ["lang:alloc", "<crate::string::String>::as_bytes", "Argument[self]", "ReturnValue", "taint", "manual"]
|
||||
# Hint
|
||||
- ["lang:core", "crate::hint::must_use", "Argument[0]", "ReturnValue", "value", "manual"]
|
||||
# Fmt
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Provides classes and predicates for reasoning about cleartext logging
|
||||
* of sensitive information vulnerabilities.
|
||||
*/
|
||||
|
||||
import rust
|
||||
private import codeql.rust.dataflow.DataFlow
|
||||
private import codeql.rust.dataflow.internal.DataFlowImpl
|
||||
private import codeql.rust.security.SensitiveData
|
||||
|
||||
/**
|
||||
* Provides default sources, sinks and barriers for detecting cleartext logging
|
||||
* vulnerabilities, as well as extension points for adding your own.
|
||||
*/
|
||||
module CleartextLogging {
|
||||
/**
|
||||
* A data flow source for cleartext logging vulnerabilities.
|
||||
*/
|
||||
abstract class Source extends DataFlow::Node { }
|
||||
|
||||
/**
|
||||
* A data flow sink for cleartext logging vulnerabilities.
|
||||
*/
|
||||
abstract class Sink extends DataFlow::Node { }
|
||||
|
||||
/**
|
||||
* A barrier for cleartext logging vulnerabilities.
|
||||
*/
|
||||
abstract class Barrier extends DataFlow::Node { }
|
||||
|
||||
/**
|
||||
* Sensitive data, considered as a flow source.
|
||||
*/
|
||||
private class SensitiveDataAsSource extends Source instanceof SensitiveData { }
|
||||
|
||||
/** A sink for logging from model data. */
|
||||
private class ModelsAsDataSinks extends Sink {
|
||||
ModelsAsDataSinks() { exists(string s | sinkNode(this, s) and s.matches("log-injection%")) }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user