Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 89e9c6c

Browse files
author
Max Schaefer
committed
Teach clear-text logging query to ignore dummy passwords.
1 parent 63187a0 commit 89e9c6c

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

ql/src/semmle/go/security/CleartextLoggingCustomizations.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import go
88
private import semmle.go.security.SensitiveActions::HeuristicNames
9+
private import semmle.go.security.SensitiveActions::PasswordHeuristics
910

1011
/**
1112
* Provides extension points for customizing the data-flow tracking configuration for reasoning
@@ -67,6 +68,9 @@ module CleartextLogging {
6768
.(Ident)
6869
.getName()
6970
.regexpMatch("(?is).*(messages|strings).*")
71+
or
72+
// avoid dummy passwords
73+
isDummyPassword(this.getStringValue())
7074
}
7175
}
7276

ql/test/query-tests/Security/CWE-312/passwords.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func redact(kind, value string) string {
1919
func test() {
2020
name := "user"
2121
password := "P@ssw0rd"
22-
x := "aaaaa"
22+
x := "horsebatterystapleincorrect"
2323
var o passStruct
2424

2525
log.Println(password) // NOT OK
@@ -47,7 +47,7 @@ func test() {
4747
log.Println(obj3) // caught because of the below line
4848
obj3.x = password // NOT OK
4949

50-
fixed_password := "123"
50+
fixed_password := "cowbatterystaplecorrect"
5151
log.Println(fixed_password) // Probably OK, but caught
5252

5353
log.Println(IncorrectPasswordError) // OK
@@ -125,6 +125,11 @@ func test() {
125125
log.Println(config) // NOT OK
126126
log.Println(config.x) // NOT OK
127127
log.Println(config.y) // NOT OK
128+
129+
obj4 := xStruct{
130+
x: "aaaaa",
131+
}
132+
log.Println(obj4) // OK
128133
}
129134

130135
const password = "horsebatterystaplecorrect"

0 commit comments

Comments
 (0)