Skip to content

Orlando/add new endpoints #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ venv
.DS_Store
*.zip
*.pyc
test.py
3 changes: 3 additions & 0 deletions socketdev/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import logging
import requests
import base64

from socketdev.dependencies import Dependencies
from socketdev.npm import NPM
from socketdev.openapi import OpenAPI
from socketdev.org import Orgs
from socketdev.quota import Quota
from socketdev.report import Report
from socketdev.sbom import Sbom
from socketdev.repositories import Repositories
from socketdev.settings import Settings
from socketdev.socket_classes import Dependency, Org, Response
Expand Down Expand Up @@ -86,5 +88,6 @@ def __init__(self, token: str):
self.org = Orgs()
self.quota = Quota()
self.report = Report()
self.sbom = Sbom()
self.repositories = Repositories()
self.settings = Settings()
23 changes: 23 additions & 0 deletions socketdev/sbom/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import socketdev
import json

class Sbom:
@staticmethod
def get_sbom_data(report_id: str) -> list:
path = f"sbom/view/{report_id}"
response = socketdev.do_request(path=path)
if response.status_code == 200:
sbom = []
sbom_dict = {}
data = response.text
data.strip('"')
data.strip()
for line in data.split("\n"):
if line != '"' and line != "" and line is not None:
item = json.loads(line)
sbom.append(item)
for key, val in enumerate(sbom):
sbom_dict[val['id']] = val
else:
sbom_dict = {}
return sbom_dict