-
Notifications
You must be signed in to change notification settings - Fork 10
/
dbx_mysql.pl
148 lines (140 loc) · 6.5 KB
/
dbx_mysql.pl
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
# -----------------------------------------------------------------------------
#
# Open Report Parser - Open Source report parser
# Copyright (C) 2023 John Bradley (userjack6880)
# Copyright (C) 2016 TechSneeze.com
# Copyright (C) 2012 John Bieling
#
# dbx_mysql.pl
# mysql db module
#
# Available at: https://github.com/userjack6880/Open-Report-Parser
#
# -----------------------------------------------------------------------------
#
# This file is part of Open Report Parser.
#
# Open Report Parser is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <https://www.gnu.org/licenses/>.
#
# -----------------------------------------------------------------------------
%dbx = (
epoch_to_timestamp_fn => 'FROM_UNIXTIME',
to_hex_string => sub {
my ($bin) = @_;
return "X'" . unpack("H*", $bin) . "'";
},
column_info_type_col => 'mysql_type_name',
tables => {
"report" => {
column_definitions => [
"serial" , "int" , "unsigned NOT NULL AUTO_INCREMENT",
"mindate" , "timestamp" , "NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP",
"maxdate" , "timestamp" , "NULL",
"domain" , "varchar(255)" , "NOT NULL",
"org" , "varchar(255)" , "NOT NULL",
"reportid" , "varchar(255)" , "NOT NULL",
"email" , "varchar(255)" , "NULL",
"extra_contact_info" , "varchar(255)" , "NULL",
"policy_adkim" , "varchar(20)" , "NULL",
"policy_aspf" , "varchar(20)" , "NULL",
"policy_p" , "varchar(20)" , "NULL",
"policy_sp" , "varchar(20)" , "NULL",
"policy_pct" , "tinyint" , "unsigned",
"raw_xml" , "mediumtext" , "",
],
additional_definitions => "PRIMARY KEY (serial), UNIQUE KEY domain (domain, reportid)",
table_options => "ROW_FORMAT=COMPRESSED",
indexes => [],
},
"rptrecord" => {
column_definitions => [
"id" , "int" , "unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY",
"serial" , "int" , "unsigned NOT NULL",
"ip" , "int" , "unsigned",
"ip6" , "binary(16)" , "",
"rcount" , "int" , "unsigned NOT NULL",
"disposition" , "enum('" . join("','", ALLOWED_DISPOSITION) . "')" , "",
"reason" , "varchar(255)" , "",
"dkimdomain" , "varchar(255)" , "",
"dkimresult" , "enum('" . join("','", ALLOWED_DKIMRESULT) . "')" , "",
"spfdomain" , "varchar(255)" , "",
"spfresult" , "enum('" . join("','", ALLOWED_SPFRESULT) . "')" , "",
"spf_align" , "enum('" . join("','", ALLOWED_SPF_ALIGN) . "')" , "NOT NULL",
"dkim_align" , "enum('" . join("','", ALLOWED_DKIM_ALIGN) . "')" , "NOT NULL",
"identifier_hfrom" , "varchar(255)" , ""
],
additional_definitions => "KEY serial (serial, ip), KEY serial6 (serial, ip6)",
table_options => "",
indexes => [],
},
"tls" => {
column_definitions => [
"serial" , "int" , "unsigned NOT NULL AUTO_INCREMENT",
"mindate" , "timestamp" , "NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP",
"maxdate" , "timestamp" , "NULL",
"domain" , "varchar(255)" , "NOT NULL",
"org" , "varchar(255)" , "NOT NULL",
"reportid" , "varchar(255)" , "NOT NULL",
"email" , "varchar(255)" , "NULL",
"policy_mode" , "varchar(20)" , "NULL",
"summary_success" , "int" , "NULL",
"summary_failure" , "int" , "NULL",
"raw_json" , "mediumtext" , "",
],
additional_definitions => "PRIMARY KEY (serial), UNIQUE KEY domain(domain, reportid)",
table_options => "ROW_FORMAT=COMPRESSED",
indexes => [],
},
"tlsrecord" => {
column_definitions => [
"id" , "int" , "unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY",
"serial" , "int" , "unsigned NOT NULL",
"send_ip" , "int" , "unsigned",
"send_ip6" , "binary(16)" , "",
"recv_ip" , "int" , "unsigned",
"recv_ip6" , "binary(16)" , "",
"recv_mx" , "varchar(255)" , "",
"type" , "varchar(255)" , "",
"count" , "int" , "unsigned NOT NULL",
],
additional_definitions => "KEY serial (serial, send_ip), KEY serial6 (serial, send_ip6)",
table_options => "",
indexes => [],
},
"oauth" => {
column_definitions => [
"id" , "int" , "unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY",
"access_token" , "varchar(4096)" , "",
"refresh_token" , "varchar(1024)" , "",
"expire" , "timestamp" , "NOT NULL",
"valid" , "int" , "unsigned NOT NULL",
],
additional_definitions => "",
table_options => "",
indexes => [],
}
},
add_column => sub {
my ($table, $col_name, $col_type, $col_opts, $after_col) = @_;
my $insert_pos = "FIRST";
if ($after_col) {
$insert_pos = "AFTER $after_col";
}
return "ALTER TABLE $table ADD $col_name $col_type $col_opts $insert_pos;"
},
modify_column => sub {
my ($table, $col_name, $col_type, $col_opts) = @_;
return "ALTER TABLE $table MODIFY COLUMN $col_name $col_type $col_opts;"
},
);
1;