SonarCube pythonsecurity:S2631 issue with re match

问题描述 投票:0回答:0

对于我下面的代码,

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)
python-3.x sonarqube python-re
© www.soinside.com 2019 - 2024. All rights reserved.