Skip to content

Commit 36de24a

Browse files
committed
use API nodes instead of type-tracking in the pino model
1 parent 178d3de commit 36de24a

File tree

1 file changed

+8
-15
lines changed
  • javascript/ql/src/semmle/javascript/frameworks

1 file changed

+8
-15
lines changed

javascript/ql/src/semmle/javascript/frameworks/Logging.qll

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -354,31 +354,24 @@ private module Pino {
354354
/**
355355
* Gets a logger instance from the `pino` library.
356356
*/
357-
private DataFlow::SourceNode pino() {
358-
result = pinoApi().getAnImmediateUse()
357+
private API::Node pino() {
358+
result = pinoApi()
359359
or
360360
// `pino` is installed as the "log" property on the request object in `Express` and similar libraries.
361361
// in `Hapi` the property is "logger".
362-
exists(HTTP::RequestExpr req |
363-
result = req.flow().getALocalSource().getAPropertyRead(["log", "logger"])
362+
exists(HTTP::RequestExpr req, API::Node reqNode |
363+
reqNode.getAnImmediateUse() = req.flow().getALocalSource() and
364+
result = reqNode.getMember(["log", "logger"])
364365
)
365366
}
366367

367-
/**
368-
* Gets a reference to a logger method from the `pino` library.
369-
*/
370-
private DataFlow::SourceNode pinoCallee(DataFlow::TypeTracker t) {
371-
t.startInProp(["trace", "debug", "info", "warn", "error", "fatal"]) and
372-
result = pino()
373-
or
374-
exists(DataFlow::TypeTracker t2 | result = pinoCallee(t2).track(t2, t))
375-
}
376-
377368
/**
378369
* A logging call to the `pino` library.
379370
*/
380371
private class PinoCall extends LoggerCall {
381-
PinoCall() { this = pinoCallee(DataFlow::TypeTracker::end()).getACall() }
372+
PinoCall() {
373+
this = pino().getMember(["trace", "debug", "info", "warn", "error", "fatal"]).getACall()
374+
}
382375

383376
override DataFlow::Node getAMessageComponent() { result = getAnArgument() }
384377
}

0 commit comments

Comments
 (0)