socketdev 3.0.0__py3-none-any.whl → 3.0.4__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 CHANGED
@@ -19,6 +19,11 @@ from socketdev.utils import Utils, IntegrationType, INTEGRATION_TYPES
19
19
  from socketdev.version import __version__
20
20
  from socketdev.labels import Labels
21
21
  from socketdev.licensemetadata import LicenseMetadata
22
+ from socketdev.threatfeed import ThreatFeed
23
+ from socketdev.apitokens import ApiTokens
24
+ from socketdev.auditlog import AuditLog
25
+ from socketdev.analytics import Analytics
26
+ from socketdev.alerttypes import AlertTypes
22
27
  from socketdev.log import log
23
28
 
24
29
  __author__ = "socket.dev"
@@ -62,6 +67,11 @@ class socketdev:
62
67
  self.labels = Labels(self.api)
63
68
  self.licensemetadata = LicenseMetadata(self.api)
64
69
  self.diffscans = DiffScans(self.api)
70
+ self.threatfeed = ThreatFeed(self.api)
71
+ self.apitokens = ApiTokens(self.api)
72
+ self.auditlog = AuditLog(self.api)
73
+ self.analytics = Analytics(self.api)
74
+ self.alerttypes = AlertTypes(self.api)
65
75
 
66
76
  @staticmethod
67
77
  def set_timeout(timeout: int):
@@ -0,0 +1,38 @@
1
+ import logging
2
+ import json
3
+ from urllib.parse import urlencode
4
+
5
+ log = logging.getLogger("socketdev")
6
+
7
+
8
+ class AlertTypes:
9
+ def __init__(self, api):
10
+ self.api = api
11
+
12
+ def get(self, alert_types: list = None, language: str = "en-US", **kwargs) -> dict:
13
+ """
14
+ Get alert types metadata.
15
+
16
+ Args:
17
+ alert_types: List of alert type strings to get metadata for
18
+ language: Language for alert metadata (default: en-US)
19
+ **kwargs: Additional query parameters
20
+
21
+ Returns:
22
+ dict: API response containing alert types metadata
23
+ """
24
+ path = "alert-types"
25
+ query_params = {"language": language}
26
+ query_params.update(kwargs)
27
+
28
+ if query_params:
29
+ path += "?" + urlencode(query_params)
30
+
31
+ payload = json.dumps(alert_types or [])
32
+ response = self.api.do_request(path=path, method="POST", payload=payload)
33
+
34
+ if response.status_code == 200:
35
+ return response.json()
36
+ log.error(f"Error getting alert types: {response.status_code}")
37
+ log.error(response.text)
38
+ return {}
@@ -0,0 +1,64 @@
1
+ import logging
2
+ from urllib.parse import urlencode
3
+
4
+ log = logging.getLogger("socketdev")
5
+
6
+
7
+ class Analytics:
8
+ def __init__(self, api):
9
+ self.api = api
10
+
11
+ def get_org(self, filter: str, **kwargs) -> list:
12
+ """
13
+ Get organization analytics (deprecated).
14
+
15
+ **DEPRECATED**: Use the Historical module methods instead:
16
+ - sdk.historical.alerts_trend() for alerts analytics
17
+ - sdk.historical.dependencies_trend() for dependencies analytics
18
+
19
+ Args:
20
+ filter: Analytics filter type
21
+ **kwargs: Additional query parameters
22
+
23
+ Returns:
24
+ list: API response containing analytics data
25
+ """
26
+ log.warning("Analytics.get_org() is deprecated. Use Historical module methods instead.")
27
+ path = f"analytics/org/{filter}"
28
+ if kwargs:
29
+ path += "?" + urlencode(kwargs)
30
+
31
+ response = self.api.do_request(path=path)
32
+ if response.status_code == 200:
33
+ return response.json()
34
+ log.error(f"Error getting org analytics: {response.status_code}")
35
+ log.error(response.text)
36
+ return []
37
+
38
+ def get_repo(self, name: str, filter: str, **kwargs) -> list:
39
+ """
40
+ Get repository analytics (deprecated).
41
+
42
+ **DEPRECATED**: Use the Historical module methods instead:
43
+ - sdk.historical.alerts_trend() for alerts analytics
44
+ - sdk.historical.dependencies_trend() for dependencies analytics
45
+
46
+ Args:
47
+ name: Repository name
48
+ filter: Analytics filter type
49
+ **kwargs: Additional query parameters
50
+
51
+ Returns:
52
+ list: API response containing analytics data
53
+ """
54
+ log.warning("Analytics.get_repo() is deprecated. Use Historical module methods instead.")
55
+ path = f"analytics/repo/{name}/{filter}"
56
+ if kwargs:
57
+ path += "?" + urlencode(kwargs)
58
+
59
+ response = self.api.do_request(path=path)
60
+ if response.status_code == 200:
61
+ return response.json()
62
+ log.error(f"Error getting repo analytics: {response.status_code}")
63
+ log.error(response.text)
64
+ return []
@@ -0,0 +1,89 @@
1
+ import logging
2
+ import json
3
+
4
+ log = logging.getLogger("socketdev")
5
+
6
+
7
+ class ApiTokens:
8
+ def __init__(self, api):
9
+ self.api = api
10
+
11
+ def create(self, org_slug: str, **kwargs) -> dict:
12
+ """
13
+ Create a new API token.
14
+
15
+ Args:
16
+ org_slug: Organization slug
17
+ **kwargs: Token configuration parameters
18
+
19
+ Returns:
20
+ dict: API response containing the created token details
21
+ """
22
+ path = f"orgs/{org_slug}/api-tokens"
23
+ payload = json.dumps(kwargs) if kwargs else "{}"
24
+ response = self.api.do_request(path=path, method="POST", payload=payload)
25
+ if response.status_code == 201:
26
+ return response.json()
27
+ log.error(f"Error creating API token: {response.status_code}")
28
+ log.error(response.text)
29
+ return {}
30
+
31
+ def update(self, org_slug: str, **kwargs) -> dict:
32
+ """
33
+ Update an API token.
34
+
35
+ Args:
36
+ org_slug: Organization slug
37
+ **kwargs: Token update parameters
38
+
39
+ Returns:
40
+ dict: API response containing the updated token details
41
+ """
42
+ path = f"orgs/{org_slug}/api-tokens/update"
43
+ payload = json.dumps(kwargs) if kwargs else "{}"
44
+ response = self.api.do_request(path=path, method="POST", payload=payload)
45
+ if response.status_code == 200:
46
+ return response.json()
47
+ log.error(f"Error updating API token: {response.status_code}")
48
+ log.error(response.text)
49
+ return {}
50
+
51
+ def rotate(self, org_slug: str, **kwargs) -> dict:
52
+ """
53
+ Rotate an API token.
54
+
55
+ Args:
56
+ org_slug: Organization slug
57
+ **kwargs: Token rotation parameters
58
+
59
+ Returns:
60
+ dict: API response containing the rotated token details
61
+ """
62
+ path = f"orgs/{org_slug}/api-tokens/rotate"
63
+ payload = json.dumps(kwargs) if kwargs else "{}"
64
+ response = self.api.do_request(path=path, method="POST", payload=payload)
65
+ if response.status_code == 200:
66
+ return response.json()
67
+ log.error(f"Error rotating API token: {response.status_code}")
68
+ log.error(response.text)
69
+ return {}
70
+
71
+ def revoke(self, org_slug: str, **kwargs) -> dict:
72
+ """
73
+ Revoke an API token.
74
+
75
+ Args:
76
+ org_slug: Organization slug
77
+ **kwargs: Token revocation parameters
78
+
79
+ Returns:
80
+ dict: API response confirming token revocation
81
+ """
82
+ path = f"orgs/{org_slug}/api-tokens/revoke"
83
+ payload = json.dumps(kwargs) if kwargs else "{}"
84
+ response = self.api.do_request(path=path, method="POST", payload=payload)
85
+ if response.status_code == 200:
86
+ return response.json()
87
+ log.error(f"Error revoking API token: {response.status_code}")
88
+ log.error(response.text)
89
+ return {}
@@ -0,0 +1,27 @@
1
+ import logging
2
+
3
+ log = logging.getLogger("socketdev")
4
+
5
+
6
+ class AuditLog:
7
+ def __init__(self, api):
8
+ self.api = api
9
+
10
+ def get(self, org_slug: str, **kwargs) -> dict:
11
+ """
12
+ Get audit log entries for an organization.
13
+
14
+ Args:
15
+ org_slug: Organization slug
16
+ **kwargs: Query parameters like limit, cursor, etc.
17
+
18
+ Returns:
19
+ dict: API response containing audit log entries
20
+ """
21
+ path = f"orgs/{org_slug}/audit-log"
22
+ response = self.api.do_request(path=path, params=kwargs)
23
+ if response.status_code == 200:
24
+ return response.json()
25
+ log.error(f"Error getting audit log: {response.status_code}")
26
+ log.error(response.text)
27
+ return {"results": []}
socketdev/core/dedupe.py CHANGED
@@ -61,7 +61,29 @@ class Dedupe:
61
61
  base = package_group[0]
62
62
  base["releases"] = sorted(releases)
63
63
  base["alerts"] = list(alert_map.values())
64
- base["purl"] = f"pkg:{base.get('type', 'unknown')}/{base.get('name', 'unknown')}@{base.get('version', '0.0.0')}"
64
+
65
+ # Use inputPurl if available and complete, otherwise construct proper purl with namespace
66
+ if "inputPurl" in base and "@" in base["inputPurl"]:
67
+ # inputPurl has version, use it as-is
68
+ base["purl"] = base["inputPurl"]
69
+ else:
70
+ # Construct purl properly with namespace and version
71
+ purl_type = base.get('type', 'unknown')
72
+ namespace = base.get('namespace')
73
+ name = base.get('name', 'unknown')
74
+ version = base.get('version', '0.0.0')
75
+
76
+ # Start with inputPurl if available (without version) or construct from scratch
77
+ if "inputPurl" in base and not "@" in base["inputPurl"]:
78
+ # inputPurl exists but lacks version, append it
79
+ base["purl"] = f"{base['inputPurl']}@{version}"
80
+ else:
81
+ # Construct complete purl from components
82
+ if namespace:
83
+ base["purl"] = f"pkg:{purl_type}/{namespace}/{name}@{version}"
84
+ else:
85
+ base["purl"] = f"pkg:{purl_type}/{name}@{version}"
86
+
65
87
  return base
66
88
 
67
89
  @staticmethod
@@ -0,0 +1,37 @@
1
+ import logging
2
+ from urllib.parse import urlencode
3
+
4
+ log = logging.getLogger("socketdev")
5
+
6
+
7
+ class ThreatFeed:
8
+ def __init__(self, api):
9
+ self.api = api
10
+
11
+ def get(self, org_slug: str = None, **kwargs) -> dict:
12
+ """
13
+ Get threat feed items.
14
+
15
+ Args:
16
+ org_slug: Organization slug (required for the new endpoint)
17
+ **kwargs: Query parameters like per_page, page_cursor, sort, etc.
18
+
19
+ Returns:
20
+ dict: API response containing threat feed items
21
+ """
22
+ if org_slug:
23
+ # Use the new org-scoped endpoint
24
+ path = f"orgs/{org_slug}/threat-feed"
25
+ else:
26
+ # Use the deprecated global endpoint
27
+ path = "threat-feed"
28
+
29
+ if kwargs:
30
+ path += "?" + urlencode(kwargs)
31
+
32
+ response = self.api.do_request(path=path)
33
+ if response.status_code == 200:
34
+ return response.json()
35
+ log.error(f"Error getting threat feed: {response.status_code}")
36
+ log.error(response.text)
37
+ return {"results": [], "nextPage": None}
socketdev/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "3.0.0"
1
+ __version__ = "3.0.4"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: socketdev
3
- Version: 3.0.0
3
+ Version: 3.0.4
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>
@@ -161,9 +161,9 @@ Export a Socket SBOM as an SPDX SBOM
161
161
  - **project_version (str)** - Filter by project version
162
162
  - **project_id (str)** - Filter by project ID
163
163
 
164
- fullscans.get(org_slug)
165
- """""""""""""""""""""""
166
- Retrieve the Fullscans information for around Organization
164
+ fullscans.get(org_slug, params)
165
+ """""""""""""""""""""""""""""""
166
+ Retrieve the Fullscans information for an Organization with query parameters
167
167
 
168
168
  **Usage:**
169
169
 
@@ -171,11 +171,20 @@ Retrieve the Fullscans information for around Organization
171
171
 
172
172
  from socketdev import socketdev
173
173
  socket = socketdev(token="REPLACE_ME")
174
- print(socket.fullscans.get("org_slug"))
174
+
175
+ # Query parameters for filtering full scans
176
+ params = {
177
+ "repo": "my-repo",
178
+ "branch": "main",
179
+ "limit": 10,
180
+ "offset": 0
181
+ }
182
+ print(socket.fullscans.get("org_slug", params))
175
183
 
176
184
  **PARAMETERS:**
177
185
 
178
186
  - **org_slug (str)** - The organization name
187
+ - **params (dict)** - Query parameters for filtering results (required)
179
188
 
180
189
  fullscans.post(files, params)
181
190
  """""""""""""""""""""""""""""
@@ -186,29 +195,30 @@ Create a full scan from a set of package manifest files. Returns a full scan inc
186
195
  .. code-block:: python
187
196
 
188
197
  from socketdev import socketdev
198
+ from socketdev.fullscans import FullScanParams
199
+
189
200
  socket = socketdev(token="REPLACE_ME")
190
201
  files = [
191
202
  "/path/to/manifest/package.json"
192
203
  ]
193
- params = {
194
- "org_slug": "org_name",
195
- "repo": "TestRepo",
196
- "branch": "main",
197
- "commit_message": "Test Commit Message",
198
- "commit_hash": "",
199
- "pull_request": "",
200
- "committers": "commiter",
201
- "make_default_branch": False,
202
- "set_as_pending_head": False,
203
- "tmp": ""
204
- }
204
+ params = FullScanParams(
205
+ org_slug="org_name",
206
+ repo="TestRepo",
207
+ branch="main",
208
+ commit_message="Test Commit Message",
209
+ commit_hash="abc123def456",
210
+ pull_request=123,
211
+ committers=["committer1", "committer2"],
212
+ make_default_branch=False,
213
+ set_as_pending_head=False
214
+ )
205
215
 
206
216
  print(socket.fullscans.post(files, params))
207
217
 
208
218
  **PARAMETERS:**
209
219
 
210
220
  - **files (list)** - List of file paths of manifest files
211
- - **params (dict)** - List of parameters to create a fullscan
221
+ - **params (FullScanParams)** - FullScanParams object containing scan configuration
212
222
 
213
223
  +------------------------+------------+-------------------------------------------------------------------------------+
214
224
  | Parameter | Required | Description |
@@ -219,20 +229,23 @@ Create a full scan from a set of package manifest files. Returns a full scan inc
219
229
  +------------------------+------------+-------------------------------------------------------------------------------+
220
230
  | branch | False | The string name in a git approved name for branches. |
221
231
  +------------------------+------------+-------------------------------------------------------------------------------+
222
- | committers | False | The string name of the person doing the commit or running the CLI. |
223
- | | | Can be specified multiple times to have more than one committer. |
232
+ | committers | False | List of committer names (List[str]). |
224
233
  +------------------------+------------+-------------------------------------------------------------------------------+
225
234
  | pull_request | False | The integer for the PR or MR number. |
226
235
  +------------------------+------------+-------------------------------------------------------------------------------+
227
236
  | commit_message | False | The string for a commit message if there is one. |
228
237
  +------------------------+------------+-------------------------------------------------------------------------------+
229
- | make_default_branch | False | If the flag is specified this will signal that this is the default branch. |
238
+ | make_default_branch | False | Boolean to signal that this is the default branch. |
230
239
  +------------------------+------------+-------------------------------------------------------------------------------+
231
240
  | commit_hash | False | Optional git commit hash |
232
241
  +------------------------+------------+-------------------------------------------------------------------------------+
233
- | set_as_pending_head | False | |
242
+ | set_as_pending_head | False | Boolean to set as pending head |
234
243
  +------------------------+------------+-------------------------------------------------------------------------------+
235
- | tmp | False | |
244
+ | tmp | False | Boolean temporary flag |
245
+ +------------------------+------------+-------------------------------------------------------------------------------+
246
+ | integration_type | False | IntegrationType enum value (e.g., "api", "github") |
247
+ +------------------------+------------+-------------------------------------------------------------------------------+
248
+ | integration_org_slug | False | Organization slug for integration |
236
249
  +------------------------+------------+-------------------------------------------------------------------------------+
237
250
 
238
251
  fullscans.delete(org_slug, full_scan_id)
@@ -245,15 +258,15 @@ Delete an existing full scan.
245
258
 
246
259
  from socketdev import socketdev
247
260
  socket = socketdev(token="REPLACE_ME")
248
- print(socket.fullscans.delete(org_slug, full_scan_id))
261
+ print(socket.fullscans.delete("org_slug", "full_scan_id"))
249
262
 
250
263
  **PARAMETERS:**
251
264
 
252
265
  - **org_slug (str)** - The organization name
253
266
  - **full_scan_id (str)** - The ID of the full scan
254
267
 
255
- fullscans.stream_diff(org_slug, before, after, preview, include_license_details)
256
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
268
+ fullscans.stream_diff(org_slug, before, after, use_types=True, include_license_details="true", \*\*kwargs)
269
+ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
257
270
  Stream a diff between two full scans. Returns a scan diff.
258
271
 
259
272
  **Usage:**
@@ -263,16 +276,27 @@ Stream a diff between two full scans. Returns a scan diff.
263
276
  from socketdev import socketdev
264
277
  socket = socketdev(token="REPLACE_ME")
265
278
  print(socket.fullscans.stream_diff("org_slug", "before_scan_id", "after_scan_id"))
279
+
280
+ # With additional parameters
281
+ print(socket.fullscans.stream_diff(
282
+ "org_slug",
283
+ "before_scan_id",
284
+ "after_scan_id",
285
+ use_types=False,
286
+ include_license_details="false"
287
+ ))
266
288
 
267
289
  **PARAMETERS:**
268
290
 
269
291
  - **org_slug (str)** - The organization name
270
292
  - **before (str)** - The base full scan ID
271
293
  - **after (str)** - The comparison full scan ID
272
- - **include_license_details (bool)** - Include license details. Can greatly increase response size. Defaults to False.
294
+ - **use_types (bool)** - Whether to return typed response objects (default: True)
295
+ - **include_license_details (str)** - Include license details ("true"/"false"). Can greatly increase response size. Defaults to "true".
296
+ - **kwargs** - Additional query parameters
273
297
 
274
- fullscans.stream(org_slug, full_scan_id)
275
- """"""""""""""""""""""""""""""""""""""""
298
+ fullscans.stream(org_slug, full_scan_id, use_types=False)
299
+ """""""""""""""""""""""""""""""""""""""""""""""""""""""""
276
300
  Stream all SBOM artifacts for a full scan.
277
301
 
278
302
  **Usage:**
@@ -281,15 +305,19 @@ Stream all SBOM artifacts for a full scan.
281
305
 
282
306
  from socketdev import socketdev
283
307
  socket = socketdev(token="REPLACE_ME")
284
- print(socket.fullscans.stream(org_slug, full_scan_id))
308
+ print(socket.fullscans.stream("org_slug", "full_scan_id"))
309
+
310
+ # With typed response
311
+ print(socket.fullscans.stream("org_slug", "full_scan_id", use_types=True))
285
312
 
286
313
  **PARAMETERS:**
287
314
 
288
315
  - **org_slug (str)** - The organization name
289
316
  - **full_scan_id (str)** - The ID of the full scan
317
+ - **use_types (bool)** - Whether to return typed response objects (default: False)
290
318
 
291
- fullscans.metadata(org_slug, full_scan_id)
292
- """"""""""""""""""""""""""""""""""""""""""
319
+ fullscans.metadata(org_slug, full_scan_id, use_types=False)
320
+ """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
293
321
  Get metadata for a single full scan
294
322
 
295
323
  **Usage:**
@@ -298,12 +326,34 @@ Get metadata for a single full scan
298
326
 
299
327
  from socketdev import socketdev
300
328
  socket = socketdev(token="REPLACE_ME")
301
- print(socket.fullscans.metadata(org_slug, full_scan_id))
329
+ print(socket.fullscans.metadata("org_slug", "full_scan_id"))
330
+
331
+ # With typed response
332
+ print(socket.fullscans.metadata("org_slug", "full_scan_id", use_types=True))
302
333
 
303
334
  **PARAMETERS:**
304
335
 
305
336
  - **org_slug (str)** - The organization name
306
337
  - **full_scan_id (str)** - The ID of the full scan
338
+ - **use_types (bool)** - Whether to return typed response objects (default: False)
339
+
340
+ fullscans.gfm(org_slug, before, after)
341
+ """"""""""""""""""""""""""""""""""""""
342
+ Get GitHub Flavored Markdown diff between two full scans.
343
+
344
+ **Usage:**
345
+
346
+ .. code-block:: python
347
+
348
+ from socketdev import socketdev
349
+ socket = socketdev(token="REPLACE_ME")
350
+ print(socket.fullscans.gfm("org_slug", "before_scan_id", "after_scan_id"))
351
+
352
+ **PARAMETERS:**
353
+
354
+ - **org_slug (str)** - The organization name
355
+ - **before (str)** - The base full scan ID
356
+ - **after (str)** - The comparison full scan ID
307
357
 
308
358
  dependencies.get(limit, offset)
309
359
  """""""""""""""""""""""""""""""
@@ -337,7 +387,7 @@ Retrieve the dependencies for the organization associated with the API Key
337
387
  ]
338
388
  params = {
339
389
  "repository": "username/repo-name",
340
- "branch": "dependency-branch
390
+ "branch": "dependency-branch"
341
391
  }
342
392
  print(socket.dependencies.post(file_names, params))
343
393
 
@@ -348,7 +398,7 @@ Retrieve the dependencies for the organization associated with the API Key
348
398
 
349
399
  repos.get()
350
400
  """""""""""
351
- Get a list of information about the tracked repositores
401
+ Get a list of information about the tracked repositories
352
402
 
353
403
  **Usage:**
354
404
 
@@ -360,7 +410,7 @@ Get a list of information about the tracked repositores
360
410
 
361
411
  **PARAMETERS:**
362
412
 
363
- - **sort** - The key to sort on froom the repo properties. Defaults to `created_at`
413
+ - **sort** - The key to sort on from the repo properties. Defaults to `created_at`
364
414
  - **direction** - Can be `desc` or `asc`. Defaults to `desc`
365
415
  - **per_page** - Integer between 1 to 100. Defaults to `10`
366
416
  - **page** - Integer page number defaults to `1`. If there are no more results it will be `0`
@@ -397,7 +447,7 @@ Create a new Socket Repository
397
447
 
398
448
  repos.repo()
399
449
  """"""""""""
400
- Get a list of information about the tracked repositores
450
+ Get a list of information about the tracked repositories
401
451
 
402
452
  **Usage:**
403
453
 
@@ -405,7 +455,7 @@ Get a list of information about the tracked repositores
405
455
 
406
456
  from socketdev import socketdev
407
457
  socket = socketdev(token="REPLACE_ME")
408
- print(socket.repos.repo(org_slug="example", repo_name="example-repo")
458
+ print(socket.repos.repo(org_slug="example", repo_name="example-repo"))
409
459
 
410
460
  repos.update()
411
461
  """"""""""""""
@@ -447,7 +497,7 @@ Delete a Socket Repository
447
497
 
448
498
  from socketdev import socketdev
449
499
  socket = socketdev(token="REPLACE_ME")
450
- print(socket.repos.delete(org_slug="example", repo_name="example-repo")
500
+ print(socket.repos.delete(org_slug="example", repo_name="example-repo"))
451
501
 
452
502
  **PARAMETERS:**
453
503
 
@@ -571,7 +621,7 @@ Create a new project health report with the provided files
571
621
 
572
622
  Deprecated: repositories.get()
573
623
  """"""""""""""""""""""""""""""
574
- Get a list of information about the tracked repositores
624
+ Get a list of information about the tracked repositories
575
625
 
576
626
  **Usage:**
577
627
 
@@ -828,3 +878,292 @@ List all historical snapshots for an organization.
828
878
 
829
879
  - **org_slug (str)** – The organization name
830
880
  - **query_params (dict, optional)** – Optional query parameters
881
+
882
+ diffscans.list(org_slug, params=None)
883
+ """""""""""""""""""""""""""""""""""""
884
+ List all diff scans for an organization.
885
+
886
+ **Usage:**
887
+
888
+ .. code-block:: python
889
+
890
+ from socketdev import socketdev
891
+ socket = socketdev(token="REPLACE_ME")
892
+ print(socket.diffscans.list("org_slug", {"limit": 10, "offset": 0}))
893
+
894
+ **PARAMETERS:**
895
+
896
+ - **org_slug (str)** – The organization name
897
+ - **params (dict, optional)** – Optional query parameters for filtering
898
+
899
+ diffscans.get(org_slug, diff_scan_id)
900
+ """""""""""""""""""""""""""""""""""""
901
+ Fetch a specific diff scan by ID.
902
+
903
+ **Usage:**
904
+
905
+ .. code-block:: python
906
+
907
+ from socketdev import socketdev
908
+ socket = socketdev(token="REPLACE_ME")
909
+ print(socket.diffscans.get("org_slug", "diff_scan_id"))
910
+
911
+ **PARAMETERS:**
912
+
913
+ - **org_slug (str)** – The organization name
914
+ - **diff_scan_id (str)** – The ID of the diff scan to retrieve
915
+
916
+ diffscans.create_from_ids(org_slug, params)
917
+ """""""""""""""""""""""""""""""""""""""""""
918
+ Create a diff scan from two full scan IDs.
919
+
920
+ **Usage:**
921
+
922
+ .. code-block:: python
923
+
924
+ from socketdev import socketdev
925
+ socket = socketdev(token="REPLACE_ME")
926
+ params = {
927
+ "before": "full_scan_id_1",
928
+ "after": "full_scan_id_2",
929
+ "description": "Compare two scans"
930
+ }
931
+ print(socket.diffscans.create_from_ids("org_slug", params))
932
+
933
+ **PARAMETERS:**
934
+
935
+ - **org_slug (str)** – The organization name
936
+ - **params (dict)** – Parameters including before and after scan IDs
937
+
938
+ diffscans.create_from_repo(org_slug, repo_slug, files, params=None)
939
+ """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
940
+ Create a diff scan from repository files.
941
+
942
+ **Usage:**
943
+
944
+ .. code-block:: python
945
+
946
+ from socketdev import socketdev
947
+ socket = socketdev(token="REPLACE_ME")
948
+ files = ["/path/to/package.json"]
949
+ params = {"branch": "main", "commit": "abc123"}
950
+ print(socket.diffscans.create_from_repo("org_slug", "repo_slug", files, params))
951
+
952
+ **PARAMETERS:**
953
+
954
+ - **org_slug (str)** – The organization name
955
+ - **repo_slug (str)** – The repository name
956
+ - **files (list)** – List of file paths to scan
957
+ - **params (dict, optional)** – Optional parameters for the scan
958
+
959
+ diffscans.gfm(org_slug, diff_scan_id)
960
+ """""""""""""""""""""""""""""""""""""
961
+ Get GitHub Flavored Markdown comments for a diff scan.
962
+
963
+ **Usage:**
964
+
965
+ .. code-block:: python
966
+
967
+ from socketdev import socketdev
968
+ socket = socketdev(token="REPLACE_ME")
969
+ print(socket.diffscans.gfm("org_slug", "diff_scan_id"))
970
+
971
+ **PARAMETERS:**
972
+
973
+ - **org_slug (str)** – The organization name
974
+ - **diff_scan_id (str)** – The ID of the diff scan
975
+
976
+ diffscans.delete(org_slug, diff_scan_id)
977
+ """"""""""""""""""""""""""""""""""""""""
978
+ Delete a specific diff scan.
979
+
980
+ **Usage:**
981
+
982
+ .. code-block:: python
983
+
984
+ from socketdev import socketdev
985
+ socket = socketdev(token="REPLACE_ME")
986
+ print(socket.diffscans.delete("org_slug", "diff_scan_id"))
987
+
988
+ **PARAMETERS:**
989
+
990
+ - **org_slug (str)** – The organization name
991
+ - **diff_scan_id (str)** – The ID of the diff scan to delete
992
+
993
+ threatfeed.get(org_slug=None, \*\*kwargs)
994
+ """""""""""""""""""""""""""""""""""""""""""
995
+ Get threat feed items for an organization or globally.
996
+
997
+ **Usage:**
998
+
999
+ .. code-block:: python
1000
+
1001
+ from socketdev import socketdev
1002
+ socket = socketdev(token="REPLACE_ME")
1003
+
1004
+ # Get org-specific threat feed
1005
+ print(socket.threatfeed.get("org_slug", per_page=50, sort="created_at"))
1006
+
1007
+ # Get global threat feed (deprecated)
1008
+ print(socket.threatfeed.get())
1009
+
1010
+ **PARAMETERS:**
1011
+
1012
+ - **org_slug (str, optional)** – The organization name (recommended for new implementations)
1013
+ - **kwargs** – Query parameters like per_page, page_cursor, sort, etc.
1014
+
1015
+ apitokens.create(org_slug, \*\*kwargs)
1016
+ """"""""""""""""""""""""""""""""""""""
1017
+ Create a new API token for an organization.
1018
+
1019
+ **Usage:**
1020
+
1021
+ .. code-block:: python
1022
+
1023
+ from socketdev import socketdev
1024
+ socket = socketdev(token="REPLACE_ME")
1025
+ token_config = {
1026
+ "name": "My API Token",
1027
+ "permissions": ["read", "write"],
1028
+ "expires_at": "2024-12-31T23:59:59Z"
1029
+ }
1030
+ print(socket.apitokens.create("org_slug", **token_config))
1031
+
1032
+ **PARAMETERS:**
1033
+
1034
+ - **org_slug (str)** – The organization name
1035
+ - **kwargs** – Token configuration parameters
1036
+
1037
+ apitokens.update(org_slug, \*\*kwargs)
1038
+ """"""""""""""""""""""""""""""""""""""
1039
+ Update an existing API token.
1040
+
1041
+ **Usage:**
1042
+
1043
+ .. code-block:: python
1044
+
1045
+ from socketdev import socketdev
1046
+ socket = socketdev(token="REPLACE_ME")
1047
+ update_params = {
1048
+ "token_id": "token_123",
1049
+ "name": "Updated Token Name",
1050
+ "permissions": ["read"]
1051
+ }
1052
+ print(socket.apitokens.update("org_slug", **update_params))
1053
+
1054
+ **PARAMETERS:**
1055
+
1056
+ - **org_slug (str)** – The organization name
1057
+ - **kwargs** – Token update parameters
1058
+
1059
+ auditlog.get(org_slug, \*\*kwargs)
1060
+ """"""""""""""""""""""""""""""""""""
1061
+ Get audit log entries for an organization.
1062
+
1063
+ **Usage:**
1064
+
1065
+ .. code-block:: python
1066
+
1067
+ from socketdev import socketdev
1068
+ socket = socketdev(token="REPLACE_ME")
1069
+ print(socket.auditlog.get("org_slug", limit=100, cursor="abc123"))
1070
+
1071
+ **PARAMETERS:**
1072
+
1073
+ - **org_slug (str)** – The organization name
1074
+ - **kwargs** – Query parameters like limit, cursor, etc.
1075
+
1076
+ analytics.get_org(filter, \*\*kwargs)
1077
+ """""""""""""""""""""""""""""""""""""""
1078
+ Get organization analytics (deprecated - use Historical module instead).
1079
+
1080
+ **Usage:**
1081
+
1082
+ .. code-block:: python
1083
+
1084
+ from socketdev import socketdev
1085
+ socket = socketdev(token="REPLACE_ME")
1086
+ # DEPRECATED: Use socket.historical.list() or socket.historical.trend() instead
1087
+ print(socket.analytics.get_org("alerts", start_date="2024-01-01"))
1088
+
1089
+ **PARAMETERS:**
1090
+
1091
+ - **filter (str)** – Analytics filter type
1092
+ - **kwargs** – Additional query parameters
1093
+
1094
+ analytics.get_repo(name, filter, \*\*kwargs)
1095
+ """"""""""""""""""""""""""""""""""""""""""""""
1096
+ Get repository analytics (deprecated - use Historical module instead).
1097
+
1098
+ **Usage:**
1099
+
1100
+ .. code-block:: python
1101
+
1102
+ from socketdev import socketdev
1103
+ socket = socketdev(token="REPLACE_ME")
1104
+ # DEPRECATED: Use socket.historical.list() or socket.historical.trend() instead
1105
+ print(socket.analytics.get_repo("repo_name", "alerts", start_date="2024-01-01"))
1106
+
1107
+ **PARAMETERS:**
1108
+
1109
+ - **name (str)** – Repository name
1110
+ - **filter (str)** – Analytics filter type
1111
+ - **kwargs** – Additional query parameters
1112
+
1113
+ alerttypes.get(alert_types=None, language="en-US", \*\*kwargs)
1114
+ """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1115
+ Get alert types metadata.
1116
+
1117
+ **Usage:**
1118
+
1119
+ .. code-block:: python
1120
+
1121
+ from socketdev import socketdev
1122
+ socket = socketdev(token="REPLACE_ME")
1123
+
1124
+ # Get metadata for specific alert types
1125
+ alert_list = ["supply_chain_risk", "license_risk"]
1126
+ print(socket.alerttypes.get(alert_list, language="en-US"))
1127
+
1128
+ # Get all alert types metadata
1129
+ print(socket.alerttypes.get())
1130
+
1131
+ **PARAMETERS:**
1132
+
1133
+ - **alert_types (list, optional)** – List of alert type strings to get metadata for
1134
+ - **language (str)** – Language for alert metadata (default: en-US)
1135
+ - **kwargs** – Additional query parameters
1136
+
1137
+ triage.list_alert_triage(org_slug, query_params=None)
1138
+ """""""""""""""""""""""""""""""""""""""""""""""""""""
1139
+ Get list of triaged alerts for an organization.
1140
+
1141
+ **Usage:**
1142
+
1143
+ .. code-block:: python
1144
+
1145
+ from socketdev import socketdev
1146
+ socket = socketdev(token="REPLACE_ME")
1147
+ query_params = {"status": "triaged", "limit": 50}
1148
+ print(socket.triage.list_alert_triage("org_slug", query_params))
1149
+
1150
+ **PARAMETERS:**
1151
+
1152
+ - **org_slug (str)** – The organization name
1153
+ - **query_params (dict, optional)** – Optional query parameters for filtering
1154
+
1155
+ openapi.get()
1156
+ """""""""""""
1157
+ Retrieve the OpenAPI specification for the Socket API.
1158
+
1159
+ **Usage:**
1160
+
1161
+ .. code-block:: python
1162
+
1163
+ from socketdev import socketdev
1164
+ socket = socketdev(token="REPLACE_ME")
1165
+ print(socket.openapi.get())
1166
+
1167
+ **PARAMETERS:**
1168
+
1169
+ None required.
@@ -1,12 +1,14 @@
1
- socketdev/__init__.py,sha256=PEXQ6i0D__cuVweAcORx1zkPRPp9hS_forsTKmTRHWY,2362
1
+ socketdev/__init__.py,sha256=wcxhpItn-ZkKQYJSsmkHKDaGdtCbWPMvb_delK2xbdU,2811
2
2
  socketdev/exceptions.py,sha256=SNU1EgswGwnxI_Zmm325ruP6CFg5C4MsS1qxXWwBJqs,1120
3
3
  socketdev/log.py,sha256=AgEcsPN3y9U-fze8pTFvLigVvNob2vmNC-TkOOQkkeQ,90
4
- socketdev/version.py,sha256=EPmgXOdWKks5S__ZMH7Nu6xpAeVrZpfxaFy4pykuyeI,22
5
- socketdev/apitokens/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- socketdev/auditlog/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ socketdev/version.py,sha256=gNoy6uoSQO4ZzowTZAJz3hphzq1F_Y-3X9YrQdb7ppc,22
5
+ socketdev/alerttypes/__init__.py,sha256=W-m2D9VxbepSAUELJPmWmX40zksGZbQcSzwQ1kjlB1k,1169
6
+ socketdev/analytics/__init__.py,sha256=kQGeO67TraqvfmYjfpYCvcNRtxW2a6x5EefEl6Jnca8,2223
7
+ socketdev/apitokens/__init__.py,sha256=itREchAUQcY8oC_EaxwwkpP3iCFnPMe7NTtdcOsD4HM,2952
8
+ socketdev/auditlog/__init__.py,sha256=JhYkzpRzugRQUbbB9Z_E8R1tK3M-323fLwatIKlp79s,786
7
9
  socketdev/core/api.py,sha256=xymEv2szAwZXDsTI4nRC_zcqoSVAenQ-TceNuHfkwbE,5773
8
10
  socketdev/core/classes.py,sha256=fyDlolgnkpHFb1dMHa2SA0czCS1I6Tr3SuYb1a67-dY,3756
9
- socketdev/core/dedupe.py,sha256=O6qxJoxfNrgD6SREmrusqsUPfTGbQEzi-3udgENHT8k,4092
11
+ socketdev/core/dedupe.py,sha256=_8wTWNghgkiRmpxADDcUbluPpQy0eSRMn9YvTbXkq_A,5102
10
12
  socketdev/core/issues.py,sha256=jIfi6h1Y-d38OgxSFhlgC74TLvY6IfUcWhQfLq8FFPo,68147
11
13
  socketdev/dependencies/__init__.py,sha256=RahCr5DyOndUcz2okg8Ak-WLbqxCeKp7MaUqiT_Z1Wo,1612
12
14
  socketdev/diffscans/__init__.py,sha256=ilv1mBDBMGjRwsfRhaUpaSy8OekiSfNK4s8PKf-0l2Y,5011
@@ -25,11 +27,11 @@ socketdev/repos/__init__.py,sha256=dM8GrjIiHUBsPJeBRKLm9QJDRCgx5F-N2iN7GDCHTIg,5
25
27
  socketdev/repositories/__init__.py,sha256=0SP-rCSfxWa9DrPkDKXac8SHqmVHFqgqUHDs-5eg8IE,790
26
28
  socketdev/sbom/__init__.py,sha256=LpesXKZhgF5OeNWls10YgxsCNamFW-F8UOy4yI11hrY,2341
27
29
  socketdev/settings/__init__.py,sha256=CCRAnFWOvm7Hi4LY0gbFqsOFHNDlWK3FHei0Edcv_-8,6268
28
- socketdev/threatfeed/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
+ socketdev/threatfeed/__init__.py,sha256=2SsJYKByXBkb2C1fGopwxejkr7mky0kggFKIunyV7Nk,1119
29
31
  socketdev/tools/__init__.py,sha256=ROvpEULLXTKby9DMsVFPlAlysjwfop1NhRqSrFUWprY,1969
30
32
  socketdev/triage/__init__.py,sha256=-h599vThVetfRSOAs1e4IUoMjcXS8xOsUfub41XPiX4,1559
31
33
  socketdev/utils/__init__.py,sha256=JD0TTGxhomG55-H7k_qTmDEQPrlabm2HEWMcoXagQ_A,10587
32
- socketdev-3.0.0.dist-info/METADATA,sha256=diUNGlq7tgn3_g6_wnN_WHw-r6qxPORs_kA8h-lcD74,24416
33
- socketdev-3.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
34
- socketdev-3.0.0.dist-info/licenses/LICENSE,sha256=mC0II_UuE-_gCG9XqOLNyrV3crnROzMpdAetGnMrhpw,1068
35
- socketdev-3.0.0.dist-info/RECORD,,
34
+ socketdev-3.0.4.dist-info/METADATA,sha256=lpsL7hXyUdGTTI7ElOSgmFMIOQwBF9HT3oT0oyx7cNY,34359
35
+ socketdev-3.0.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
36
+ socketdev-3.0.4.dist-info/licenses/LICENSE,sha256=mC0II_UuE-_gCG9XqOLNyrV3crnROzMpdAetGnMrhpw,1068
37
+ socketdev-3.0.4.dist-info/RECORD,,