-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathclasses.py
More file actions
148 lines (124 loc) · 3.67 KB
/
classes.py
File metadata and controls
148 lines (124 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import json
class Score:
supplyChain: float
quality: float
maintenance: float
license: float
overall: float
vulnerability: float
def __init__(self, **kwargs):
if kwargs:
for key, value in kwargs.items():
setattr(self, key, value)
for score_name in self.__dict__:
score = getattr(self, score_name)
if score <= 1:
score = score * 100
setattr(self, score_name, score)
def __str__(self):
return json.dumps(self.__dict__)
class Package:
type: str
name: str
version: str
release: str
id: str
direct: bool
manifestFiles: list
author: list
size: int
score: dict
scores: Score
alerts: list
error_alerts: list
alert_counts: dict
topLevelAncestors: list
url: str
transitives: int
license: str
license_text: str
purl: str
def __init__(self, **kwargs):
if kwargs:
for key, value in kwargs.items():
setattr(self, key, value)
if not hasattr(self, "direct"):
self.direct = False
else:
if str(self.direct).lower() == "true":
self.direct = True
self.url = f"https://socket.dev/{self.type}/package/{self.name}/overview/{self.version}"
if hasattr(self, 'score'):
self.scores = Score(**self.score)
if not hasattr(self, "alerts"):
self.alerts = []
if not hasattr(self, "topLevelAncestors"):
self.topLevelAncestors = []
if not hasattr(self, "manifestFiles"):
self.manifestFiles = []
if not hasattr(self, "transitives"):
self.transitives = 0
if not hasattr(self, "author"):
self.author = []
if not hasattr(self, "size"):
self.size = 0
self.alert_counts = {
"critical": 0,
"high": 0,
"middle": 0,
"low": 0
}
self.error_alerts = []
if not hasattr(self, "license"):
self.license = "NoLicenseFound"
if not hasattr(self, "license_text"):
self.license_text = ""
self.url = f"https://socket.dev/{self.type}/package/{self.name}/overview/{self.version}"
self.purl = f"{self.type}/{self.name}@{self.version}"
class Dependency:
branch: str
id: int
name: str
type: str
version: str
namespace: str
repository: str
def __init__(self, **kwargs):
if kwargs:
for key, value in kwargs.items():
setattr(self, key, value)
def __str__(self):
return json.dumps(self.__dict__)
class Org:
id: int
image: str
name: str
plan: str
def __init__(self, **kwargs):
if kwargs:
for key, value in kwargs.items():
setattr(self, key, value)
def __str__(self):
return json.dumps(self.__dict__)
class Response:
text: str
error: bool
status_code: int
def __init__(self, text: str, error: bool, status_code: int):
self.text = text
self.error = error
self.status_code = status_code
def __str__(self):
return json.dumps(self.__dict__)
def json(self):
return self.__dict__
class DependGetData:
url: str
headers: dict
payload: str
def __init__(self, **kwargs):
if kwargs:
for key, value in kwargs.items():
setattr(self, key, value)
def __str__(self):
return json.dumps(self.__dict__)