socketsecurity 2.1.28__tar.gz → 2.1.35__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/PKG-INFO +1 -1
  2. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/pyproject.toml +1 -1
  3. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/__init__.py +1 -1
  4. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/core/__init__.py +10 -5
  5. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/core/git_interface.py +115 -3
  6. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/workflows/github-actions.yml +2 -2
  7. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/.github/CODEOWNERS +0 -0
  8. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/.github/PULL_REQUEST_TEMPLATE/bug-fix.md +0 -0
  9. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/.github/PULL_REQUEST_TEMPLATE/feature.md +0 -0
  10. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/.github/PULL_REQUEST_TEMPLATE/improvement.md +0 -0
  11. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  12. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/.github/workflows/docker-stable.yml +0 -0
  13. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/.github/workflows/pr-preview.yml +0 -0
  14. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/.github/workflows/release.yml +0 -0
  15. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/.github/workflows/version-check.yml +0 -0
  16. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/.gitignore +0 -0
  17. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/.hooks/sync_version.py +0 -0
  18. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/.pre-commit-config.yaml +0 -0
  19. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/.python-version +0 -0
  20. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/Dockerfile +0 -0
  21. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/LICENSE +0 -0
  22. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/Makefile +0 -0
  23. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/Pipfile.lock +0 -0
  24. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/README.md +0 -0
  25. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/docs/README.md +0 -0
  26. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/pytest.ini +0 -0
  27. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/requirements-dev.lock +0 -0
  28. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/requirements-dev.txt +0 -0
  29. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/requirements.lock +0 -0
  30. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/requirements.txt +0 -0
  31. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/scripts/build_container.sh +0 -0
  32. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/scripts/deploy-test-docker.sh +0 -0
  33. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/scripts/deploy-test-pypi.sh +0 -0
  34. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/scripts/run.sh +0 -0
  35. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/config.py +0 -0
  36. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/core/classes.py +0 -0
  37. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/core/cli_client.py +0 -0
  38. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/core/exceptions.py +0 -0
  39. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/core/helper/__init__.py +0 -0
  40. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/core/lazy_file_loader.py +0 -0
  41. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/core/logging.py +0 -0
  42. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/core/messages.py +0 -0
  43. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/core/resource_utils.py +0 -0
  44. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/core/scm/__init__.py +0 -0
  45. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/core/scm/base.py +0 -0
  46. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/core/scm/client.py +0 -0
  47. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/core/scm/github.py +0 -0
  48. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/core/scm/gitlab.py +0 -0
  49. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/core/scm_comments.py +0 -0
  50. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/core/socket_config.py +0 -0
  51. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/core/utils.py +0 -0
  52. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/output.py +0 -0
  53. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/plugins/__init__.py +0 -0
  54. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/plugins/base.py +0 -0
  55. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/plugins/jira.py +0 -0
  56. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/plugins/manager.py +0 -0
  57. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/plugins/slack.py +0 -0
  58. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/plugins/teams.py +0 -0
  59. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/plugins/webhook.py +0 -0
  60. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/socketsecurity/socketcli.py +0 -0
  61. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/__init__.py +0 -0
  62. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/core/conftest.py +0 -0
  63. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/core/create_diff_input.json +0 -0
  64. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/core/test_diff_generation.py +0 -0
  65. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/core/test_package_and_alerts.py +0 -0
  66. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/core/test_sdk_methods.py +0 -0
  67. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/core/test_supporting_methods.py +0 -0
  68. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/data/fullscans/create_response.json +0 -0
  69. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/data/fullscans/diff/stream_diff.json +0 -0
  70. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/data/fullscans/diff/stream_diff_full.json +0 -0
  71. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/data/fullscans/head_scan/metadata.json +0 -0
  72. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/data/fullscans/head_scan/stream_scan.json +0 -0
  73. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/data/fullscans/head_scan/stream_scan_full.json +0 -0
  74. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/data/fullscans/new_scan/metadata.json +0 -0
  75. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/data/fullscans/new_scan/stream_scan.json +0 -0
  76. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/data/repos/repo_info_error.json +0 -0
  77. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/data/repos/repo_info_no_head.json +0 -0
  78. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/data/repos/repo_info_success.json +0 -0
  79. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/data/settings/security-policy.json +0 -0
  80. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/unit/__init__.py +0 -0
  81. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/unit/test_cli_config.py +0 -0
  82. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/unit/test_client.py +0 -0
  83. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/unit/test_config.py +0 -0
  84. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/tests/unit/test_output.py +0 -0
  85. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/workflows/bitbucket-pipelines.yml +0 -0
  86. {socketsecurity-2.1.28 → socketsecurity-2.1.35}/workflows/gitlab-ci.yml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: socketsecurity
3
- Version: 2.1.28
3
+ Version: 2.1.35
4
4
  Summary: Socket Security CLI for CI/CD
5
5
  Project-URL: Homepage, https://socket.dev
6
6
  Author-email: Douglas Coburn <douglas@socket.dev>
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
 
7
7
  [project]
8
8
  name = "socketsecurity"
9
- version = "2.1.28"
9
+ version = "2.1.35"
10
10
  requires-python = ">= 3.10"
11
11
  license = {"file" = "LICENSE"}
12
12
  dependencies = [
@@ -1,2 +1,2 @@
1
1
  __author__ = 'socket.dev'
2
- __version__ = '2.1.28'
2
+ __version__ = '2.1.35'
@@ -389,15 +389,20 @@ class Core:
389
389
  from .utils import socket_globs as fallback_patterns
390
390
  patterns = fallback_patterns
391
391
 
392
+ # Normalize all file paths for matching
393
+ norm_files = [f.replace('\\', '/').lstrip('./') for f in files]
394
+
392
395
  for ecosystem in patterns:
393
396
  ecosystem_patterns = patterns[ecosystem]
394
397
  for file_name in ecosystem_patterns:
395
398
  pattern_str = ecosystem_patterns[file_name]["pattern"]
396
- for file in files:
397
- if "\\" in file:
398
- file = file.replace("\\", "/")
399
- if PurePath(file).match(pattern_str):
400
- return True
399
+ # Expand brace patterns for each manifest pattern
400
+ expanded_patterns = Core.expand_brace_pattern(pattern_str)
401
+ for exp_pat in expanded_patterns:
402
+ for file in norm_files:
403
+ # Use PurePath.match for glob-like matching
404
+ if PurePath(file).match(exp_pat):
405
+ return True
401
406
  return False
402
407
 
403
408
  def check_file_count_limit(self, file_count: int) -> dict:
@@ -12,9 +12,17 @@ class Git:
12
12
 
13
13
  def __init__(self, path: str):
14
14
  self.path = path
15
+ self.ensure_safe_directory(path)
15
16
  self.repo = Repo(path)
16
17
  assert self.repo
17
18
  self.head = self.repo.head
19
+
20
+ # Always fetch all remote refs to ensure branches exist for diffing
21
+ try:
22
+ self.repo.git.fetch('--all')
23
+ log.debug("Fetched all remote refs for diffing.")
24
+ except Exception as fetch_error:
25
+ log.debug(f"Failed to fetch all remote refs: {fetch_error}")
18
26
 
19
27
  # Use CI environment SHA if available, otherwise fall back to current HEAD commit
20
28
  github_sha = os.getenv('GITHUB_SHA')
@@ -128,12 +136,95 @@ class Git:
128
136
  self.commit_sha = self.commit.binsha
129
137
  self.commit_message = self.commit.message
130
138
  self.committer = self.commit.committer
131
- self.show_files = self.repo.git.show(self.commit, name_only=True, format="%n").splitlines()
139
+ # Detect changed files in PR/MR context for GitHub, GitLab, Bitbucket; fallback to git show
140
+ self.show_files = []
141
+ detected = False
142
+ # GitHub Actions PR context
143
+ github_base_ref = os.getenv('GITHUB_BASE_REF')
144
+ github_head_ref = os.getenv('GITHUB_HEAD_REF')
145
+ github_event_name = os.getenv('GITHUB_EVENT_NAME')
146
+ github_before_sha = os.getenv('GITHUB_EVENT_BEFORE') # previous commit for push
147
+ github_sha = os.getenv('GITHUB_SHA') # current commit
148
+ if github_event_name == 'pull_request' and github_base_ref and github_head_ref:
149
+ try:
150
+ # Fetch both branches individually
151
+ self.repo.git.fetch('origin', github_base_ref)
152
+ self.repo.git.fetch('origin', github_head_ref)
153
+ # Try remote diff first
154
+ diff_range = f"origin/{github_base_ref}...origin/{github_head_ref}"
155
+ try:
156
+ diff_files = self.repo.git.diff('--name-only', diff_range)
157
+ self.show_files = diff_files.splitlines()
158
+ log.debug(f"Changed files detected via git diff (GitHub PR remote): {self.show_files}")
159
+ detected = True
160
+ except Exception as remote_error:
161
+ log.debug(f"Remote diff failed: {remote_error}")
162
+ # Try local branch diff
163
+ local_diff_range = f"{github_base_ref}...{github_head_ref}"
164
+ try:
165
+ diff_files = self.repo.git.diff('--name-only', local_diff_range)
166
+ self.show_files = diff_files.splitlines()
167
+ log.debug(f"Changed files detected via git diff (GitHub PR local): {self.show_files}")
168
+ detected = True
169
+ except Exception as local_error:
170
+ log.debug(f"Local diff failed: {local_error}")
171
+ except Exception as error:
172
+ log.debug(f"Failed to fetch branches or diff for GitHub PR: {error}")
173
+ # Commits to default branch (push events)
174
+ elif github_event_name == 'push' and github_before_sha and github_sha:
175
+ try:
176
+ diff_files = self.repo.git.diff('--name-only', f'{github_before_sha}..{github_sha}')
177
+ self.show_files = diff_files.splitlines()
178
+ log.debug(f"Changed files detected via git diff (GitHub push): {self.show_files}")
179
+ detected = True
180
+ except Exception as error:
181
+ log.debug(f"Failed to get changed files via git diff (GitHub push): {error}")
182
+ elif github_event_name == 'push':
183
+ try:
184
+ self.show_files = self.repo.git.show(self.commit, name_only=True, format="%n").splitlines()
185
+ log.debug(f"Changed files detected via git show (GitHub push fallback): {self.show_files}")
186
+ detected = True
187
+ except Exception as error:
188
+ log.debug(f"Failed to get changed files via git show (GitHub push fallback): {error}")
189
+ # GitLab CI Merge Request context
190
+ if not detected:
191
+ gitlab_target = os.getenv('CI_MERGE_REQUEST_TARGET_BRANCH_NAME')
192
+ gitlab_source = os.getenv('CI_MERGE_REQUEST_SOURCE_BRANCH_NAME')
193
+ if gitlab_target and gitlab_source:
194
+ try:
195
+ self.repo.git.fetch('origin', gitlab_target, gitlab_source)
196
+ diff_range = f"origin/{gitlab_target}...origin/{gitlab_source}"
197
+ diff_files = self.repo.git.diff('--name-only', diff_range)
198
+ self.show_files = diff_files.splitlines()
199
+ log.debug(f"Changed files detected via git diff (GitLab): {self.show_files}")
200
+ detected = True
201
+ except Exception as error:
202
+ log.debug(f"Failed to get changed files via git diff (GitLab): {error}")
203
+ # Bitbucket Pipelines PR context
204
+ if not detected:
205
+ bitbucket_pr_id = os.getenv('BITBUCKET_PR_ID')
206
+ bitbucket_source = os.getenv('BITBUCKET_BRANCH')
207
+ bitbucket_dest = os.getenv('BITBUCKET_PR_DESTINATION_BRANCH')
208
+ # BITBUCKET_BRANCH is the source branch in PR builds
209
+ if bitbucket_pr_id and bitbucket_source and bitbucket_dest:
210
+ try:
211
+ self.repo.git.fetch('origin', bitbucket_dest, bitbucket_source)
212
+ diff_range = f"origin/{bitbucket_dest}...origin/{bitbucket_source}"
213
+ diff_files = self.repo.git.diff('--name-only', diff_range)
214
+ self.show_files = diff_files.splitlines()
215
+ log.debug(f"Changed files detected via git diff (Bitbucket): {self.show_files}")
216
+ detected = True
217
+ except Exception as error:
218
+ log.debug(f"Failed to get changed files via git diff (Bitbucket): {error}")
219
+ # Fallback to git show for single commit
220
+ if not detected:
221
+ self.show_files = self.repo.git.show(self.commit, name_only=True, format="%n").splitlines()
222
+ log.debug(f"Changed files detected via git show: {self.show_files}")
132
223
  self.changed_files = []
133
224
  for item in self.show_files:
134
225
  if item != "":
135
- full_path = f"{self.path}/{item}"
136
- self.changed_files.append(full_path)
226
+ # Use relative path for glob matching
227
+ self.changed_files.append(item)
137
228
 
138
229
  # Determine if this commit is on the default branch
139
230
  # This considers both GitHub Actions detached HEAD and regular branch situations
@@ -319,3 +410,24 @@ class Git:
319
410
  except Exception as error:
320
411
  log.debug(f"Error checking if on default branch: {error}")
321
412
  return False
413
+
414
+ @staticmethod
415
+ def ensure_safe_directory(path: str) -> None:
416
+ # Ensure the repo is marked as safe for git (prevents SHA empty/dubious ownership errors)
417
+ try :
418
+ import subprocess
419
+ abs_path = os.path.abspath(path)
420
+ # Get all safe directories
421
+ result = subprocess.run([
422
+ "git", "config", "--global", "--get-all", "safe.directory"
423
+ ], capture_output=True, text=True)
424
+ safe_dirs = result.stdout.splitlines() if result.returncode == 0 else []
425
+ if abs_path not in safe_dirs:
426
+ subprocess.run([
427
+ "git", "config", "--global", "--add", "safe.directory", abs_path
428
+ ], check=True)
429
+ log.debug(f"Added {abs_path} to git safe.directory config.")
430
+ else:
431
+ log.debug(f"{abs_path} already present in git safe.directory config.")
432
+ except Exception as safe_error:
433
+ log.debug(f"Failed to set safe.directory for git: {safe_error}")
@@ -15,7 +15,7 @@ on:
15
15
 
16
16
  # Prevent concurrent runs for the same commit
17
17
  concurrency:
18
- group: socket-scan-${{ github.ref }}-${{ github.sha }}
18
+ group: socket-scan-${{ github.sha }}
19
19
  cancel-in-progress: true
20
20
 
21
21
  jobs:
@@ -33,7 +33,7 @@ jobs:
33
33
  - uses: actions/checkout@v4
34
34
  with:
35
35
  # For PRs, fetch one additional commit for proper diff analysis
36
- fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
36
+ fetch-depth: 0
37
37
 
38
38
  - name: Run Socket Security Scan
39
39
  env:
File without changes