Skip to content

Commit 7ceb919

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

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
3+
<script>
4+
import { useQueries } from "@tanstack/vue-query";
5+
6+
export default {
7+
data() {
8+
const ids = [1, 2, 3]
9+
const results = useQueries({
10+
queries: ids.map((id) => ({
11+
queryKey: ['post', id],
12+
queryFn: async () => {
13+
const response = await fetch("${id}"); // $ MISSING: Source
14+
return response.json();
15+
},
16+
staleTime: Infinity,
17+
})),
18+
});
19+
20+
return { data2 : results[0].data };
21+
}
22+
}
23+
</script>
24+
25+
<template>
26+
<VueQueryClientProvider :client="queryClient">
27+
<div v-html="data2"></div> <!--$ MISSING: Alert -->
28+
</VueQueryClientProvider>
29+
</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)