Skip to content

Commit 184d23d

Browse files
committed
Add test cases for @tanstack/angular-query-experimental injectQuery
1 parent c001435 commit 184d23d

File tree

2 files changed

+41
-0
lines changed
  • javascript/ql/test/query-tests/Security/CWE-079/DomBasedXssWithResponseThreat

2 files changed

+41
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,7 @@ nodes
9292
| testReactRelay.tsx:136:16:136:39 | readFra ... y, key) | semmle.label | readFra ... y, key) |
9393
| testReactRelay.tsx:137:50:137:53 | data | semmle.label | data |
9494
subpaths
95+
testFailures
96+
| test.ts:8:82:8:92 | // $ Source | Missing result: Source |
97+
| test.ts:21:79:21:88 | // $ Alert | Missing result: Alert |
98+
| test.ts:24:94:24:103 | // $ Alert | Missing result: Alert |
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { QueryClient, injectQuery } from '@tanstack/angular-query-experimental'
2+
import { HttpClient } from '@angular/common/http'
3+
4+
class ServiceOrComponent {
5+
query = injectQuery(() => ({
6+
queryKey: ['repoData'],
7+
queryFn: () =>
8+
this.#http.get<Response>('https://api.github.com/repos/tanstack/query'), // $ Source
9+
}))
10+
11+
#http: {
12+
get: <T>(url: string) => Promise<T>
13+
};
14+
15+
constructor(http: HttpClient) {
16+
this.#http = http;
17+
}
18+
19+
displayRepoDetails() {
20+
this.query.data.then(response => {
21+
document.getElementById('repoInfo').innerHTML = response.description; // $ Alert
22+
23+
const detailsElement = document.createElement('div');
24+
detailsElement.innerHTML = `<h2>${response.name}</h2><p>${response.owner.bio}</p>`; // $ Alert
25+
document.body.appendChild(detailsElement);
26+
});
27+
}
28+
}
29+
30+
interface Response {
31+
name: string;
32+
description: string;
33+
stargazers_count: number;
34+
owner: {
35+
bio: string;
36+
}
37+
}

0 commit comments

Comments
 (0)