Skip to content

Commit 6d4fc56

Browse files
authored
manifest file search now case-insensitive (#35)
1 parent f874edb commit 6d4fc56

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

Diff for: socketsecurity/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
__author__ = 'socket.dev'
2-
__version__ = '1.0.37'
2+
__version__ = '1.0.38'

Diff for: socketsecurity/core/__init__.py

+24-14
Original file line numberDiff line numberDiff line change
@@ -410,12 +410,15 @@ def match_supported_files(files: list) -> bool:
410410
patterns = socket_globs[ecosystem]
411411
for file_name in patterns:
412412
pattern = patterns[file_name]["pattern"]
413-
# path_pattern = f"**/{pattern}"
414413
for file in files:
415414
if "\\" in file:
416415
file = file.replace("\\", "/")
417-
if PurePath(file).match(pattern):
418-
matched_files.append(file)
416+
# Split path and filename
417+
path_parts = PurePath(file).parts
418+
if path_parts:
419+
# Compare only the filename portion case-insensitively
420+
if PurePath(path_parts[-1].lower()).match(pattern.lower()):
421+
matched_files.append(file)
419422
if len(matched_files) == 0:
420423
not_matched = True
421424
return not_matched
@@ -435,17 +438,24 @@ def find_files(path: str) -> list:
435438
patterns = socket_globs[ecosystem]
436439
for file_name in patterns:
437440
pattern = patterns[file_name]["pattern"]
438-
file_path = f"{path}/**/{pattern}"
439-
440-
log.debug(f"Globbing {file_path}")
441-
glob_start = time.time()
442-
glob_files = glob(file_path, recursive=True)
443-
for glob_file in glob_files:
444-
if glob_file not in files:
445-
files.add(glob_file)
446-
glob_end = time.time()
447-
glob_total_time = glob_end - glob_start
448-
log.debug(f"Glob for pattern {file_path} took {glob_total_time:.2f} seconds")
441+
# Keep path as-is but try filename variations
442+
file_paths = [
443+
f"{path}/**/{pattern}",
444+
f"{path}/**/{pattern.lower()}",
445+
f"{path}/**/{pattern.upper()}",
446+
f"{path}/**/{pattern.capitalize()}"
447+
]
448+
449+
for file_path in file_paths:
450+
log.debug(f"Globbing {file_path}")
451+
glob_start = time.time()
452+
glob_files = glob(file_path, recursive=True)
453+
for glob_file in glob_files:
454+
if glob_file not in files:
455+
files.add(glob_file)
456+
glob_end = time.time()
457+
glob_total_time = glob_end - glob_start
458+
log.debug(f"Glob for pattern {file_path} took {glob_total_time:.2f} seconds")
449459

450460
log.debug("Finished Find Files")
451461
end_time = time.time()

0 commit comments

Comments
 (0)