Skip to content

Commit a5cf024

Browse files
committed
add support for getServerSideProps in Next.js
1 parent af262a0 commit a5cf024

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private module NextJS {
7474
(
7575
pred =
7676
pageModule
77-
.getAnExportedValue("getStaticProps")
77+
.getAnExportedValue(["getStaticProps", "getServerSideProps"])
7878
.getAFunctionValue()
7979
.getAReturn()
8080
.getALocalSource()

javascript/ql/test/library-tests/frameworks/Next/pages/[my-fallback-id].jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,21 @@ export async function getStaticProps({ params }) {
1515
}
1616
}
1717

18-
export default function Post({ taint, stars }) {
18+
export default function Post({ taint, stars, more }) {
1919
sink(taint);
2020
sink(stars);
21+
sink(more);
2122
return <span />;
2223
}
2324

2425
Post.getInitialProps = async (ctx) => {
2526
return { stars: source(2) }
27+
}
28+
29+
export async function getServerSideProps(ctx) {
30+
return {
31+
props: {
32+
more: source(3)
33+
}
34+
}
2635
}

javascript/ql/test/library-tests/frameworks/Next/tests.expected

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ remoteFlow
22
| pages/[my-fallback-id].jsx:9:40:9:45 | params |
33
dataFlow
44
| pages/[my-fallback-id].jsx:13:20:13:27 | source() | pages/[my-fallback-id].jsx:19:10:19:14 | taint |
5-
| pages/[my-fallback-id].jsx:25:21:25:29 | source(2) | pages/[my-fallback-id].jsx:20:10:20:14 | stars |
5+
| pages/[my-fallback-id].jsx:26:21:26:29 | source(2) | pages/[my-fallback-id].jsx:20:10:20:14 | stars |
6+
| pages/[my-fallback-id].jsx:32:19:32:27 | source(3) | pages/[my-fallback-id].jsx:21:10:21:13 | more |

0 commit comments

Comments
 (0)