Skip to content

Commit da8725a

Browse files
authored
Merge pull request github#3823 from dellalibera/js/fancy-log
Approved by erik-krogh
2 parents b3e68ef + bb06014 commit da8725a

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

change-notes/1.25/analysis-javascript.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
77
- [bluebird](http://bluebirdjs.com/)
88
- [express](https://www.npmjs.com/package/express)
9+
- [fancy-log](https://www.npmjs.com/package/fancy-log)
910
- [fastify](https://www.npmjs.com/package/fastify)
1011
- [fstream](https://www.npmjs.com/package/fstream)
1112
- [jGrowl](https://github.com/stanlemon/jGrowl)

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ abstract class LoggerCall extends DataFlow::CallNode {
1919
*/
2020
string getAStandardLoggerMethodName() {
2121
result = "crit" or
22+
result = "dir" or
2223
result = "debug" or
2324
result = "error" or
2425
result = "emerg" or
@@ -159,3 +160,20 @@ private module Npmlog {
159160
}
160161
}
161162
}
163+
164+
/**
165+
* Provides classes for working with [fancy-log](https://github.com/gulpjs/fancy-log).
166+
*/
167+
private module Fancylog {
168+
/**
169+
* A call to the fancy-log logging mechanism.
170+
*/
171+
class Fancylog extends LoggerCall {
172+
Fancylog() {
173+
this = DataFlow::moduleMember("fancy-log", getAStandardLoggerMethodName()).getACall() or
174+
this = DataFlow::moduleImport("fancy-log").getACall()
175+
}
176+
177+
override DataFlow::Node getAMessageComponent() { result = getAnArgument() }
178+
}
179+
}

javascript/ql/test/library-tests/frameworks/Logging/LoggerCall.expected

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,13 @@
2323
| tst.js:22:1:22:37 | require ... ", arg) | tst.js:22:34:22:36 | arg |
2424
| tst.js:23:1:23:40 | require ... ", arg) | tst.js:23:27:23:34 | "msg %s" |
2525
| tst.js:23:1:23:40 | require ... ", arg) | tst.js:23:37:23:39 | arg |
26+
| tst.js:25:1:25:35 | require ... ", arg) | tst.js:25:22:25:29 | "msg %s" |
27+
| tst.js:25:1:25:35 | require ... ", arg) | tst.js:25:32:25:34 | arg |
28+
| tst.js:26:1:26:39 | require ... ", arg) | tst.js:26:26:26:33 | "msg %s" |
29+
| tst.js:26:1:26:39 | require ... ", arg) | tst.js:26:36:26:38 | arg |
30+
| tst.js:27:1:27:40 | require ... ", arg) | tst.js:27:27:27:34 | "msg %s" |
31+
| tst.js:27:1:27:40 | require ... ", arg) | tst.js:27:37:27:39 | arg |
32+
| tst.js:28:1:28:40 | require ... ", arg) | tst.js:28:27:28:34 | "msg %s" |
33+
| tst.js:28:1:28:40 | require ... ", arg) | tst.js:28:37:28:39 | arg |
34+
| tst.js:29:1:29:41 | require ... ", arg) | tst.js:29:28:29:35 | "msg %s" |
35+
| tst.js:29:1:29:41 | require ... ", arg) | tst.js:29:38:29:40 | arg |

javascript/ql/test/library-tests/frameworks/Logging/tst.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ log("msg %s", arg);
2121
require("npmlog").log("info", "msg %s", arg);
2222
require("npmlog").info("msg %s", arg);
2323
require("npmlog").verbose("msg %s", arg);
24+
25+
require("fancy-log")("msg %s", arg);
26+
require("fancy-log").dir("msg %s", arg);
27+
require("fancy-log").warn("msg %s", arg);
28+
require("fancy-log").info("msg %s", arg);
29+
require("fancy-log").error("msg %s", arg);

0 commit comments

Comments
 (0)