【发布时间】:2022-04-17 16:06:22
【问题描述】:
CheckMarx 将该组件标记为易受攻击。我不明白为什么。我不确定 CheckMarx 对 React 代码的理解程度,我不知道我会如何安抚 CheckMarx。
错误是Client_DOM_XSS: The application\'s renderes untrusted data embeddings untrusted data in generated output with state, 在 react-app\\src\\visualizer\\Visualization.js 的第 25 行。这种不受信任的数据直接嵌入到输出中,没有经过适当的清理或编码,使攻击者能够将恶意代码注入到输出中。
任何人都可以帮忙吗?
import React, {Component} from \'react\';
export default class Visualization extends Component {
constructor(props) {
super(props);
this.state = {
x: null,
};
}
componentDidUpdate(prevProps, prevState, snapshot) {
if(!this.props.x) {
this.setState({
x: null,
});
} else if(this.props.x !== prevProps.x) {
this.setState({
x: this.props.x,
});
}
}
render() {
return (<div>X: {this.state.x}</div>)
}
}
-
看起来像 checkmarx 中的错误。