socketdev 3.0.16__py3-none-any.whl → 3.0.20__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.
- socketdev/__init__.py +2 -1
- socketdev/core/api.py +6 -1
- socketdev/uploadmanifests/__init__.py +75 -1
- socketdev/version.py +1 -1
- {socketdev-3.0.16.dist-info → socketdev-3.0.20.dist-info}/METADATA +3 -2
- {socketdev-3.0.16.dist-info → socketdev-3.0.20.dist-info}/RECORD +8 -8
- {socketdev-3.0.16.dist-info → socketdev-3.0.20.dist-info}/WHEEL +0 -0
- {socketdev-3.0.16.dist-info → socketdev-3.0.20.dist-info}/licenses/LICENSE +0 -0
socketdev/__init__.py
CHANGED
|
@@ -44,11 +44,12 @@ request_timeout = 1200
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
class socketdev:
|
|
47
|
-
def __init__(self, token: str, timeout: int = 1200):
|
|
47
|
+
def __init__(self, token: str, timeout: int = 1200, allow_unverified: bool = False):
|
|
48
48
|
self.api = API()
|
|
49
49
|
self.token = token + ":"
|
|
50
50
|
self.api.encode_key(self.token)
|
|
51
51
|
self.api.set_timeout(timeout)
|
|
52
|
+
self.api.set_allow_unverified(allow_unverified)
|
|
52
53
|
|
|
53
54
|
self.dependencies = Dependencies(self.api)
|
|
54
55
|
self.export = Export(self.api)
|
socketdev/core/api.py
CHANGED
|
@@ -25,6 +25,7 @@ class API:
|
|
|
25
25
|
self.encoded_key = None
|
|
26
26
|
self.api_url = "https://api.socket.dev/v0"
|
|
27
27
|
self.request_timeout = 30
|
|
28
|
+
self.allow_unverified = False
|
|
28
29
|
|
|
29
30
|
def encode_key(self, token: str):
|
|
30
31
|
self.encoded_key = base64.b64encode(token.encode()).decode("ascii")
|
|
@@ -32,6 +33,9 @@ class API:
|
|
|
32
33
|
def set_timeout(self, timeout: int):
|
|
33
34
|
self.request_timeout = timeout
|
|
34
35
|
|
|
36
|
+
def set_allow_unverified(self, allow_unverified: bool):
|
|
37
|
+
self.allow_unverified = allow_unverified
|
|
38
|
+
|
|
35
39
|
def do_request(
|
|
36
40
|
self,
|
|
37
41
|
path: str,
|
|
@@ -58,7 +62,8 @@ class API:
|
|
|
58
62
|
try:
|
|
59
63
|
|
|
60
64
|
response = requests.request(
|
|
61
|
-
method.upper(), url, headers=headers, data=payload, files=files,
|
|
65
|
+
method.upper(), url, headers=headers, data=payload, files=files,
|
|
66
|
+
timeout=self.request_timeout, verify=not self.allow_unverified
|
|
62
67
|
)
|
|
63
68
|
request_duration = time.time() - start_time
|
|
64
69
|
|
|
@@ -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
|
|
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.
|
|
1
|
+
__version__ = "3.0.20"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: socketdev
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.20
|
|
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>
|
|
@@ -71,7 +71,8 @@ Initializing the module
|
|
|
71
71
|
**PARAMETERS:**
|
|
72
72
|
|
|
73
73
|
- **token (str)** - The Socket API Key for your Organization
|
|
74
|
-
- **
|
|
74
|
+
- **timeout (int)** - The number of seconds to wait before failing the connection
|
|
75
|
+
- **allow_unverified (bool)** - Whether to skip SSL certificate verification (default: False). Set to True for testing with self-signed certificates.
|
|
75
76
|
|
|
76
77
|
Supported Functions
|
|
77
78
|
-------------------
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
socketdev/__init__.py,sha256=
|
|
1
|
+
socketdev/__init__.py,sha256=huea0EKxNEolh19KXWvmlJGa_lTeYIuks8VCyezXOic,3090
|
|
2
2
|
socketdev/exceptions.py,sha256=SNU1EgswGwnxI_Zmm325ruP6CFg5C4MsS1qxXWwBJqs,1120
|
|
3
3
|
socketdev/log.py,sha256=AgEcsPN3y9U-fze8pTFvLigVvNob2vmNC-TkOOQkkeQ,90
|
|
4
|
-
socketdev/version.py,sha256=
|
|
4
|
+
socketdev/version.py,sha256=i7VhYKmHJiagr-PY7e9uws903hsi4fJbmE2GatnTMqc,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
|
|
8
8
|
socketdev/auditlog/__init__.py,sha256=vjcVtOK6oujqC6-RW5Hrvmth5BqFkLdinbeyqtycOpA,881
|
|
9
9
|
socketdev/basics/__init__.py,sha256=9jTEwC4dMUV-9pKpU4twK-hM1cY0xeXAxjDrb37sxoQ,4067
|
|
10
|
-
socketdev/core/api.py,sha256=
|
|
10
|
+
socketdev/core/api.py,sha256=7G4FY3rbbfU7Vs9LzCrCqRfarX1JC_oBkg4B7_SOsmo,5972
|
|
11
11
|
socketdev/core/classes.py,sha256=fyDlolgnkpHFb1dMHa2SA0czCS1I6Tr3SuYb1a67-dY,3756
|
|
12
12
|
socketdev/core/dedupe.py,sha256=bvX92ia4anVQtEv18LaLupisuHg68eNPuLZjmLhhAGE,5493
|
|
13
13
|
socketdev/core/issues.py,sha256=jIfi6h1Y-d38OgxSFhlgC74TLvY6IfUcWhQfLq8FFPo,68147
|
|
@@ -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
|
|
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.
|
|
37
|
-
socketdev-3.0.
|
|
38
|
-
socketdev-3.0.
|
|
39
|
-
socketdev-3.0.
|
|
36
|
+
socketdev-3.0.20.dist-info/METADATA,sha256=PlXc8n5ChOy-CKswEilJXyMTL7GlFP5lImgYYiqVsjg,36240
|
|
37
|
+
socketdev-3.0.20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
38
|
+
socketdev-3.0.20.dist-info/licenses/LICENSE,sha256=mC0II_UuE-_gCG9XqOLNyrV3crnROzMpdAetGnMrhpw,1068
|
|
39
|
+
socketdev-3.0.20.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|