gpt4 book ai didi

javascript - 如何修复 codacy 警报 "Generic Object Injection Sink"

转载 作者:行者123 更新时间:2023-12-04 14:32:12 35 4
gpt4 key购买 nike

下面是我的代码。我不认为有任何问题。

我怎么能愚弄 codacy?如果我不能使用 obj[key] ,那么这到底是什么东西?我无法避免[] .

handleClick = (e, titleProps) => {
const { index } = titleProps
const newVal = this.state.activeIndexObj[index]? false: true
let activeIndexObj = {...this.state.activeIndexObj}
activeIndexObj[index] = newVal
// Generic Object Injection Sink (security/detect-object-injection)

最佳答案

您只需要将索引解析为整数

activeIndexObj[parseInt(index)] = newVal

黑客可能会注入(inject)函数或原型(prototype)链接,这就是出现此安全错误的原因。

关于javascript - 如何修复 codacy 警报 "Generic Object Injection Sink",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51715616/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com