对于我下面的代码,
SonarCube
在抱怨pythonsecurity:S2631
Regular expressions should not be vulnerable to Denial of Service attacks
我试图理解相同的代码被
sonarlint
扩展的 VS Code
扫描并且报告没有问题。但是一些遗留的SonarCube enterprise
版本确实如此。
如何解决这个问题,更重要的是使用
sonarlint
进行重现。
result = []
for obj in page['Contents']:
key: str = obj['Key']
key_without_prefix = key.replace(prefix, "", 1)
if re.match(pattern, key_without_prefix): # issue here
result.append(key)