add support for getInitialProps in Next.js

This commit is contained in:
Erik Krogh Kristensen
2021-02-16 10:22:21 +01:00
parent d63fcaf7f1
commit af262a035d
3 changed files with 21 additions and 4 deletions

View File

@@ -67,12 +67,23 @@ private module NextJS {
NextJSStaticPropsStep() {
pageModule = getAPagesModule() and
this = pageModule.getAnExportedValue("getStaticProps").getAFunctionValue()
this = pageModule.getAnExportedValue("default").getAFunctionValue()
}
override predicate step(DataFlow::Node pred, DataFlow::Node succ) {
pred = this.getAReturn().getALocalSource().getAPropertyWrite("props").getRhs() and
succ = pageModule.getAnExportedValue("default").getAFunctionValue().getParameter(0)
(
pred =
pageModule
.getAnExportedValue("getStaticProps")
.getAFunctionValue()
.getAReturn()
.getALocalSource()
.getAPropertyWrite("props")
.getRhs()
or
pred = this.getAPropertyWrite("getInitialProps").getRhs().getAFunctionValue().getAReturn()
) and
succ = this.getParameter(0)
}
}
}