-
Notifications
You must be signed in to change notification settings - Fork 0
/
operacoes_db.py
137 lines (119 loc) · 2.46 KB
/
operacoes_db.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
137
import model
from engine import get_db
import datetime
db = next(get_db())
def insert_ameaca(
tid: int,
stamp_added: datetime.date,
threat: str,
category: str,
risk: str,
description: str,
wikisummary: str,
wikireference: str,
retired: str,
stamp_updated: datetime.date,
stamp_seen: datetime.date,
stamp_retired: datetime.date,
):
ameaca = model.Ameacas(
tid=tid,
hora_adicionado=stamp_added,
nome=threat,
categoria=category,
risco=risk,
descricao=description,
wiki_sumario=wikisummary,
wiki_link=wikireference,
descontinuado=retired,
hora_atualizado=stamp_updated,
hora_visto=stamp_seen,
hora_descontinuado=stamp_retired,
)
if not db.query(model.Ameacas).filter(model.Ameacas.tid == tid).all():
db.add(ameaca)
db.commit()
db.refresh(ameaca)
def insert_atributos(
atid: int,
tid: int,
tipo: str,
descricao: str,
):
atributo = model.Atributos(
atid=atid,
tid=tid,
categoria=tipo,
descricao=descricao,
)
db.add(atributo)
db.commit()
db.refresh(atributo)
def insert_novidades(
nid: int,
tid: int,
title: str,
channel: str,
icon: str,
link: str,
stamp: datetime.date,
):
novidade = model.Novidades(
nid=nid,
tid=tid,
titulo=title,
canal=channel,
icone=icon,
link=link,
hora_adicionado=stamp,
)
db.add(novidade)
db.commit()
db.refresh(novidade)
def insert_outrosnomes(
onid: int,
tid: int,
nome: str,
):
outrosnomes = model.Outrosnomes(
onid=onid,
tid=tid,
nomes=nome,
)
db.add(outrosnomes)
db.commit()
db.refresh(outrosnomes)
def insert_relacionados(
relid: int,
tid: int,
nome: str,
category: str,
risk: str,
stamp_linked: datetime.date,
):
relacionado = model.Relacionados(
relid=relid,
tid=tid,
nome=nome,
categoria=category,
risco=risk,
hora_link=stamp_linked,
)
db.add(relacionado)
db.commit()
db.refresh(relacionado)
def insert_TaticasETecnicas(
ttpsid: int,
tid: int,
tipo: str,
descricao: str,
):
ttps = model.TaticasETecnicas(
ttpsid=ttpsid,
tid=tid,
categoria=tipo,
descricao=descricao,
)
db.add(ttps)
db.commit()
db.refresh(ttps)