-
Notifications
You must be signed in to change notification settings - Fork 6
/
hub.py
136 lines (117 loc) · 3.08 KB
/
hub.py
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
from dataclasses import dataclass, asdict
from typing import Any, Optional
from hub.models.location import LocationStack
from hub.models.source import SourceSast
@dataclass(kw_only=True, eq=False, order=False, init=True)
class ScanResult:
rules: list[Any]
locations: list[Any]
findings: list[Any]
@dataclass(kw_only=True, eq=False, order=False, init=True)
class ScanDetail:
id: str
description: str
@dataclass(kw_only=True, eq=False, order=False, init=True)
class Scan:
scanDetails: ScanDetail
source: list[SourceSast]
tool: dict[str, str]
results: list[ScanResult]
@dataclass(kw_only=True, eq=False, order=False, init=True)
class Report:
schema: str = "https://docs.appsec-hub.ru/"
version: str = "1.0.1"
scans: list[Scan]
def to_dict(self) -> dict:
result = asdict(self)
result["$schema"] = self.schema
del result["schema"]
return result
@dataclass(kw_only=False, eq=False, order=False)
class FindingHubSast:
type: str
id: str
ruleId: str
locationId: str
line: int
code: str
status: str
description: str
stacks: list[LocationStack] = None
def __init__(
self,
idx: str,
ruleId: str,
locationId: str,
line: int,
code: str,
description: str,
status: str,
type: str,
stacks: Optional[list[LocationStack]]
):
self.type = type
self.id = idx
self.ruleId = ruleId
self.locationId = locationId
self.line = line
self.code = code
self.description = description
self.status = status
self.stacks = stacks
if not self.stacks and self.line is not None:
self.stacks = [
LocationStack(locationId=self.locationId, line=self.line, code=self.code)
]
super().__init__()
@dataclass(kw_only=False, eq=False, order=False)
class FindingHubDast:
type: str
id: str
ruleId: str
locationId: str
url: str
status: str
description: str
def __init__(
self,
idx: str,
ruleId: str,
locationId: str,
url: str,
description: str,
status: str,
type: str
):
self.type = type
self.id = idx
self.ruleId = ruleId
self.locationId = locationId
self.url = url
self.description = description
self.status = status
super().__init__()
@dataclass(kw_only=False, eq=False, order=False)
class FindingHubScaS:
type: str
id: str
ruleId: str
locationId: str
status: str
description: str
def __init__(
self,
idx: str,
ruleId: str,
locationId: str,
description: str,
status: str,
type: str
):
self.type = type
self.id = idx
self.ruleId = ruleId
self.locationId = locationId
self.description = description
self.status = status
super().__init__()