PluginProbe
Patchstack – WordPress & Plugins Security / 2.2.6
Patchstack – WordPress & Plugins Security v2.2.6
2.3.7 trunk 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.17 2.1.18 2.1.19 2.1.2 2.1.20 2.1.21 2.1.22 2.1.23 2.1.24 2.1.25 2.1.3 2.1.4 2.1.5 2.1.6 All 49 releases
← All changes | includes/migrations/base.php +79 -80 2.1.152.2.6 View file →
@@ -5,35 +5,33 @@
5 5 exit;
6 6 }
7 7
8 8 // Create firewall log table.
9 -$sql = 'CREATE TABLE ' . $prefix . "patchstack_firewall_log (
9 +$sql = 'CREATE TABLE IF NOT EXISTS `' . $prefix . "patchstack_firewall_log` (
10 10 id mediumint(9) NOT NULL AUTO_INCREMENT,
11 11 ip tinytext NOT NULL,
12 12 flag tinytext NOT NULL,
13 13 fid mediumint(4),
14 14 request_uri tinytext,
15 - referer tinytext,
16 15 user_agent tinytext,
17 - protocol tinytext,
18 16 method tinytext,
19 - query_string tinytext,
20 - query_vars tinytext,
21 17 post_data LONGTEXT,
22 18 log_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
23 19 apply_ban INT NOT NULL DEFAULT '1',
24 20 block_type VARCHAR(255) NOT NULL DEFAULT '',
25 21 block_params VARCHAR(255) NOT NULL DEFAULT '',
22 + PRIMARY KEY (id),
26 23 UNIQUE KEY id (id)
27 24 ) $charset_collate;";
28 25 dbDelta( $sql );
29 26
30 27 // Create logic table that will store the firewall rules descriptions.
31 -$sql = 'CREATE TABLE ' . $prefix . "patchstack_logic (
28 +$sql = 'CREATE TABLE IF NOT EXISTS `' . $prefix . "patchstack_logic` (
32 29 id mediumint(9) NOT NULL,
33 30 cname varchar(20),
34 31 description tinytext,
35 32 log_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
33 + PRIMARY KEY (id),
36 34 UNIQUE KEY id (id)
37 35 ) $charset_collate;";
38 36 dbDelta( $sql );
39 37
@@ -47,9 +45,10 @@
47 45 object_id tinytext NULL,
48 46 object_name text NULL,
49 47 action tinytext NULL,
50 48 date datetime NULL,
51 - PRIMARY KEY (id)
49 + PRIMARY KEY (id),
50 + UNIQUE KEY id (id)
52 51 ) $charset_collate;";
53 52 dbDelta( $sql );
54 53
55 54 // Insert base firewall rules.
@@ -54,175 +53,175 @@
54 53
55 54 // Insert base firewall rules.
56 55 $result = $wpdb->get_var( 'SELECT COUNT(*) FROM ' . $prefix . 'patchstack_logic' );
57 56 if ( ! $result ) {
58 - $logics = array(
59 - array(
57 + $logics = [
58 + [
60 59 'id' => 400,
61 60 'cname' => 'Bad Request',
62 61 'description' => 'The server cannot or will not process the request due to an apparent client error',
63 - ),
64 - array(
62 + ],
63 + [
65 64 'id' => 401,
66 65 'cname' => 'Unauthorized',
67 66 'description' => 'Authentication is required and has failed or has not yet been provided.',
68 - ),
69 - array(
67 + ],
68 + [
70 69 'id' => 402,
71 70 'cname' => 'Invalid URL',
72 71 'description' => 'Payment Required. Reserved for future use.',
73 - ),
74 - array(
72 + ],
73 + [
75 74 'id' => 403,
76 75 'cname' => 'Forbidden',
77 76 'description' => 'The request was valid, but the server is refusing action.',
78 - ),
79 - array(
77 + ],
78 + [
80 79 'id' => 404,
81 80 'cname' => 'Not Found',
82 81 'description' => 'The requested resource could not be found but may be available in the future.',
83 - ),
84 - array(
82 + ],
83 + [
85 84 'id' => 405,
86 85 'cname' => 'Not Allowed',
87 86 'description' => 'A request method is not supported for the requested resource.',
88 - ),
89 - array(
87 + ],
88 + [
90 89 'id' => 410,
91 90 'cname' => 'Gone',
92 91 'description' => 'Indicates that the resource requested is no longer available and will not be available again.',
93 - ),
94 - array(
92 + ],
93 + [
95 94 'id' => 411,
96 95 'cname' => 'String Injection',
97 96 'description' => 'A request strings attack.',
98 - ),
99 - array(
97 + ],
98 + [
100 99 'id' => 501,
101 100 'cname' => 'Pingback',
102 101 'description' => 'Pingback protection.',
103 - ),
104 - array(
102 + ],
103 + [
105 104 'id' => 502,
106 105 'cname' => 'Unauthorized',
107 106 'description' => 'Blocked debug log access',
108 - ),
109 - array(
107 + ],
108 + [
110 109 'id' => 101,
111 110 'cname' => 'Restricted Files',
112 111 'description' => 'Trying to access readme file.',
113 - ),
114 - array(
112 + ],
113 + [
115 114 'id' => 102,
116 115 'cname' => 'Restricted Files',
117 116 'description' => 'Trying to access license file.',
118 - ),
119 - array(
117 + ],
118 + [
120 119 'id' => 103,
121 120 'cname' => 'Restricted Files',
122 121 'description' => 'Trying to access wp-config file.',
123 - ),
124 - array(
122 + ],
123 + [
125 124 'id' => 104,
126 125 'cname' => 'Restricted Files',
127 126 'description' => 'Trying to access robots_txt file.',
128 - ),
129 - array(
127 + ],
128 + [
130 129 'id' => 108,
131 130 'cname' => 'Bad Char',
132 131 'description' => 'Advanced character string filtered.',
133 - ),
134 - array(
132 + ],
133 + [
135 134 'id' => 109,
136 135 'cname' => 'Gone',
137 - 'description' => 'Trying to access readme files htaccess, htpasswd,errordocs or logs.',
138 - ),
139 - array(
136 + 'description' => 'Trying to access readme files htaccess, htpasswd, errordocs or logs.',
137 + ],
138 + [
140 139 'id' => 2,
141 140 'cname' => 'Dir Exploit',
142 141 'description' => 'Blocked restricted wordpres file access.',
143 - ),
144 - array(
142 + ],
143 + [
145 144 'id' => 3,
146 145 'cname' => 'Dir Exploit',
147 146 'description' => 'Blacklist Bots detected.',
148 - ),
149 - array(
147 + ],
148 + [
150 149 'id' => 4,
151 150 'cname' => 'HTTP Ref Attack',
152 151 'description' => 'Abusive HTTP Referrer Blocking.',
153 - ),
154 - array(
152 + ],
153 + [
155 154 'id' => 5,
156 155 'cname' => 'Blacklist',
157 156 'description' => 'Known blacklist attacks.',
158 - ),
159 - array(
157 + ],
158 + [
160 159 'id' => 6,
161 160 'cname' => 'Trace',
162 161 'description' => 'Trace and track method detected.',
163 - ),
164 - array(
162 + ],
163 + [
165 164 'id' => 7,
166 165 'cname' => 'Proxy Commenting',
167 166 'description' => 'Forbid proxy comment posting.',
168 - ),
169 - array(
167 + ],
168 + [
170 169 'id' => 8,
171 170 'cname' => 'SQLI',
172 171 'description' => 'Deny bad query strings.',
173 - ),
174 - array(
172 + ],
173 + [
175 174 'id' => 10,
176 175 'cname' => 'SQLI',
177 176 'description' => 'Deny bad query strings.',
178 - ),
179 - array(
177 + ],
178 + [
180 179 'id' => 11,
181 180 'cname' => 'Request',
182 181 'description' => 'Deny bad query strings.',
183 - ),
184 - array(
182 + ],
183 + [
185 184 'id' => 12,
186 185 'cname' => 'Referrers',
187 186 'description' => 'Deny bad query strings.',
188 - ),
189 - array(
187 + ],
188 + [
190 189 'id' => 13,
191 190 'cname' => 'Request',
192 191 'description' => 'Deny bad query strings.',
193 - ),
194 - array(
192 + ],
193 + [
195 194 'id' => 16,
196 195 'cname' => 'RFI',
197 196 'description' => 'Forbid RFI.',
198 - ),
199 - array(
197 + ],
198 + [
200 199 'id' => 17,
201 200 'cname' => 'Spam',
202 201 'description' => 'Block spambot.',
203 - ),
204 - array(
202 + ],
203 + [
205 204 'id' => 18,
206 205 'cname' => 'Hotlinks',
207 206 'description' => 'Image hotlinking.',
208 - ),
209 - array(
207 + ],
208 + [
210 209 'id' => 19,
211 - 'cname' => 'Wpscan',
212 - 'description' => 'Attack from WPSCAN.',
213 - ),
214 - array(
210 + 'cname' => 'readme',
211 + 'description' => 'Readme.txt Scan.',
212 + ],
213 + [
215 214 'id' => 22,
216 215 'cname' => 'Bots',
217 216 'description' => 'Deny bad bots.',
218 - ),
219 - array(
217 + ],
218 + [
220 219 'id' => 23,
221 220 'cname' => 'XSS',
222 221 'description' => 'Cross site scripting.',
223 - ),
224 - );
222 + ]
223 + ];
225 224
226 225 foreach ( $logics as $logic ) {
227 226 $result = $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM ' . $prefix . 'patchstack_logic WHERE id = %s', $logic['id'] ) );
228 227 if ( ! $result ) {
@@ -227,13 +226,13 @@
227 226 $result = $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM ' . $prefix . 'patchstack_logic WHERE id = %s', $logic['id'] ) );
228 227 if ( ! $result ) {
229 228 $wpdb->insert(
230 229 $prefix . 'patchstack_logic',
231 - array(
230 + [
232 231 'id' => $logic['id'],
233 232 'cname' => $logic['cname'],
234 233 'description' => $logic['description'],
235 - )
234 + ]
236 235 );
237 236 }
238 237 }
239 238 }