Skip to content

Commit 4917d64

Browse files
committed
Added test cases for tanstack-vue useQueries.
1 parent 0c01588 commit 4917d64

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

javascript/ql/test/query-tests/Security/CWE-079/DomBasedXssWithResponseThreat/Xss.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,6 @@ nodes
130130
| testReactRelay.tsx:136:16:136:39 | readFra ... y, key) | semmle.label | readFra ... y, key) |
131131
| testReactRelay.tsx:137:50:137:53 | data | semmle.label | data |
132132
subpaths
133+
testFailures
134+
| testUseQueries2.vue:6:66:6:76 | // $ Source | Missing result: Source |
135+
| testUseQueries2.vue:35:32:35:46 | <!--$ Alert --> | Missing result: Alert |
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<script>
2+
import { useQueries } from "@tanstack/vue-query";
3+
4+
export default {
5+
data() {
6+
const ids = [1, 2, 3]
7+
const results = useQueries({
8+
queries: ids.map((id) => ({
9+
queryKey: ['post', id],
10+
queryFn: async () => {
11+
const response = await fetch("${id}"); // $ MISSING: Source
12+
return response.json();
13+
},
14+
staleTime: Infinity,
15+
})),
16+
});
17+
18+
return { data2 : results[0].data };
19+
}
20+
}
21+
</script>
22+
23+
<template>
24+
<VueQueryClientProvider :client="queryClient">
25+
<div v-html="data2"></div> <!--$ MISSING: Alert -->
26+
</VueQueryClientProvider>
27+
</template>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<script>
2+
import { useQueries } from "@tanstack/vue-query";
3+
import { computed } from "vue";
4+
5+
const fetchContent = async () => {
6+
const response = await fetch("https://example.com/content"); // $ Source
7+
const data = await response.json();
8+
return data;
9+
};
10+
11+
export default {
12+
data() {
13+
const results = useQueries({
14+
queries: [
15+
{
16+
queryKey: ["post", 1],
17+
queryFn: fetchContent,
18+
staleTime: Infinity,
19+
},
20+
{
21+
queryKey: ["post", 2],
22+
queryFn: () => fetchPost(2),
23+
staleTime: Infinity,
24+
},
25+
],
26+
});
27+
28+
return { data3 : results[0].data };
29+
},
30+
};
31+
</script>
32+
33+
<template>
34+
<VueQueryClientProvider :client="queryClient">
35+
<div v-html="data3"></div> <!--$ Alert -->
36+
</VueQueryClientProvider>
37+
</template>

0 commit comments

Comments
 (0)