From 15f225139f2b1360d9df41fe1aad53ef888c79fb Mon Sep 17 00:00:00 2001 From: ihor_dovbii Date: Fri, 8 May 2020 13:46:56 +0300 Subject: [PATCH] rework exclude_paths logic --- sast_controller/bin/config.py | 2 +- sast_controller/drivers/cx/utils.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sast_controller/bin/config.py b/sast_controller/bin/config.py index e66e10d..e5d780b 100755 --- a/sast_controller/bin/config.py +++ b/sast_controller/bin/config.py @@ -18,7 +18,7 @@ class Config(object): """Class with default configuration parameters""" EXCLUDED_TYPES = ["png", "zip", "css", "txt", "svg", "mp3", "wav", "less", "gif"] - EXCLUDED_PATH = ["node_modules", "config", "coverage", "dist_", "test", "report", "i18n"] + EXCLUDED_PATH = ["node_modules", "config", "coverage", "dist_", "test", "report", "i18n", "tests"] CODE_PATH = os.environ.get('CODE_PATH') or '/code' CX_PROJECT_NAME = os.environ.get('CX_PROJECT', os.environ.get('PROJECT', None)) diff --git a/sast_controller/drivers/cx/utils.py b/sast_controller/drivers/cx/utils.py index e702069..cd551c6 100755 --- a/sast_controller/drivers/cx/utils.py +++ b/sast_controller/drivers/cx/utils.py @@ -56,10 +56,14 @@ def zinfo_from_file(fullname): def is_not_excluded_path(path, exclude_paths): """Return False if path excluded, else True""" + split_path_list = [] + for split_path in path.split("/"): + split_path_list.append(split_path) if exclude_paths: for exclude_path in exclude_paths: - if exclude_path.lower().strip() in path.lower(): - return False + for split_path in split_path_list: + if exclude_path.lower().strip() == split_path.lower(): + return False return True