Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 896a9b0

Browse files
committed
refactor CleartextLogging to allow for reuse
1 parent c580ada commit 896a9b0

2 files changed

Lines changed: 28 additions & 14 deletions

File tree

javascript/ql/src/semmle/javascript/security/dataflow/CleartextLogging.qll

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,11 @@ module CleartextLogging {
3535
override predicate isSanitizer(DataFlow::Node node) { node instanceof Barrier }
3636

3737
override predicate isSanitizerEdge(DataFlow::Node pred, DataFlow::Node succ) {
38-
succ.(DataFlow::PropRead).getBase() = pred
38+
CleartextLogging::isSanitizerEdge(pred, succ)
3939
}
4040

4141
override predicate isAdditionalTaintStep(DataFlow::Node src, DataFlow::Node trg) {
42-
// A taint propagating data flow edge through objects: a tainted write taints the entire object.
43-
exists(DataFlow::PropWrite write |
44-
write.getRhs() = src and
45-
trg.(DataFlow::SourceNode).flowsTo(write.getBase())
46-
)
47-
or
48-
// Taint through the arguments object.
49-
exists(DataFlow::CallNode call, Function f |
50-
src = call.getAnArgument() and
51-
f = call.getACallee() and
52-
not call.isImprecise() and
53-
trg.asExpr() = f.getArgumentsVariable().getAnAccess()
54-
)
42+
CleartextLogging::isAdditionalTaintStep(src, trg)
5543
}
5644
}
5745
}

javascript/ql/src/semmle/javascript/security/dataflow/CleartextLoggingCustomizations.qll

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,30 @@ module CleartextLogging {
189189
class PartiallySensitiveMap extends DataFlow::FlowLabel {
190190
PartiallySensitiveMap() { this = "PartiallySensitiveMap" }
191191
}
192+
193+
/**
194+
* Holds if the edge `pred` -> `succ` should be sanitized for clear-text logging of sensitive information.
195+
*/
196+
predicate isSanitizerEdge(DataFlow::Node pred, DataFlow::Node succ) {
197+
succ.(DataFlow::PropRead).getBase() = pred
198+
}
199+
200+
/**
201+
* Holds if the edge `src` -> `trg` is an additional taint-step for clear-text logging of sensitive information.
202+
*/
203+
predicate isAdditionalTaintStep(DataFlow::Node src, DataFlow::Node trg) {
204+
// A taint propagating data flow edge through objects: a tainted write taints the entire object.
205+
exists(DataFlow::PropWrite write |
206+
write.getRhs() = src and
207+
trg.(DataFlow::SourceNode).flowsTo(write.getBase())
208+
)
209+
or
210+
// Taint through the arguments object.
211+
exists(DataFlow::CallNode call, Function f |
212+
src = call.getAnArgument() and
213+
f = call.getACallee() and
214+
not call.isImprecise() and
215+
trg.asExpr() = f.getArgumentsVariable().getAnAccess()
216+
)
217+
}
192218
}

0 commit comments

Comments
 (0)