Avoid parsing all nested folders
+import os.path
from time import sleep
import boto3
@@ -172,6 +173,12 @@ class BcPlatformIntegration(object):
if not self.use_s3_integration:
return
+ if files:
+ for f in files:
+ _, file_extension = os.path.splitext(f)
+ if file_extension in SUPPORTED_FILE_EXTENSIONS:
+ self._persist_file(f, os.path.relpath(f, root_dir))
+ else:
for root_path, d_names, f_names in os.walk(root_dir):
if any(re.findall(re.compile(exp), root_path) for exp in self.excluded_paths):
# no need to persist files from excluded directories
@@ -182,11 +189,6 @@ class BcPlatformIntegration(object):
if file_extension in SUPPORTED_FILE_EXTENSIONS:
full_file_path = os.path.join(root_path, file_path)
relative_file_path = os.path.relpath(full_file_path, root_dir)
- if not files:
- # upload every file since -f was not used.
- self._persist_file(full_file_path, relative_file_path)
- elif full_file_path in files:
- # upload only the files specified in -f.
self._persist_file(full_file_path, relative_file_path)
def persist_scan_results(self, scan_reports):
