socketdev 3.0.5__tar.gz → 3.0.6__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 (64) hide show
  1. {socketdev-3.0.5 → socketdev-3.0.6}/PKG-INFO +1 -1
  2. {socketdev-3.0.5 → socketdev-3.0.6}/pyproject.toml +1 -1
  3. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/diffscans/__init__.py +4 -3
  4. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/fullscans/__init__.py +3 -2
  5. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/utils/__init__.py +33 -8
  6. socketdev-3.0.6/socketdev/version.py +1 -0
  7. {socketdev-3.0.5 → socketdev-3.0.6}/tests/integration/test_comprehensive_integration.py +1 -1
  8. {socketdev-3.0.5 → socketdev-3.0.6}/tests/unit/test_working_endpoints_unit.py +5 -5
  9. socketdev-3.0.5/socketdev/version.py +0 -1
  10. {socketdev-3.0.5 → socketdev-3.0.6}/.github/CODEOWNERS +0 -0
  11. {socketdev-3.0.5 → socketdev-3.0.6}/.github/PULL_REQUEST_TEMPLATE/bug-fix.md +0 -0
  12. {socketdev-3.0.5 → socketdev-3.0.6}/.github/PULL_REQUEST_TEMPLATE/feature.md +0 -0
  13. {socketdev-3.0.5 → socketdev-3.0.6}/.github/PULL_REQUEST_TEMPLATE/improvement.md +0 -0
  14. {socketdev-3.0.5 → socketdev-3.0.6}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  15. {socketdev-3.0.5 → socketdev-3.0.6}/.github/workflows/pr-preview.yml +0 -0
  16. {socketdev-3.0.5 → socketdev-3.0.6}/.github/workflows/release.yml +0 -0
  17. {socketdev-3.0.5 → socketdev-3.0.6}/.github/workflows/version-check.yml +0 -0
  18. {socketdev-3.0.5 → socketdev-3.0.6}/.gitignore +0 -0
  19. {socketdev-3.0.5 → socketdev-3.0.6}/.hooks/sync_version.py +0 -0
  20. {socketdev-3.0.5 → socketdev-3.0.6}/.python-version +0 -0
  21. {socketdev-3.0.5 → socketdev-3.0.6}/LICENSE +0 -0
  22. {socketdev-3.0.5 → socketdev-3.0.6}/README.rst +0 -0
  23. {socketdev-3.0.5 → socketdev-3.0.6}/scripts/build.sh +0 -0
  24. {socketdev-3.0.5 → socketdev-3.0.6}/scripts/deploy-test-pypi.sh +0 -0
  25. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/__init__.py +0 -0
  26. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/alerttypes/__init__.py +0 -0
  27. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/analytics/__init__.py +0 -0
  28. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/apitokens/__init__.py +0 -0
  29. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/auditlog/__init__.py +0 -0
  30. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/core/api.py +0 -0
  31. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/core/classes.py +0 -0
  32. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/core/dedupe.py +0 -0
  33. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/core/issues.py +0 -0
  34. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/dependencies/__init__.py +0 -0
  35. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/exceptions.py +0 -0
  36. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/export/__init__.py +0 -0
  37. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/historical/__init__.py +0 -0
  38. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/labels/__init__.py +0 -0
  39. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/licensemetadata/__init__.py +0 -0
  40. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/log.py +0 -0
  41. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/npm/__init__.py +0 -0
  42. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/openapi/__init__.py +0 -0
  43. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/org/__init__.py +0 -0
  44. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/purl/__init__.py +0 -0
  45. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/quota/__init__.py +0 -0
  46. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/report/__init__.py +0 -0
  47. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/repos/__init__.py +0 -0
  48. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/repositories/__init__.py +0 -0
  49. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/sbom/__init__.py +0 -0
  50. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/settings/__init__.py +0 -0
  51. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/threatfeed/__init__.py +0 -0
  52. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/tools/__init__.py +0 -0
  53. {socketdev-3.0.5 → socketdev-3.0.6}/socketdev/triage/__init__.py +0 -0
  54. {socketdev-3.0.5 → socketdev-3.0.6}/tests/README.md +0 -0
  55. {socketdev-3.0.5 → socketdev-3.0.6}/tests/conftest.py +0 -0
  56. {socketdev-3.0.5 → socketdev-3.0.6}/tests/integration/test_all_endpoints.py +0 -0
  57. {socketdev-3.0.5 → socketdev-3.0.6}/tests/integration/test_diffscans_integration.py +0 -0
  58. {socketdev-3.0.5 → socketdev-3.0.6}/tests/integration/test_new_endpoints.py +0 -0
  59. {socketdev-3.0.5 → socketdev-3.0.6}/tests/run_tests.py +0 -0
  60. {socketdev-3.0.5 → socketdev-3.0.6}/tests/unit/__init__.py +0 -0
  61. {socketdev-3.0.5 → socketdev-3.0.6}/tests/unit/test_all_endpoints_unit.py +0 -0
  62. {socketdev-3.0.5 → socketdev-3.0.6}/tests/unit/test_dedupe.py +0 -0
  63. {socketdev-3.0.5 → socketdev-3.0.6}/tests/unit/test_socket_sdk_unit.py +0 -0
  64. {socketdev-3.0.5 → socketdev-3.0.6}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: socketdev
3
- Version: 3.0.5
3
+ Version: 3.0.6
4
4
  Summary: Socket Security Python SDK
5
5
  Project-URL: Homepage, https://github.com/socketdev/socketdev
6
6
  Author-email: Douglas Coburn <douglas@socket.dev>
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "socketdev"
7
- version = "3.0.5"
7
+ version = "3.0.6"
8
8
  requires-python = ">= 3.9"
9
9
  dependencies = [
10
10
  'requests',
@@ -1,6 +1,6 @@
1
1
  import json
2
2
  import logging
3
- from typing import Any, Dict, Optional, Union
3
+ from typing import Any, Dict, List, Optional, Union
4
4
  from ..utils import Utils
5
5
 
6
6
  log = logging.getLogger("socketdev")
@@ -30,7 +30,7 @@ class DiffScans:
30
30
  log.error(f"Error fetching diff scan: {response.status_code}, message: {response.text}")
31
31
  return {}
32
32
 
33
- def create_from_repo(self, org_slug: str, repo_slug: str, files: list, params: Optional[Dict[str, Any]] = None, use_lazy_loading: bool = False, workspace: str = None, max_open_files: int = 100, base_path: str = None) -> dict:
33
+ def create_from_repo(self, org_slug: str, repo_slug: str, files: list, params: Optional[Dict[str, Any]] = None, use_lazy_loading: bool = False, workspace: str = None, max_open_files: int = 100, base_path: str = None, base_paths: list = None) -> dict:
34
34
  """
35
35
  Create a diff scan from repo HEAD, uploading files as multipart form data.
36
36
 
@@ -46,6 +46,7 @@ class DiffScans:
46
46
  max_open_files: Maximum number of files to keep open simultaneously when using
47
47
  lazy loading. Useful for systems with low ulimit values (default: 100)
48
48
  base_path: Optional base path to strip from key names for cleaner file organization
49
+ base_paths: Optional list of base paths to strip from key names (takes precedence over base_path)
49
50
 
50
51
  Returns:
51
52
  dict: API response containing diff scan results
@@ -64,7 +65,7 @@ class DiffScans:
64
65
 
65
66
  # Use lazy loading if requested
66
67
  if use_lazy_loading:
67
- prepared_files = Utils.load_files_for_sending_lazy(files, workspace, max_open_files, base_path)
68
+ prepared_files = Utils.load_files_for_sending_lazy(files, workspace, max_open_files, base_path, base_paths)
68
69
  else:
69
70
  prepared_files = files
70
71
 
@@ -728,7 +728,7 @@ class FullScans:
728
728
  )
729
729
  return {}
730
730
 
731
- def post(self, files: list, params: FullScanParams, use_types: bool = False, use_lazy_loading: bool = False, workspace: str = None, max_open_files: int = 100, base_path: str = None) -> Union[dict, CreateFullScanResponse]:
731
+ def post(self, files: list, params: FullScanParams, use_types: bool = False, use_lazy_loading: bool = False, workspace: str = None, max_open_files: int = 100, base_path: str = None, base_paths: List[str] = None) -> Union[dict, CreateFullScanResponse]:
732
732
  """
733
733
  Create a new full scan by uploading manifest files.
734
734
 
@@ -743,6 +743,7 @@ class FullScans:
743
743
  max_open_files: Maximum number of files to keep open simultaneously when using
744
744
  lazy loading. Useful for systems with low ulimit values (default: 100)
745
745
  base_path: Optional base path to strip from key names for cleaner file organization
746
+ base_paths: Optional list of base paths to strip from key names (takes precedence over base_path)
746
747
 
747
748
  Returns:
748
749
  dict or CreateFullScanResponse: API response containing scan results
@@ -763,7 +764,7 @@ class FullScans:
763
764
 
764
765
  # Use lazy loading if requested
765
766
  if use_lazy_loading:
766
- prepared_files = Utils.load_files_for_sending_lazy(files, workspace, max_open_files, base_path)
767
+ prepared_files = Utils.load_files_for_sending_lazy(files, workspace, max_open_files, base_path, base_paths)
767
768
  else:
768
769
  prepared_files = files
769
770
 
@@ -233,7 +233,7 @@ class Utils:
233
233
  return integration_type # type: ignore
234
234
 
235
235
  @staticmethod
236
- def load_files_for_sending_lazy(files: List[str], workspace: str = None, max_open_files: int = 100, base_path: str = None) -> List[Tuple[str, Tuple[str, LazyFileLoader]]]:
236
+ def load_files_for_sending_lazy(files: List[str], workspace: str = None, max_open_files: int = 100, base_path: str = None, base_paths: List[str] = None) -> List[Tuple[str, Tuple[str, LazyFileLoader]]]:
237
237
  """
238
238
  Prepares files for sending to the Socket API using lazy loading.
239
239
 
@@ -247,6 +247,7 @@ class Utils:
247
247
  workspace: Base directory path to make paths relative to
248
248
  max_open_files: Maximum number of files to keep open simultaneously (default: 100)
249
249
  base_path: Optional base path to strip from key names for cleaner file organization
250
+ base_paths: Optional list of base paths to strip from key names (takes precedence over base_path)
250
251
 
251
252
  Returns:
252
253
  List of tuples formatted for requests multipart upload:
@@ -260,6 +261,8 @@ class Utils:
260
261
  workspace = workspace.replace("\\", "/")
261
262
  if base_path and "\\" in base_path:
262
263
  base_path = base_path.replace("\\", "/")
264
+ if base_paths:
265
+ base_paths = [bp.replace("\\", "/") if "\\" in bp else bp for bp in base_paths]
263
266
 
264
267
  for file_path in files:
265
268
  # Normalize file path
@@ -270,29 +273,51 @@ class Utils:
270
273
 
271
274
  # Calculate the key name for the form data
272
275
  key = file_path
276
+ path_stripped = False
273
277
 
274
- # If base_path is provided, strip it from the file path to create the key
275
- if base_path:
278
+ # If base_paths is provided, try to strip one of the paths from the file path
279
+ if base_paths:
280
+ for bp in base_paths:
281
+ # Normalize base_path to ensure consistent handling of trailing slashes
282
+ normalized_base_path = bp.rstrip("/") + "/" if not bp.endswith("/") else bp
283
+ if key.startswith(normalized_base_path):
284
+ key = key[len(normalized_base_path):]
285
+ path_stripped = True
286
+ break
287
+ elif key.startswith(bp.rstrip("/")):
288
+ # Handle case where base_path matches exactly without trailing slash
289
+ stripped_base = bp.rstrip("/")
290
+ if key.startswith(stripped_base + "/") or key == stripped_base:
291
+ key = key[len(stripped_base):]
292
+ key = key.lstrip("/")
293
+ path_stripped = True
294
+ break
295
+
296
+ # If base_path is provided and no base_paths matched, use single base_path
297
+ elif base_path:
276
298
  # Normalize base_path to ensure consistent handling of trailing slashes
277
299
  normalized_base_path = base_path.rstrip("/") + "/" if not base_path.endswith("/") else base_path
278
300
  if key.startswith(normalized_base_path):
279
301
  key = key[len(normalized_base_path):]
302
+ path_stripped = True
280
303
  elif key.startswith(base_path.rstrip("/")):
281
304
  # Handle case where base_path matches exactly without trailing slash
282
305
  stripped_base = base_path.rstrip("/")
283
306
  if key.startswith(stripped_base + "/") or key == stripped_base:
284
307
  key = key[len(stripped_base):]
285
308
  key = key.lstrip("/")
309
+ path_stripped = True
286
310
 
287
- # If workspace is provided and base_path wasn't used, fall back to workspace logic
288
- elif workspace and file_path.startswith(workspace):
311
+ # If workspace is provided and no base paths matched, fall back to workspace logic
312
+ if not path_stripped and workspace and file_path.startswith(workspace):
289
313
  key = file_path[len(workspace):]
290
314
  key = key.lstrip("/")
291
315
  key = key.lstrip("./")
316
+ path_stripped = True
292
317
 
293
- # If neither base_path nor workspace matched, clean up the key
294
- if key == file_path:
295
- # No base_path or workspace stripping occurred, clean up leading parts
318
+ # If no path stripping occurred, clean up the key
319
+ if not path_stripped:
320
+ # No base_path, base_paths, or workspace stripping occurred, clean up leading parts
296
321
  key = key.lstrip("/")
297
322
  key = key.lstrip("./")
298
323
 
@@ -0,0 +1 @@
1
+ __version__ = "3.0.6"
@@ -152,7 +152,7 @@ class TestSocketSDKIntegration(unittest.TestCase):
152
152
  self.created_scan_ids.append(scan_id)
153
153
 
154
154
  # Get the scan
155
- scan_info = self.sdk.fullscans.get(self.org_slug, scan_id)
155
+ scan_info = self.sdk.fullscans.get(self.org_slug, {"id": scan_id})
156
156
  self.assertIsInstance(scan_info, dict)
157
157
 
158
158
  # List scans
@@ -346,15 +346,15 @@ class TestWorkingEndpointsUnit(unittest.TestCase):
346
346
  """Test fullscans get - CORRECTED PARAMETER HANDLING."""
347
347
  expected_data = {"id": "scan-123", "status": "completed"}
348
348
  self._mock_response(expected_data)
349
-
350
- # The actual API uses query parameters, not path parameters
349
+
350
+ # When getting a specific scan by ID, it uses path parameters
351
351
  result = self.sdk.fullscans.get("test-org", {"id": "scan-123"})
352
-
352
+
353
353
  self.assertEqual(result, expected_data)
354
354
  call_args = self.mock_requests.request.call_args
355
355
  self.assertEqual(call_args[0][0], "GET")
356
- # Path includes query params, not path segments
357
- self.assertIn("/orgs/test-org/full-scans?id=scan-123", call_args[0][1])
356
+ # Single ID param creates path segment, not query params
357
+ self.assertIn("/orgs/test-org/full-scans/scan-123", call_args[0][1])
358
358
 
359
359
  def test_diffscans_create_from_repo_corrected_unit(self):
360
360
  """Test diffscans creation from repo - CORRECTED PATH."""
@@ -1 +0,0 @@
1
- __version__ = "3.0.5"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes