Skip to content

Commit

Permalink
bugfix: 修复CodCC白名单无效问题 TencentBlueKing#5802
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuanruitao committed Dec 19, 2021
1 parent 8f744a9 commit e11f791
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,14 @@ private boolean checkMaskByPath(CCNDefectEntity ccnDefectEntity,
&& (ccnDefectEntity.getStatus() & ComConstants.DefectStatus.FIXED.value()) == 0
&& (PathUtils.checkIfMaskByPath(StringUtils.isNotEmpty(relPath) ? relPath : filePath, filterPaths)
|| (CollectionUtils.isNotEmpty(pathList)
&& !PathUtils.checkIfMaskByPath(StringUtils.isNotEmpty(relPath) ? relPath : filePath, pathList)))) {
&& !PathUtils.checkIfMaskByPath(filePath, pathList)))) {
ccnDefectEntity.setStatus(ccnDefectEntity.getStatus() | ComConstants.DefectStatus.PATH_MASK.value());
ccnDefectEntity.setExcludeTime(curTime);
return true;
}
// 如果已经是被路径屏蔽的,但是实质没有被路径屏蔽,则要把屏蔽状态去掉
else if ((CollectionUtils.isEmpty(pathList)
|| PathUtils.checkIfMaskByPath(StringUtils.isNotEmpty(relPath) ? relPath : filePath, pathList))
|| PathUtils.checkIfMaskByPath(filePath, pathList))
&& !PathUtils.checkIfMaskByPath(StringUtils.isNotEmpty(relPath) ? relPath : filePath, filterPaths)
&& (ccnDefectEntity.getStatus() & ComConstants.DefectStatus.PATH_MASK.value()) > 0) {
ccnDefectEntity.setStatus(ccnDefectEntity.getStatus() - ComConstants.DefectStatus.PATH_MASK.value());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,14 @@ private boolean checkMaskByPath(LintDefectV2Entity lintDefectV2Entity,
&& (lintDefectV2Entity.getStatus() & DefectStatus.FIXED.value()) == 0
&& (PathUtils.checkIfMaskByPath(StringUtils.isNotEmpty(relPath) ? relPath : filePath, filterPaths)
|| (CollectionUtils.isNotEmpty(pathList)
&& !PathUtils.checkIfMaskByPath(StringUtils.isNotEmpty(relPath) ? relPath : filePath, pathList)))) {
&& !PathUtils.checkIfMaskByPath(filePath, pathList)))) {
lintDefectV2Entity.setStatus(lintDefectV2Entity.getStatus() | ComConstants.TaskFileStatus.PATH_MASK.value());
lintDefectV2Entity.setExcludeTime(curTime);
return true;
}
// 如果已经是被路径屏蔽的,但是实质没有被路径屏蔽,则要把屏蔽状态去掉
else if ((CollectionUtils.isEmpty(pathList)
|| PathUtils.checkIfMaskByPath(StringUtils.isNotEmpty(relPath) ? relPath : filePath, pathList))
|| PathUtils.checkIfMaskByPath(filePath, pathList))
&& !PathUtils.checkIfMaskByPath(StringUtils.isNotEmpty(relPath) ? relPath : filePath, filterPaths)
&& (lintDefectV2Entity.getStatus() & ComConstants.TaskFileStatus.PATH_MASK.value()) > 0) {
lintDefectV2Entity.setStatus(lintDefectV2Entity.getStatus() - ComConstants.TaskFileStatus.PATH_MASK.value());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ private List<CLOCDefectEntity> checkMaskByPath(List<CLOCDefectEntity> clocDefect
// 命中黑名单 或 没有命中白名单
if (PathUtils.checkIfMaskByPath(it.getFileName(), filterPath)
|| (CollectionUtils.isNotEmpty(pathSet)
&& !PathUtils.checkIfMaskByPath(StringUtils.isBlank(it.getRelPath())
? it.getFileName() : it.getRelPath(), pathSet))) {
&& !PathUtils.checkIfMaskByPath(it.getFileName(), pathSet))) {
pathMaskDefectList.add(it.getFileName());
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ private boolean checkMaskByPath(DUPCDefectEntity dupcDefectEntity,
&& (dupcDefectEntity.getStatus() & ComConstants.DefectStatus.FIXED.value()) == 0
&& (PathUtils.checkIfMaskByPath(StringUtils.isNotEmpty(relPath) ? relPath : filePath, filterPaths)
|| (CollectionUtils.isNotEmpty(pathSet)
&& !PathUtils.checkIfMaskByPath(StringUtils.isNotEmpty(relPath) ? relPath : filePath, pathSet))))
&& !PathUtils.checkIfMaskByPath(filePath, pathSet))))
{
dupcDefectEntity.setStatus(dupcDefectEntity.getStatus() | ComConstants.TaskFileStatus.PATH_MASK.value());
dupcDefectEntity.setExcludeTime(curTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,7 @@ private int checkMaskByPath(DefectEntity defectEntity,
Set<String> filterPathSet,
Set<String> pathSet,
long currTime) {
String path = StringUtils.isBlank(defectEntity.getRelPath())
? defectEntity.getFilePathname()
: defectEntity.getRelPath();
String path = defectEntity.getFilePathname();
// 当前未被屏蔽但是命中屏蔽路径的,需要把告警屏蔽掉
if ((status & ComConstants.DefectStatus.PATH_MASK.value()) == 0
&& (PathUtils.checkIfMaskByPath(path, filterPathSet)
Expand Down

0 comments on commit e11f791

Please sign in to comment.