File tree Expand file tree Collapse file tree 4 files changed +82
-2
lines changed Expand file tree Collapse file tree 4 files changed +82
-2
lines changed Original file line number Diff line number Diff line change @@ -215,3 +215,45 @@ Retrieve the Socket Organization Settings
215
215
from socketdev import SocketDev
216
216
socket = SocketDev("REPLACE_ME")
217
217
print(socket.settings.get())
218
+
219
+ sbom.view(report_id)
220
+ """"""""""""""""""""""
221
+ Retrieve the information for a SBOM Report
222
+
223
+ **Usage: **
224
+
225
+ .. code-block ::
226
+
227
+ from socketdev import SocketDev
228
+ socket = SocketDev("REPLACE_ME")
229
+ print(socket.sbom.view("report_id"))
230
+
231
+ **PARAMETERS: **
232
+
233
+ - **report_id (str) ** - The report ID of the report to view
234
+
235
+ purl.post(license, components)
236
+ """"""""""""""""""""""
237
+ Retrieve the package information for a purl post
238
+
239
+ **Usage: **
240
+
241
+ .. code-block ::
242
+
243
+ from socketdev import SocketDev
244
+ socket = SocketDev("REPLACE_ME")
245
+ license = "true"
246
+ components = [
247
+ {
248
+ "purl": "pkg:pypi/[email protected] "
249
+ },
250
+ {
251
+ "purl": "pkg:pypi/socketsecurity"
252
+ }
253
+ ]
254
+ print(socket.purl.post(license, components))
255
+
256
+ **PARAMETERS: **
257
+
258
+ - **license (str) ** - The license parameter if enabled will show alerts and license information. If disabled will only show the basic package metadata and scores. Default is true
259
+ - **components (array{dict}) ** - The components list of packages urls
Original file line number Diff line number Diff line change 9
9
from socketdev .quota import Quota
10
10
from socketdev .report import Report
11
11
from socketdev .sbom import Sbom
12
+ from socketdev .purl import Purl
12
13
from socketdev .repositories import Repositories
13
14
from socketdev .settings import Settings
14
15
from socketdev .socket_classes import Dependency , Org , Response
@@ -89,5 +90,6 @@ def __init__(self, token: str):
89
90
self .quota = Quota ()
90
91
self .report = Report ()
91
92
self .sbom = Sbom ()
93
+ self .purl = Purl ()
92
94
self .repositories = Repositories ()
93
95
self .settings = Settings ()
Original file line number Diff line number Diff line change
1
+ import socketdev
2
+ from urllib .parse import urlencode
3
+ import json
4
+
5
+ class Purl :
6
+ @staticmethod
7
+ def post (license : str = "true" , components : list = []) -> dict :
8
+ path = "purl?" + "license=" + license
9
+ components = {"components" :components }
10
+ components = json .dumps (components )
11
+
12
+ response = socketdev .do_request (
13
+ path = path ,
14
+ payload = components ,
15
+ method = "POST"
16
+ )
17
+ if response .status_code == 200 :
18
+ purl = []
19
+ purl_dict = {}
20
+ result = response .text
21
+ result .strip ('"' )
22
+ result .strip ()
23
+ for line in result .split ("\n " ):
24
+ if line != '"' and line != "" and line is not None :
25
+ item = json .loads (line )
26
+ purl .append (item )
27
+ for val in purl :
28
+ purl_dict [val ['id' ]] = val
29
+ else :
30
+ purl_dict = {}
31
+ print (f"Error posting { components } to the Purl API" )
32
+ print (response .text )
33
+
34
+ return purl_dict
35
+
36
+
Original file line number Diff line number Diff line change 3
3
4
4
class Sbom :
5
5
@staticmethod
6
- def get_sbom_data (report_id : str ) -> list :
6
+ def view (report_id : str ) -> list :
7
7
path = f"sbom/view/{ report_id } "
8
8
response = socketdev .do_request (path = path )
9
9
if response .status_code == 200 :
@@ -16,7 +16,7 @@ def get_sbom_data(report_id: str) -> list:
16
16
if line != '"' and line != "" and line is not None :
17
17
item = json .loads (line )
18
18
sbom .append (item )
19
- for key , val in enumerate ( sbom ) :
19
+ for val in sbom :
20
20
sbom_dict [val ['id' ]] = val
21
21
else :
22
22
sbom_dict = {}
You can’t perform that action at this time.
0 commit comments