Files
codeql/javascript/ql/test/query-tests/Security/CWE-079/DomBasedXss/react-use-context.js
2020-10-28 16:23:36 +00:00

21 lines
436 B
JavaScript

import { useContext, Component } from 'react';
import { MyContext } from './react-create-context';
function useMyContext() {
return useContext(MyContext);
}
export function useDoc1() {
let { root } = useMyContext();
root.appendChild(window.name); // NOT OK
}
class C extends Component {
foo() {
let { root } = this.context;
root.appendChild(window.name); // NOT OK
}
}
C.contextType = MyContext;