forked from Automattic/vip-go-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
defines.php
363 lines (303 loc) · 9.27 KB
/
defines.php
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<?php
/**
* Various defines for vip-go-ci
*
* @package Automattic/vip-go-ci
*/
declare(strict_types=1);
/*
* Version number and default name to use.
*/
define( 'VIPGOCI_VERSION', '1.3.13' );
define( 'VIPGOCI_DEFAULT_NAME_TO_USE', 'vip-go-ci' );
/*
* Define minimum version requirements.
*/
define( 'VIPGOCI_GIT_VERSION_MINIMUM', '2.10' );
define( 'VIPGOCI_PHP_VERSION_MINIMUM', '8.0.0' );
/*
* Client-ID for HTTP requests.
*/
define( 'VIPGOCI_CLIENT_ID', 'automattic-vip-go-ci' );
/*
* GitHub defines.
*/
define( 'VIPGOCI_GITHUB_WEB_BASE_URL', 'https://github.com' );
/* Define if not defined. Unit-tests can define this for testing. */
if ( ! defined( 'VIPGOCI_GITHUB_BASE_URL' ) ) {
define( 'VIPGOCI_GITHUB_BASE_URL', 'https://api.github.com' );
}
// GitHub API version header. If updated, update latest-release.php too.
define( 'VIPGOCI_GITHUB_API_VERSION', '2022-11-28' );
/*
* Defines for various sizes, such as KB.
*/
define( 'VIPGOCI_KB_IN_BYTES', 1024 );
/*
* Constants for HTTP API functions.
*/
define( 'VIPGOCI_HTTP_API_LONG_TIMEOUT', 20 );
define( 'VIPGOCI_HTTP_API_SHORT_TIMEOUT', 5 );
define( 'VIPGOCI_HTTP_API_CONTENT_TYPE_APPLICATION_JSON', 'application/json' );
define( 'VIPGOCI_HTTP_API_CONTENT_TYPE_X_WWW_FORM_URLENCODED', 'application/x-www-form-urlencoded' );
/*
* Define exit-codes
*/
define( 'VIPGOCI_EXIT_NORMAL', 0 );
define( 'VIPGOCI_EXIT_INTERNAL_ERROR', 220 );
define( 'VIPGOCI_EXIT_COMMIT_NOT_PART_OF_PR', 230 );
define( 'VIPGOCI_EXIT_HTTP_API_ERROR', 247 );
define( 'VIPGOCI_EXIT_COMMIT_NOT_LATEST', 248 );
define( 'VIPGOCI_EXIT_EXEC_TIME', 249 );
define( 'VIPGOCI_EXIT_CODE_ISSUES', 250 );
define( 'VIPGOCI_EXIT_SYSTEM_PROBLEM', 251 );
define( 'VIPGOCI_EXIT_GITHUB_PROBLEM', 252 );
define( 'VIPGOCI_EXIT_USAGE_ERROR', 253 );
/*
* Define statistics-types.
*
* Note: These are related to the command-line
* arguments passed to the program (e.g., --phpcs)
* -- altering these is not recommended.
*/
define( 'VIPGOCI_STATS_PHPCS', 'phpcs' );
define( 'VIPGOCI_STATS_LINT', 'lint' );
define( 'VIPGOCI_STATS_WPSCAN_API', 'wpscan-api' );
/*
* Define error/warning/info constants.
*/
define( 'VIPGOCI_ISSUE_TYPE_INFO', 'info' );
define( 'VIPGOCI_ISSUE_TYPE_WARNING', 'warning' );
define( 'VIPGOCI_ISSUE_TYPE_ERROR', 'error' );
/*
* Defines for auto-approvals.
*/
define( 'VIPGOCI_APPROVAL_AUTOAPPROVE', 'auto-approval' );
define( 'VIPGOCI_APPROVAL_AUTOAPPROVE_NON_FUNCTIONAL_CHANGES_FILE_EXTENSIONS_DEFAULT', array( 'php' ) );
/*
* Defines for vipgoci_runtime_measure() function.
*/
define( 'VIPGOCI_RUNTIME_START', 'start' );
define( 'VIPGOCI_RUNTIME_STOP', 'stop' );
define( 'VIPGOCI_RUNTIME_DUMP', 'dump' );
/*
* Defines for vipgoci_counter_report() function.
*/
define( 'VIPGOCI_COUNTERS_DUMP', 'dump' );
define( 'VIPGOCI_COUNTERS_DO', 'do' );
/*
* Define for vipgoci_run_time_length_determine() function.
*/
define( 'VIPGOCI_RUN_LENGTH_MEDIUM', 120 );
define( 'VIPGOCI_RUN_LENGTH_LONG', 240 );
/*
* Define for vipgoci_cache() function.
*/
define( 'VIPGOCI_CACHE_CLEAR', '--VIPGOCI-CACHE-CLEAR-0x321--' );
/*
* Define for vipgoci_http_api_wait() function.
*/
// This can be overridden in programs using vip-go-ci as library.
if ( ! defined( 'VIPGOCI_HTTP_API_WAIT_TIME_SECONDS' ) ) {
define( 'VIPGOCI_HTTP_API_WAIT_TIME_SECONDS', 3 );
}
define( 'VIPGOCI_HTTP_API_WAIT_APIS_ARRAY', array( VIPGOCI_GITHUB_BASE_URL ) );
/*
* Defines for files.
*/
define( 'VIPGOCI_OPTIONS_FILE_NAME', '.vipgoci_options' );
/*
* Define for vipgoci_git_diffs_fetch() function.
*/
define(
'VIPGOCI_GIT_DIFF_CALC_CHANGES',
array(
'+' => 'additions',
'-' => 'deletions',
)
);
define( 'VIPGOCI_GIT_DIFF_DATA_SOURCE_GIT_REPO', 'local-git-repo' );
define( 'VIPGOCI_GIT_DIFF_DATA_SOURCE_GITHUB_API', 'github-api' );
/*
* Define file number of lines limit.
*/
define( 'VIPGOCI_SKIPPED_FILES', 'skipped-files' );
define( 'VIPGOCI_VALIDATION_MAXIMUM_LINES_LIMIT', 15000 );
define( 'VIPGOCI_VALIDATION_MAXIMUM_LINES', 'max-lines' );
define(
'VIPGOCI_VALIDATION',
array(
VIPGOCI_VALIDATION_MAXIMUM_LINES
=> 'Maximum number of lines exceeded (%d)',
)
);
define( 'VIPGOCI_VALIDATION_MAXIMUM_DETAIL_MSG', 'Note that the above file(s) were not analyzed due to their length.' );
/*
* Indicates which sections of log
* messages should not be logged to IRC.
*/
define(
'VIPGOCI_IRC_IGNORE_STRING_START',
'<!-- vip-go-ci-irc-ignore-start -->'
);
define(
'VIPGOCI_IRC_IGNORE_STRING_END',
'<!-- vip-go-ci-irc-ignore-end -->'
);
/*
* Strings for generic messages.
*/
define( 'VIPGOCI_CODE_ANALYSIS_ISSUES', 'Code analysis identified issues' );
define( 'VIPGOCI_GITHUB_ERROR_STR', 'GitHub API communication error. Please contact a human.' );
/*
* Various messages.
*/
define(
'VIPGOCI_REVIEW_COMMENTS_TOTAL_MAX',
'Total number of active review comments per ' .
'pull request has been reached and some ' .
'comments might not appear as a result. ' .
'Please resolve some issues to see more'
);
define(
'VIPGOCI_OUT_OF_MEMORY_ERROR',
'Unable to analyze the pull request due to resource constraints. The pull request may be too large to process. Please try submitting a smaller pull request'
);
define(
'VIPGOCI_NO_ISSUES_FOUND_MSG_AND_NO_REVIEWS',
'No issues were found to report when scanning latest commit'
);
define(
'VIPGOCI_NO_ISSUES_FOUND_MSG_AND_EXISTING_REVIEWS',
'Scanning latest commit did not yield any new issues. Please have a look at older feedback still existing'
);
/*
* Defines related to PHP linting.
*/
define( 'VIPGOCI_LINT_FILE_EXTENSIONS_DEFAULT', array( 'php' ) );
define(
'VIPGOCI_LINT_REPORT_START',
'%1$s has identified PHP syntax errors during automated linting. ' .
'We recommend reviewing the issues noted and that they are resolved.' .
"\n\r\n\r" . 'PHP linting performed at commit %2$s ([view code](%3$s)).'
);
define(
'VIPGOCI_LINT_FAILED_MSG_START',
'Unable to PHP lint one or more files due to error running PHP linter: '
);
define(
'VIPGOCI_LINT_FAILED_MSG_END',
'The error may be temporary. If the error persists, please contact a human'
);
define( 'VIPGOCI_LINT_ERROR_STR', 'PHP Syntax Errors Found' );
/*
* Defines relating to PHPCS scanning.
*/
define( 'VIPGOCI_PHPCS_FILE_EXTENSIONS_DEFAULT', array( 'php', 'js', 'twig' ) );
define(
'VIPGOCI_PHPCS_SCAN_REVIEW_START',
'%1$s has identified potential problems in this pull request ' .
'during automated scanning. We recommend reviewing the issues ' .
'noted and that they are resolved.'
);
define(
'VIPGOCI_PHPCS_SCAN_FAILED_MSG_START',
'Unable to PHPCS or SVG scan one or more files due to error running PHPCS/SVG scanner: '
);
define(
'VIPGOCI_PHPCS_SCAN_FAILED_MSG_END',
'The error may be temporary. If the error persists, please contact a human'
);
define(
'VIPGOCI_PHPCS_INVALID_SNIFFS',
'Invalid PHPCS sniff(s) specified in ' .
'options or options file. Those have ' .
'been ignored temporarily. Please ' .
'update the options so that scanning ' .
'can continue as expected. '
);
define(
'VIPGOCI_PHPCS_INVALID_SNIFFS_CONT',
'<br />' .
PHP_EOL . PHP_EOL .
'* Option name: `%s`' . PHP_EOL .
'* Invalid sniff(s): `%s`' . PHP_EOL
);
define(
'VIPGOCI_PHPCS_DUPLICATE_SNIFFS',
'Sniff(s) has been found in duplicate in ' .
'options or options file. Those have ' .
'been ignored temporarily. Please ' .
'update the options so that scanning ' .
'can continue as expected. ' .
'<br /> '
);
define(
'VIPGOCI_PHPCS_DUPLICATE_SNIFFS_CONT',
'<br />' .
PHP_EOL . PHP_EOL .
'* Options: `%s` and `%s`' . PHP_EOL .
'* Sniff(s) in duplicate: `%s`' . PHP_EOL .
'<br />'
);
/*
* Defines for SVG scanning.
*/
define( 'VIPGOCI_SVG_FILE_EXTENSIONS_DEFAULT', array( 'svg' ) );
/*
* Defines for addons generally.
*/
define( 'VIPGOCI_ADDON_PLUGIN', 'vipgoci-addon-plugin' );
define( 'VIPGOCI_ADDON_THEME', 'vipgoci-addon-theme' );
/*
* WordPress.org defines.
*/
define( 'VIPGOCI_WORDPRESS_ORG_API_BASE_URL', 'https://api.wordpress.org' );
/*
* Defines for WPScan API support.
*/
define( 'VIPGOCI_WPSCAN_BASE_URL', 'https://wpscan.com' );
define( 'VIPGOCI_WPSCAN_API_BASE_URL', VIPGOCI_WPSCAN_BASE_URL . '/api/v3' );
define( 'VIPGOCI_WPSCAN_PLUGIN_FILE_EXTENSIONS_DEFAULT', array( 'php' ) );
define( 'VIPGOCI_WPSCAN_THEME_FILE_EXTENSIONS_DEFAULT', array( 'css' ) );
define( 'VIPGOCI_WPSCAN_UPDATEURI_WP_ORG_URLS', array( 'w.org', 'wordpress.org' ) );
define( 'VIPGOCI_WPSCAN_VULNERABLE', 'vulnerable' );
define( 'VIPGOCI_WPSCAN_OBSOLETE', 'obsolete' );
define( 'VIPGOCI_WPSCAN_API_ERROR', 'Vulnerability and Update Scan' );
define(
'VIPGOCI_WPSCAN_REPORT_START',
'%1$s has identified one or more insecure or obsolete %2$s(s) being ' .
'submitted or altered in this pull request. Updating the %2$s(s) before merging ' .
'into the target branch is strongly recommended.'
);
define( 'VIPGOCI_WPSCAN_SKIP_SCAN_PR_LABEL', 'skip-wpscan' );
define(
'VIPGOCI_WPSCAN_CVSS_RANKING',
array(
array(
'upper_value' => '10.0',
'lower_value' => '9.0',
'ranking' => 'CRITICAL',
),
array(
'upper_value' => '8.9',
'lower_value' => '7.0',
'ranking' => 'HIGH',
),
array(
'upper_value' => '6.9',
'lower_value' => '4.0',
'ranking' => 'MEDIUM',
),
array(
'upper_value' => '3.9',
'lower_value' => '0.1',
'ranking' => 'LOW',
),
array(
'upper_value' => '0.0',
'lower_value' => '0.0',
'ranking' => 'NONE',
),
)
);