Skip to content

Commit f3f42a0

Browse files
committed
Fixed globbing for files that were unintentionally filtering out paths that started with a dot
1 parent 9fd102a commit f3f42a0

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
66

77
[project]
88
name = "socketsecurity"
9-
version = "2.2.57"
9+
version = "2.2.58"
1010
requires-python = ">= 3.10"
1111
license = {"file" = "LICENSE"}
1212
dependencies = [

socketsecurity/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
__author__ = 'socket.dev'
2-
__version__ = '2.2.57'
2+
__version__ = '2.2.58'
33
USER_AGENT = f'SocketPythonCLI/{__version__}'

socketsecurity/core/__init__.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from dataclasses import asdict
1010
from glob import glob
1111
from io import BytesIO
12-
from pathlib import PurePath
12+
from pathlib import Path, PurePath
1313
from typing import BinaryIO, Dict, List, Tuple, Set, Union, TYPE_CHECKING, Optional
1414

1515
if TYPE_CHECKING:
@@ -315,15 +315,18 @@ def find_files(self, path: str, ecosystems: Optional[List[str]] = None) -> List[
315315

316316
for pattern in expanded_patterns:
317317
case_insensitive_pattern = Core.to_case_insensitive_regex(pattern)
318-
file_path = os.path.join(path, "**", case_insensitive_pattern)
319-
320-
log.debug(f"Globbing {file_path}")
318+
319+
log.debug(f"Searching for pattern: {case_insensitive_pattern}")
321320
glob_start = time.time()
322-
glob_files = glob(file_path, recursive=True)
321+
322+
# Use pathlib.Path.rglob() instead of glob.glob() to properly match dotfiles/dotdirs
323+
base_path = Path(path)
324+
glob_files = base_path.rglob(case_insensitive_pattern)
323325

324326
for glob_file in glob_files:
325-
if os.path.isfile(glob_file) and not Core.is_excluded(glob_file, self.config.excluded_dirs):
326-
files.add(glob_file.replace("\\", "/"))
327+
glob_file_str = str(glob_file)
328+
if os.path.isfile(glob_file_str) and not Core.is_excluded(glob_file_str, self.config.excluded_dirs):
329+
files.add(glob_file_str.replace("\\", "/"))
327330

328331
glob_end = time.time()
329332
log.debug(f"Globbing took {glob_end - glob_start:.4f} seconds")
@@ -414,6 +417,11 @@ def has_manifest_files(self, files: list) -> bool:
414417
# Expand brace patterns for each manifest pattern
415418
expanded_patterns = Core.expand_brace_pattern(pattern_str)
416419
for exp_pat in expanded_patterns:
420+
# If pattern doesn't contain '/', prepend '**/' to match files in any subdirectory
421+
# This ensures patterns like '*requirements.txt' match '.test/requirements.txt'
422+
if '/' not in exp_pat:
423+
exp_pat = f"**/{exp_pat}"
424+
417425
for file in norm_files:
418426
# Use PurePath.match for glob-like matching
419427
if PurePath(file).match(exp_pat):

0 commit comments

Comments
 (0)