socketdev 3.0.16__py3-none-any.whl → 3.0.17__py3-none-any.whl

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.
@@ -10,6 +10,79 @@ class UploadManifests:
10
10
  def __init__(self, api):
11
11
  self.api = api
12
12
 
13
+ def _calculate_key_name(self, file_path: str, workspace: Optional[str] = None, base_path: Optional[str] = None, base_paths: Optional[List[str]] = None) -> str:
14
+ """
15
+ Calculate the key name for a file using the same logic as load_files_for_sending_lazy.
16
+ This ensures consistency between lazy and non-lazy loading modes.
17
+ """
18
+ # Normalize file path
19
+ if "\\" in file_path:
20
+ file_path = file_path.replace("\\", "/")
21
+
22
+ # Normalize paths
23
+ if workspace and "\\" in workspace:
24
+ workspace = workspace.replace("\\", "/")
25
+ if base_path and "\\" in base_path:
26
+ base_path = base_path.replace("\\", "/")
27
+ if base_paths:
28
+ base_paths = [bp.replace("\\", "/") if "\\" in bp else bp for bp in base_paths]
29
+
30
+ # Calculate the key name for the form data
31
+ key = file_path
32
+ path_stripped = False
33
+
34
+ # If base_paths is provided, try to strip one of the paths from the file path
35
+ if base_paths:
36
+ for bp in base_paths:
37
+ normalized_base_path = bp.rstrip("/") + "/" if not bp.endswith("/") else bp
38
+ if key.startswith(normalized_base_path):
39
+ key = key[len(normalized_base_path):]
40
+ path_stripped = True
41
+ break
42
+ elif key.startswith(bp.rstrip("/")):
43
+ stripped_base = bp.rstrip("/")
44
+ if key.startswith(stripped_base + "/") or key == stripped_base:
45
+ key = key[len(stripped_base):]
46
+ key = key.lstrip("/")
47
+ path_stripped = True
48
+ break
49
+ elif base_path:
50
+ normalized_base_path = base_path.rstrip("/") + "/" if not base_path.endswith("/") else base_path
51
+ if key.startswith(normalized_base_path):
52
+ key = key[len(normalized_base_path):]
53
+ path_stripped = True
54
+ elif key.startswith(base_path.rstrip("/")):
55
+ stripped_base = base_path.rstrip("/")
56
+ if key.startswith(stripped_base + "/") or key == stripped_base:
57
+ key = key[len(stripped_base):]
58
+ key = key.lstrip("/")
59
+ path_stripped = True
60
+
61
+ # If workspace is provided and no base paths matched, fall back to workspace logic
62
+ if not path_stripped and workspace and file_path.startswith(workspace):
63
+ key = file_path[len(workspace):]
64
+ # Remove all leading slashes (for absolute paths)
65
+ while key.startswith("/"):
66
+ key = key[1:]
67
+ path_stripped = True
68
+
69
+ # Clean up relative path prefixes, but preserve filename dots
70
+ while key.startswith("./"):
71
+ key = key[2:]
72
+ while key.startswith("../"):
73
+ key = key[3:]
74
+ # Remove any remaining leading slashes (for absolute paths)
75
+ while key.startswith("/"):
76
+ key = key[1:]
77
+
78
+ # Remove Windows drive letter if present (C:/...)
79
+ if len(key) > 2 and key[1] == ':' and (key[2] == '/' or key[2] == '\\'):
80
+ key = key[2:]
81
+ while key.startswith("/"):
82
+ key = key[1:]
83
+
84
+ return key
85
+
13
86
  def upload_manifest_files(self, org_slug: str, file_paths: List[str], workspace: Optional[str] = None, base_path: Optional[str] = None, base_paths: Optional[List[str]] = None, use_lazy_loading: bool = True) -> str:
14
87
  """
15
88
  Upload manifest files to Socket API and return tarHash.
@@ -46,7 +119,8 @@ class UploadManifests:
46
119
  # Fallback to basic file loading if needed
47
120
  loaded_files = []
48
121
  for file_path in valid_files:
49
- key = os.path.basename(file_path)
122
+ # Use the same key generation logic as lazy loading for consistency
123
+ key = self._calculate_key_name(file_path, workspace, base_path, base_paths)
50
124
  with open(file_path, 'rb') as f:
51
125
  loaded_files.append((key, (key, f.read())))
52
126
 
socketdev/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "3.0.16"
1
+ __version__ = "3.0.17"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: socketdev
3
- Version: 3.0.16
3
+ Version: 3.0.17
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>
@@ -1,7 +1,7 @@
1
1
  socketdev/__init__.py,sha256=aZhHDONQpWnX-Doxf_NNClJREgu-aXvGaEv6xPrYRgI,3001
2
2
  socketdev/exceptions.py,sha256=SNU1EgswGwnxI_Zmm325ruP6CFg5C4MsS1qxXWwBJqs,1120
3
3
  socketdev/log.py,sha256=AgEcsPN3y9U-fze8pTFvLigVvNob2vmNC-TkOOQkkeQ,90
4
- socketdev/version.py,sha256=PqtbPq3twQFhrmoNUmgkuDLFZ2kj-AYNbWriNF-hNQM,23
4
+ socketdev/version.py,sha256=R6f0Unnq7Z8lMwtRKDIicOTUYUnOYPARONzr0oGHSyU,23
5
5
  socketdev/alerttypes/__init__.py,sha256=W-m2D9VxbepSAUELJPmWmX40zksGZbQcSzwQ1kjlB1k,1169
6
6
  socketdev/analytics/__init__.py,sha256=kQGeO67TraqvfmYjfpYCvcNRtxW2a6x5EefEl6Jnca8,2223
7
7
  socketdev/apitokens/__init__.py,sha256=Z6W9Jkh4gdDeJBivfcONZuz7jRKZtxWLTi1n9gkbYVE,4222
@@ -31,9 +31,9 @@ socketdev/settings/__init__.py,sha256=CCRAnFWOvm7Hi4LY0gbFqsOFHNDlWK3FHei0Edcv_-
31
31
  socketdev/threatfeed/__init__.py,sha256=2SsJYKByXBkb2C1fGopwxejkr7mky0kggFKIunyV7Nk,1119
32
32
  socketdev/tools/__init__.py,sha256=ROvpEULLXTKby9DMsVFPlAlysjwfop1NhRqSrFUWprY,1969
33
33
  socketdev/triage/__init__.py,sha256=-h599vThVetfRSOAs1e4IUoMjcXS8xOsUfub41XPiX4,1559
34
- socketdev/uploadmanifests/__init__.py,sha256=7ekyDEa0GCyoLVZUwobgc5jP6hzO-QI45Gz0Cw0nesg,2652
34
+ socketdev/uploadmanifests/__init__.py,sha256=-sFHbOW-aw7U0wRfEJT_Edrzx8aCbzD9cTGmVTNJKpw,6043
35
35
  socketdev/utils/__init__.py,sha256=27OgKDg_0lcrSCUy5g1CV_LTv2_OYb9-wkNiamlTntc,13567
36
- socketdev-3.0.16.dist-info/METADATA,sha256=C6jbmqkQC2C-upL-CJufkwpRWPTMtyhEZx3OtINithI,36090
37
- socketdev-3.0.16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
38
- socketdev-3.0.16.dist-info/licenses/LICENSE,sha256=mC0II_UuE-_gCG9XqOLNyrV3crnROzMpdAetGnMrhpw,1068
39
- socketdev-3.0.16.dist-info/RECORD,,
36
+ socketdev-3.0.17.dist-info/METADATA,sha256=86eT1c8tDWhr9DiZDrx_FxnTXmpoZnV2HEQp-aRmc8E,36090
37
+ socketdev-3.0.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
38
+ socketdev-3.0.17.dist-info/licenses/LICENSE,sha256=mC0II_UuE-_gCG9XqOLNyrV3crnROzMpdAetGnMrhpw,1068
39
+ socketdev-3.0.17.dist-info/RECORD,,