mirror of
https://github.com/github/codeql.git
synced 2025-12-21 11:16:30 +01:00
recognize when the js engine in gray-matter is set to something safe
This commit is contained in:
@@ -53,7 +53,14 @@ module CodeInjection {
|
||||
|
||||
/** An expression parsed by the `gray-matter` library. */
|
||||
class GrayMatterSink extends Sink {
|
||||
GrayMatterSink() { this = DataFlow::moduleImport("gray-matter").getACall().getArgument(0) }
|
||||
API::CallNode call;
|
||||
|
||||
GrayMatterSink() {
|
||||
call = DataFlow::moduleImport("gray-matter").getACall() and
|
||||
this = call.getArgument(0) and
|
||||
// if the js/javascript engine is set, then we assume they are set to something safe.
|
||||
not exists(call.getParameter(1).getMember("engines").getMember(["js", "javascript"]))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,4 +36,4 @@ edges
|
||||
| lib/index.js:2:21:2:24 | data | lib/index.js:1:35:1:38 | data | lib/index.js:2:21:2:24 | data | $@ flows to here and is later $@. | lib/index.js:1:35:1:38 | data | Library input | lib/index.js:2:15:2:30 | "(" + data + ")" | interpreted as code |
|
||||
| lib/index.js:6:26:6:29 | name | lib/index.js:5:35:5:38 | name | lib/index.js:6:26:6:29 | name | $@ flows to here and is later $@. | lib/index.js:5:35:5:38 | name | Library input | lib/index.js:6:17:6:29 | "obj." + name | interpreted as code |
|
||||
| lib/index.js:14:21:14:24 | data | lib/index.js:13:38:13:41 | data | lib/index.js:14:21:14:24 | data | $@ flows to here and is later $@. | lib/index.js:13:38:13:41 | data | Library input | lib/index.js:14:15:14:30 | "(" + data + ")" | interpreted as code |
|
||||
| lib/index.js:22:7:22:10 | data | lib/index.js:19:26:19:29 | data | lib/index.js:22:7:22:10 | data | $@ flows to here and is later $@. | lib/index.js:19:26:19:29 | data | Library input | lib/index.js:25:32:25:34 | str | interpreted as code |
|
||||
| lib/index.js:22:7:22:10 | data | lib/index.js:19:26:19:29 | data | lib/index.js:22:7:22:10 | data | $@ flows to here and is later $@. | lib/index.js:19:26:19:29 | data | Library input | lib/index.js:25:24:25:26 | str | interpreted as code |
|
||||
|
||||
@@ -22,6 +22,14 @@ export function greySink(data) {
|
||||
${data}
|
||||
---
|
||||
`
|
||||
const { content } = matter(str);
|
||||
console.log(content);
|
||||
const res = matter(str);
|
||||
console.log(res);
|
||||
|
||||
matter(str, { // OK
|
||||
engines: {
|
||||
js: function (data) {
|
||||
console.log("NOPE");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user