Skip to content

Commit 9d49550

Browse files
Add ExcludeZapEncoderSanitizer query
1 parent 833b74a commit 9d49550

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* ExcludeZapEncoderSanitizer.ql
3+
*
4+
* Filter/suppress log-injection findings when the taint flow can be shown to
5+
* pass through a sanitizer (including zap custom encoders).
6+
*
7+
* NOTE: This is a conservative template. Integrate with your existing
8+
* taint-tracking / source/sink predicates used by your log-injection rules.
9+
*/
10+
11+
import go
12+
import go.security.dataflow.TaintTracking as T
13+
// adjust imports above if your repo uses a different taint package
14+
15+
// Reuse the library predicates
16+
import LogSanitizer
17+
18+
/**
19+
* A wrapper sink used for demonstration. Replace with the actual log sink
20+
* definitions used by your log-injection query if you want precise suppression.
21+
*/
22+
class LogSink extends T.Sink {
23+
LogSink() { this = T.Sink("LogSink") }
24+
}
25+
26+
/**
27+
* Find flows from sources to log sinks but ignore flows that pass through a sanitizer.
28+
* This query demonstrates the pattern — adapt to concrete source/sink definitions.
29+
*/
30+
from T.Source src, T.Sink sink, Function sanitizerFn
31+
where
32+
src.flowsTo(sink) and
33+
not exists(sanitizerFn |
34+
isSanitizer(sanitizerFn) and
35+
// sanitizer function appears somewhere on the flow path
36+
src.flowsTo(sanitizerFn) and
37+
sanitizerFn.flowsTo(sink)
38+
)
39+
select sink, "Possible unsanitized value logged (no sanitizer detected on flow)."

0 commit comments

Comments
 (0)