forked from cycodehq/cycode-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
60 lines (43 loc) · 1.3 KB
/
Copy pathmodels.py
File metadata and controls
60 lines (43 loc) · 1.3 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
from enum import Enum
from typing import List, NamedTuple, Dict, Type
from cycode.cyclient.models import Detection
class Document:
def __init__(self, path: str, content: str, is_git_diff_format: bool = False, unique_id: str = None):
self.path = path
self.content = content
self.is_git_diff_format = is_git_diff_format
self.unique_id = unique_id
def __repr__(self) -> str:
return (
"path:{0}, "
"content:{1}".format(self.path, self.content)
)
class DocumentDetections:
def __init__(self, document: Document, detections: List[Detection]):
self.document = document
self.detections = detections
def __repr__(self) -> str:
return (
"document:{0}, "
"detections:{1}".format(self.document, self.detections)
)
class Severity(Enum):
INFO = -1
LOW = 0
MEDIUM = 1
MODERATE = 1
HIGH = 2
CRITICAL = 3
@staticmethod
def try_get_value(name: str) -> any:
if name not in Severity.__members__:
return None
return Severity[name].value
class CliError(NamedTuple):
code: str
message: str
soft_fail: bool = False
CliErrors = Dict[Type[Exception], CliError]
class CliResult(NamedTuple):
success: bool
message: str