Skip to content

Commit 1e3b862

Browse files
committed
Added a test case where useFragment from react-relay should be marked as a source but isn't
1 parent cc5179a commit 1e3b862

File tree

1 file changed

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

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import { useFragment } from 'react-relay';
3+
4+
const CommentComponent = ({ commentRef }) => {
5+
const commentData = useFragment(
6+
graphql`
7+
fragment CommentComponent_comment on Comment {
8+
id
9+
text
10+
}
11+
`,
12+
commentRef
13+
); // $ MISSING: Source=[js/xss]
14+
15+
return (
16+
<div>
17+
<h3>Comment:</h3>
18+
{/* Directly rendering user input without sanitation */}
19+
<p dangerouslySetInnerHTML = {{ __html: commentData.text}}> {commentData.text}</p> // $ MISSING: Alert=[js/xss]
20+
</div>
21+
);
22+
};

0 commit comments

Comments
 (0)