Skip to content

Commit 05690c2

Browse files
committed
Added a test for tanstack/react-query useQuery
1 parent 967c1ad commit 05690c2

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#select
2+
edges
3+
nodes
4+
subpaths
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
extensions:
2+
- addsTo:
3+
pack: codeql/threat-models
4+
extensible: threatModelConfiguration
5+
data:
6+
- ["response", true, 0]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
query: Security/CWE-079/Xss.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from "react";
2+
import { useQuery } from "@tanstack/react-query";
3+
4+
const fetchContent = async () => {
5+
const response = await fetch("https://example.com/content"); // $ MISSING: Source[js/xss]
6+
const data = await response.json();
7+
return data;
8+
};
9+
10+
const ContentWithDangerousHtml = () => {
11+
const { data, error, isLoading } = useQuery(
12+
{
13+
queryFn: fetchContent
14+
}
15+
);
16+
17+
if (isLoading) return <div>Loading...</div>;
18+
if (error) return <div>Error fetching content!</div>;
19+
20+
return (
21+
<div>
22+
<h1>Content with Dangerous HTML</h1>
23+
<div
24+
dangerouslySetInnerHTML={{
25+
__html: data, // $ MISSING: Alert[js/xss]
26+
}}
27+
/>
28+
</div>
29+
);
30+
};
31+
32+
export default ContentWithDangerousHtml;

0 commit comments

Comments
 (0)