Skip to content

Commit 7b1aa23

Browse files
Copilotgeoffw0
andcommitted
Address PR feedback: trim examples, remove duplicate CWE ref, autoformat
Co-authored-by: geoffw0 <40627776+geoffw0@users.noreply.github.com>
1 parent 49265b6 commit 7b1aa23

File tree

5 files changed

+5
-24
lines changed

5 files changed

+5
-24
lines changed

rust/ql/lib/codeql/rust/security/LogInjectionExtensions.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ module LogInjection {
4242
private class ModelsAsDataSink extends Sink {
4343
ModelsAsDataSink() { sinkNode(this, "log-injection") }
4444
}
45-
}
45+
}

rust/ql/src/queries/security/CWE-117/LogInjection.qhelp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,5 @@ potentially forging a legitimate admin login entry.
4343

4444
<references>
4545
<li>OWASP: <a href="https://owasp.org/www-community/attacks/Log_Injection">Log Injection</a>.</li>
46-
<li>CWE-117: <a href="https://cwe.mitre.org/data/definitions/117.html">Improper Output Neutralization for Logs</a>.</li>
4746
</references>
4847
</qhelp>

rust/ql/src/queries/security/CWE-117/LogInjection.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ import LogInjectionFlow::PathGraph
3737

3838
from LogInjectionFlow::PathNode sourceNode, LogInjectionFlow::PathNode sinkNode
3939
where LogInjectionFlow::flowPath(sourceNode, sinkNode)
40-
select sinkNode.getNode(), sourceNode, sinkNode, "Log entry depends on a $@.",
41-
sourceNode.getNode(), "user-provided value"
40+
select sinkNode.getNode(), sourceNode, sinkNode, "Log entry depends on a $@.", sourceNode.getNode(),
41+
"user-provided value"
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::env;
2-
use log::{info, error};
2+
use log::info;
33

44
fn main() {
55
env_logger::init();
@@ -10,13 +10,4 @@ fn main() {
1010

1111
// BAD: log message constructed with unsanitized user input
1212
info!("User login attempt: {}", username);
13-
14-
// BAD: another example with error logging
15-
if username.is_empty() {
16-
error!("Login failed for user: {}", username);
17-
}
18-
19-
// BAD: formatted string with user input
20-
let message = format!("Processing request for user: {}", username);
21-
info!("{}", message);
2213
}
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::env;
2-
use log::{info, error};
2+
use log::info;
33

44
fn sanitize_for_logging(input: &str) -> String {
55
// Remove newlines and carriage returns to prevent log injection
@@ -16,13 +16,4 @@ fn main() {
1616
// GOOD: log message constructed with sanitized user input
1717
let sanitized_username = sanitize_for_logging(username);
1818
info!("User login attempt: {}", sanitized_username);
19-
20-
// GOOD: another example with error logging
21-
if username.is_empty() {
22-
error!("Login failed for user: {}", sanitized_username);
23-
}
24-
25-
// GOOD: formatted string with sanitized user input
26-
let message = format!("Processing request for user: {}", sanitized_username);
27-
info!("{}", message);
2819
}

0 commit comments

Comments
 (0)