mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
Merge pull request #18834 from Napalys/js/tanstack
JS: Support 'response' threat model and @tanstack/react-query
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
#select
|
||||
| test.jsx:27:29:27:32 | data | test.jsx:5:28:5:63 | fetch(" ... ntent") | test.jsx:27:29:27:32 | data | Cross-site scripting vulnerability due to $@. | test.jsx:5:28:5:63 | fetch(" ... ntent") | user-provided value |
|
||||
edges
|
||||
| test.jsx:5:11:5:63 | response | test.jsx:6:24:6:31 | response | provenance | |
|
||||
| test.jsx:5:22:5:63 | await f ... ntent") | test.jsx:5:11:5:63 | response | provenance | |
|
||||
| test.jsx:5:28:5:63 | fetch(" ... ntent") | test.jsx:5:22:5:63 | await f ... ntent") | provenance | |
|
||||
| test.jsx:6:11:6:38 | data | test.jsx:7:12:7:15 | data | provenance | |
|
||||
| test.jsx:6:18:6:38 | await r ... .json() | test.jsx:6:11:6:38 | data | provenance | |
|
||||
| test.jsx:6:24:6:31 | response | test.jsx:6:24:6:38 | response.json() | provenance | |
|
||||
| test.jsx:6:24:6:38 | response.json() | test.jsx:6:18:6:38 | await r ... .json() | provenance | |
|
||||
| test.jsx:7:12:7:15 | data | test.jsx:15:11:17:5 | data | provenance | |
|
||||
| test.jsx:15:11:17:5 | data | test.jsx:27:29:27:32 | data | provenance | |
|
||||
nodes
|
||||
| test.jsx:5:11:5:63 | response | semmle.label | response |
|
||||
| test.jsx:5:22:5:63 | await f ... ntent") | semmle.label | await f ... ntent") |
|
||||
| test.jsx:5:28:5:63 | fetch(" ... ntent") | semmle.label | fetch(" ... ntent") |
|
||||
| test.jsx:6:11:6:38 | data | semmle.label | data |
|
||||
| test.jsx:6:18:6:38 | await r ... .json() | semmle.label | await r ... .json() |
|
||||
| test.jsx:6:24:6:31 | response | semmle.label | response |
|
||||
| test.jsx:6:24:6:38 | response.json() | semmle.label | response.json() |
|
||||
| test.jsx:7:12:7:15 | data | semmle.label | data |
|
||||
| test.jsx:15:11:17:5 | data | semmle.label | data |
|
||||
| test.jsx:27:29:27:32 | data | semmle.label | data |
|
||||
subpaths
|
||||
@@ -0,0 +1,6 @@
|
||||
extensions:
|
||||
- addsTo:
|
||||
pack: codeql/threat-models
|
||||
extensible: threatModelConfiguration
|
||||
data:
|
||||
- ["response", true, 0]
|
||||
@@ -0,0 +1,2 @@
|
||||
query: Security/CWE-079/Xss.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
@@ -0,0 +1,34 @@
|
||||
import React from "react";
|
||||
import { useQuery } from "./wrapper";
|
||||
|
||||
const fetchContent = async () => {
|
||||
const response = await fetch("https://example.com/content"); // $ Source[js/xss]
|
||||
const data = await response.json();
|
||||
return data;
|
||||
};
|
||||
|
||||
const getQueryOptions = () => {
|
||||
return {queryFn: fetchContent};
|
||||
}
|
||||
|
||||
const ContentWithDangerousHtml = () => {
|
||||
const { data, error, isLoading } = useQuery(
|
||||
getQueryOptions()
|
||||
);
|
||||
|
||||
if (isLoading) return <div>Loading...</div>;
|
||||
if (error) return <div>Error fetching content!</div>;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>Content with Dangerous HTML</h1>
|
||||
<div
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: data, // $ Alert[js/xss]
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ContentWithDangerousHtml;
|
||||
@@ -0,0 +1,2 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
export { useQuery }
|
||||
Reference in New Issue
Block a user