-
Notifications
You must be signed in to change notification settings - Fork 5
/
db_populate.py
executable file
·63 lines (53 loc) · 1.54 KB
/
db_populate.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
#!bin/python
from app import db
from app.models import Control, Level, Itype, Tlp, Source, Likelihood, Status, Destination
controls = ["Inbound", "Outbound"]
levels = ["None", "Low", "Medium", "High"]
tlps = ["White", "Green", "Amber", "Red"]
types = [["ipv4","^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$"],
["domain", "^(?:[-A-Za-z0-9]+\.)+[A-Za-z]{2,12}$"],
["md5", "^[a-fA-F0-9]{32}$"],
["sha256", "^[A-Fa-f0-9]{64}$"],
["url", "^(http[s]?://(?:[-A-Za-z0-9]+\.)+[A-Za-z]{2,12}(/[^\s]+)?|(?:[-A-Za-z0-9]+\.)+[A-Za-z]{2,12}/[^\s]*)$"]]
sources = ["Feed", "Email List", "Blog"]
statuses = ["New", "Open", "Resolved"]
destinations = [["pan", "Palo Alto", "fmtPan"], ["json", "Generic Json", "fmtJson"]]
for i in controls:
obj = Control()
obj.name = i
db.session.add(obj)
db.session.commit()
for i in levels:
obj = Level()
obj2 = Likelihood()
obj.name = i
obj2.name = i
db.session.add(obj)
db.session.add(obj2)
db.session.commit()
for i in tlps:
obj = Tlp()
obj.name = i
db.session.add(obj)
db.session.commit()
for i in types:
obj = Itype(i[0], i[1])
db.session.add(obj)
db.session.commit()
for i in sources:
obj = Source()
obj.name = i
db.session.add(obj)
db.session.commit()
for i in statuses:
obj = Status()
obj.name = i
db.session.add(obj)
db.session.commit()
for i in destinations:
obj = Destination()
obj.name = i[0]
obj.description = i[1]
obj.formatter = i[2]
db.session.add(obj)
db.session.commit()