mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
add support for getInitialProps in Next.js
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,12 @@ export async function getStaticProps({ params }) {
|
||||
}
|
||||
}
|
||||
|
||||
export default function Post({ taint }) {
|
||||
export default function Post({ taint, stars }) {
|
||||
sink(taint);
|
||||
sink(stars);
|
||||
return <span />;
|
||||
}
|
||||
|
||||
Post.getInitialProps = async (ctx) => {
|
||||
return { stars: source(2) }
|
||||
}
|
||||
@@ -2,3 +2,4 @@ remoteFlow
|
||||
| pages/[my-fallback-id].jsx:9:40:9:45 | params |
|
||||
dataFlow
|
||||
| pages/[my-fallback-id].jsx:13:20:13:27 | source() | pages/[my-fallback-id].jsx:19:10:19:14 | taint |
|
||||
| pages/[my-fallback-id].jsx:25:21:25:29 | source(2) | pages/[my-fallback-id].jsx:20:10:20:14 | stars |
|
||||
|
||||
Reference in New Issue
Block a user