Commit c851b147 authored by SBassett's avatar SBassett
Browse files

PHP-Security-Tools

Some bash scripts which install, run and manage reports for various
security-focused tools for the PHP programming language.  See also
README.md.

Bug: T221477
Change-Id: Ib453a49deebd3d66c4cb7af9dbccd26319ebfdef
parent ba4ec884
[gerrit]
host=gerrit.wikimedia.org
port=29418
project=wikimedia/security/tooling.git
track=1
defaultrebase=0
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
# PHP-Security-Tools
Some bash scripts which install, run and manage reports for various security-focused tools for the PHP programming language.
## Prerequisites
```
bash
composer
docker
git
node/npm
php72+
sed
```
## Installing
1. ```git clone "https://gerrit.wikimedia.org/r/wikimedia/security/tooling"```
## Usage
1. Configure ```.env``` to your liking and run something like: ```eval $(cat .env | sed 's/^/export /')``` - sample values provided within ```sample.env```
2. ```chmod +x bin/run && bin/run {args...}``` (args is typically just one argument: the path to the code)
3. Optionally alias ```bin/run``` to something shorter: ```alias pst="/path/to/pst/install/bin/run" or drop a similar script into /usr/local/bin or somewhere similar.
4. The PHP-Security-Tools run script has a few options/arguments:
1. -h | --help | help = displays a help message with different tool options
2. all = Runs all tools and create a report
3. sec-check-ext = Runs phan mediawiki-optimized SecCheckPlugin (ext)
4. sec-check-gen = Runs phan SecCheckPlugin general scan
5. phan-sec = Runs security-focused phan checks
6. phpcs-sec = Runs security-focused phpcs checks
7. php-sec = Runs Symphony's security:check against composer.lock
8. php-snyk = Runs Snyk's CLI (auth required) against composer.lock
9. npm-sec = Run an npm audit if a valid package-lock.json exists
10. npm-out = Run an npm outdated if a valid package-lock.json exists
11. node-retire = Run retirejs
12. node-snyk = Run Snyk's CLI against package-lock.json
13. mw-php-sec = Runs mwSecSniff to find potentially dangerous PHP code
14. mw-i18n-sec = Runs i18n script to find potentially dangerous HTML
15. mw-http-leaks = Runs a very naive check for http leaks within HTML
## TODO
1. Additional tools to investigate, which *may* or *may not* be useful:
1. FunctionFQNReplacer (code quality) - https://github.com/Roave/FunctionFQNReplacer
2. psecio/parse (security) - https://github.com/psecio/parse
3. unused-scanner (code quality) - https://github.com/Insolita/unused-scanner
4. TaintPHP (security) - https://github.com/olivo/TaintPHP
5. Progpilot (security) - https://github.com/designsecurity/progpilot
6. Psalm (security) - https://psalm.dev/
7. php-malware-finder (security) - https://github.com/nbs-system/php-malware-finder
8. phortress (security, old) - https://github.com/lowjoel/phortress
9. phpstan (code quality) - https://github.com/phpstan/phpstan
10. phpcpd (code quality) - https://github.com/sebastianbergmann/phpcpd
11. exakat (security, commercial?) - https://www.exakat.io/price-services/
12. WAP (security, old) - https://github.com/asrulhadi/wap
13. php mess detector (code quality) - http://phpmd.org/
14. php-cs-fixer (code quality) - https://github.com/FriendsOfPHP/PHP-CS-Fixer
15. phpdepend (code quality) - https://github.com/pdepend/pdepend
2. Write integration tests
3. Improve checks for mw_i18n_message_check (ensure i18n file/dir, etc.)
4. Fix issues (so many undeclareds, not very nice) with phan_sec()
5. Consolidate docker run commands a little better?
6. Improve portability/compatibility of various bin/ scripts with different Unix flavors
## Authors
* **Scott Bassett** [sbassett@wikimedia.org]
## License
This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.
#!/usr/bin/env bash
################################################################################
# Author: sbassett@wikimedia.org
# License: Apache 2 <https://opensource.org/licenses/Apache-2.0>
# Description:
# Build relevant Dockerfiles within $DOCKERFILE_DIR
# Env variables (see sample.env):
################################################################################
set -euo pipefail
if [ -f .env ]; then eval $(cat .env | sed 's/^/export /'); fi
cd $PST_INSTALL_DIR/$PST_DOCKERFILE_DIR && docker-compose -p "pst" build
#!/usr/bin/env bash
###############################################################################
# Author: sbassett@wikimedia.org
# License: Apache 2 <https://opensource.org/licenses/Apache-2.0>
# Description:
# Simple http leaks searches based upon:
# - https://github.com/cure53/HTTPLeaks/blob/master/leak.html
# - https://mathiasbynens.be/demo/url-regex
###############################################################################
set -euo pipefail
# validate arguments
if ([ -z ${1+x} ] || ([ ! -d "$1" ] && [ ! -f "$1" ])); then
printf "One argument is required: {valid path}. Exiting.\n"
exit 1
fi
# set variables
readonly path="$1"
readonly search="$(command -v grep 2> /dev/null)"
readonly searchflags='-nrE'
# naive way to search for various urls lingering about in code
# yes, this can create lots of false positives for now,
# but it proably shouldn't
readonly http_leaks="((https?|ftp|file):)?//(\w+)"
# search files in $path
find $path -type d \( -path '*/.git*' -o \
-path '*/vendor*' -o \
-path '*/node_modules*' \) \
-prune -o -print0 | while read -d $'\0' file
do
results=""
out=""
out=$(echo "$file" |xargs php -w |tr ";" "\n" \
|${search} ${searchflags} "${http_leaks}" || :)
if [ -n "${out}" ]; then results="${results}\n${file}\n${out}\n"; fi
printf "%b" "$results"
done
#!/usr/bin/env bash
###############################################################################
# Author: sbassett@wikimedia.org, bawolff+wn@gmail.com
# License: Apache 2 <https://opensource.org/licenses/Apache-2.0>
# Description:
# Based upon: T205563
# Assumption: Any messages containing literal js will end in .js. Any other
# raw html message is in normal html context (not attribute)
# Dependencies:
# awk
# cat
# grep
# jq (https://github.com/stedolan/jq)
# sed
###############################################################################
set -euo pipefail
# validate arguments
if ([ -z ${1+x} ] || ([ ! -d "$1" ] && [ ! -f "$1" ])); then
printf "One argument is required: {valid path}. Exiting.\n"
exit 1
fi
# search mw message files (xxx.json) in current directory
find "$@" -type d \( -path '*/.git*' -o \
-path '*/vendor*' -o \
-path '*/node_modules' \) \
-prune -o -name '*.json' -print0 | while read -d $'\0' file
do
results=""
# check potentially bad html
out=""
out=$(cat "$file" | sed -E -e 's/<\/? ?(abbr|span|br|strong|em|pre|nowiki|charinsert|b|del|code|kbd|p|tt|div|i|big|sup|sub|samp|var|small|h1|h2|h3|h4|u)( ((class|title|lang|xml:lang|dir)=\\?["'\''][^=<>"'\'']*\\?["'\'']))* ?\/?>//g' -e 's/<!--//g' -e 's/<https?:\/\/[a-zA-Z0-9./-]*>//g' | grep -n '<' | awk '{print $0,"\n"}' || :)
if [ -n "${out}" ]; then
outstr="HTML detected within message file \"$file\". Please review!"
outborder=$(printf "%0.s-" {1..80})
outstr="${outborder}\n${outstr}\n${outborder}\n"
results="${results}${outstr}${out}\n\n"
fi
# check potentially bad json
out=""
out=$(cat "$file" | grep '^+' | sed -E -e 's/\\\\//g' -e 's/\\[nt"]//g' | grep '\\' || :)
if [ -n "${out}" ]; then
outstr="JSON escape sequence detected within file \"$file\". Please review!"
outborder=$(printf "%0.s-" {1..80})
outstr="${outborder}\n${outstr}\n${outborder}\n"
results="${results}${outstr}${out}\n\n"
fi
printf "%b" "$results"
done
#!/usr/bin/env bash
###############################################################################
# Author: sbassett@wikimedia.org
# License: Apache 2 <https://opensource.org/licenses/Apache-2.0>
# Description:
# Simple PHP/MW security searches based upon:
# - https://www.mediawiki.org/wiki/Security_checklist_for_developers
# - https://www.mediawiki.org/wiki/Security_for_developers/Tutorial
# - https://w.wiki/8vF
# - https://stackoverflow.com/questions/3115559/exploitable-php-functions
###############################################################################
set -euo pipefail
# validate arguments
if ([ -z ${1+x} ] || ([ ! -d "$1" ] && [ ! -f "$1" ]) || [ -z ${2+x} ] || ! [[ "$2" =~ ^[0-9]+$ ]]); then
printf "Two arguments required: {valid path} and {function group [int]}. Exiting.\n"
exit 1
fi
# set variables
readonly path="$1"
readonly groups="$2" # {1, 2, 3, 4, 12, 134, 1234}
# use certain groups of functions
use_group_1=false
use_group_2=false
use_group_3=false
use_group_4=false
if [[ "$groups" == *"1"* ]]; then use_group_1=true; fi
if [[ "$groups" == *"2"* ]]; then use_group_2=true; fi
if [[ "$groups" == *"3"* ]]; then use_group_3=true; fi
if [[ "$groups" == *"4"* ]]; then use_group_4=true; fi
readonly search="$(command -v grep 2> /dev/null)"
readonly searchflags='-nrE'
readonly searchexcludes="--exclude-dir=.git \
--exclude-dir=vendor \
--exclude-dir=node_modules"
# group 1: core php functions and patterns
readonly dangerous_group_1="^(\s+)?(addslashes)(\s*)?(\()?(\(.*)?$\
|^(\s+)?(alter_ini)(\s*)?(\()?(\(.*)?$\
|^(\s+)?apache_(.+)?$\
|^(\s+)?assert(\s*)?(\()?(\(.*)?$\
|^(\s+)?base64_decode(\s*)?(\()?(\(.*)?$\
|^(\s+)?create_function(\s*)?(\()?(\(.*)?$\
|^(\s+)?define_syslog_variables(\s*)?(\()?(\(.*)?$\
|^(\s+)?diskfreespace(\s*)?(\()?(\(.*)?$\
|^(\s+)?disk_free_space(\s*)?(\()?(\(.*)?$\
|^(\s+)?disk_total_space(\s*)?(\()?(\(.*)?$\
|^(\s+)?echo(\s*)?(\()?(\(.*)?$\
|^(\s+)?escapeshellarg(\s*)?(\()?(\(.*)?$\
|^(\s+)?escapeshellcmd(\s*)?(\()?(\(.*)?$\
|^(\s+)?eval(\s*)?(\()?(\(.*)?$\
|^(\s+)?exec(\s*)?(\()?(\(.*)?$\
|^(\s+)?expect_popen(\s*)?(\()?(\(.*)?$\
|^(\s+)?fsockopen(\s*)?(\()?(\(.*)?$\
|^(\s+)?ftp_(.+)?$\
|^(\s+)?getcwd(\s*)?(\()?(\(.*)?$\
|^(\s+)?getenv(\s*)?(\()?(\(.*)?$\
|^(\s+)?getlastmo(\s*)?(\()?(\(.*)?$\
|^(\s+)?getmygid(\s*)?(\()?(\(.*)?$\
|^(\s+)?getmyinode(\s*)?(\()?(\(.*)?$\
|^(\s+)?getmypid(\s*)?(\()?(\(.*)?$\
|^(\s+)?getmyuid(\s*)?(\()?(\(.*)?$\
|^(\s+)?get_cfg_var(\s*)?(\()?(\(.*)?$\
|^(\s+)?get_current_user(\s*)?(\()?(\(.*)?$\
|^(\s+)?header(\s*)?(\()?(\(.*)?$\
|^(\s+)?highlight_file(\s*)?(\()?(\(.*)?$\
|^(\s+)?include(\s*)?(\()?(\(.*)?$\
|^(\s+)?include_once(\s*)?(\()?(\(.*)?$\
|^(\s+)?include(\s*)\
|^(\s+)?include_once(\s*)\
|^(\s+)?ini_alter(\s*)?(\()?(\(.*)?$\
|^(\s+)?ini_get_all(\s*)?(\()?(\(.*)?$\
|^(\s+)?ini_restore(\s*)?(\()?(\(.*)?$\
|^(\s+)?ini_set(\s*)?(\()?(\(.*)?$\
|^(\s+)?mail(\s*)?(\()?(\(.*)?$\
|^(\s+)?max_execution_time(\s*)?(\()?(\(.*)?$\
|^(\s+)?openlog(\s*)?(\()?(\(.*)?$\
|^(\s+)?passthru(\s*)?(\()?(\(.*)?$\
|^(\s+)?parse_ini_file(\s*)?(\()?(\(.*)?$\
|^(\s+)?parse_str(\s*)?(\()?(\(.*)?$\
|^(\s+)?pcntl_exec(\s*)?(\()?(\(.*)?$\
|^(\s+)?phpinfo(\s*)?(\()?(\(.*)?$\
|^(\s+)?php_uname(\s*)?(\()?(\(.*)?$\
|^(\s+)?pfsockopen(\s*)?(\()?(\(.*)?$\
|^(\s+)?popen(\s*)?(\()?(\(.*)?$\
|^(\s+)?posix_(.+)?$\
|^(\s+)?preg_(.+)?$\
|^(\s+)?print(\s*)?(\()?(\(.*)?$\
|^(\s+)?print_r(\s*)?(\()?(\(.*)?$\
|^(\s+)?proc_close(\s*)?(\()?(\(.*)?$\
|^(\s+)?proc_get_status(\s*)?(\()?(\(.*)?$\
|^(\s+)?proc_nice(\s*)?(\()?(\(.*)?$\
|^(\s+)?proc_open(\s*)?(\()?(\(.*)?$\
|^(\s+)?proc_terminate(\s*)?(\()?(\(.*)?$\
|^(\s+)?putenv(\s*)?(\()?(\(.*)?$\
|^(\s+)?ReflectionFunction(\s*)?(\()?(\(.*)?$\
|^(\s+)?require(\s*)?(\()?(\(.*)?$\
|^(\s+)?require_once(\s*)?(\()?(\(.*)?$\
|^(\s+)?require(\s*)\
|^(\s+)?require_once(\s*)\
|^(\s+)?runkit_method_add(\s*)?(\()?(\(.*)?$\
|^(\s+)?serialize(\s*)?(\()?(\(.*)?$\
|^(\s+)?set_include_path(\s*)?(\()?(\(.*)?$\
|^(\s+)?set_time_limit(\s*)?(\()?(\(.*)?$\
|^(\s+)?socket_(.+)?$\
|^(\s+)?shell_exec(\s*)?(\()?(\(.*)?$\
|^(\s+)?syslog(\s*)?(\()?(\(.*)?$\
|^(\s+)?system(\s*)?(\()?(\(.*)?$\
|^(\s+)?unserialize(\s*)?(\()?(\(.*)?$\
|^(\s+)?var_dump(\s*)?(\()?(\(.*)?$\
|^(\s+)?virtual(\s*)?(\()?(\(.*)?$\
|^(\s+)?xmlrpc_(.+)?$\
|\`\
|\\\$_COOKIE\
|\\\$_GET\
|\\\$_POST\
|\\\$_REQUEST\
|\\\$_SERVER\
|\\\$GLOBALS"
# group 2: mediawiki-specific functions
readonly dangerous_group_2="^(\s+)?buildLike(\s*)?(\()?(\(.*)?$\
|^(\s+)?delete(\s*)?(\()?(\(.*)?$\
|^(\s+)?deleteJoin(\s*)?(\()?(\(.*)?$\
|^(\s+)?Html::rawElement(\s*)?(\()?(\(.*)?$\
|^(\s+)?insert(\s*)?(\()?(\(.*)?$\
|^(\s+)?insertSelect(\s*)?(\()?(\(.*)?$\
|^(\s+)?Linker::links(\s*)?(\()?(\(.*)?$\
|>plain(\s*)?(\()?(\(.*)?$\
|^(\s+)?query(\s*)?(\()?(\(.*)?$\
|>rawParams(\s*)?(\()?(\(.*)?$\
|^(\s+)?Sanitizer::stripAllTags(\s*)?(\()?(\(.*)?$\
|^(\s+)?select(\s*)?(\()?(\(.*)?$\
|^(\s+)?selectField(\s*)?(\()?(\(.*)?$\
|^(\s+)?selectRow(\s*)?(\()?(\(.*)?$\
|^(\s+)?Shell::command(\s*)?(\()?(\(.*)?$\
|>text(\s*)?(\()?(\(.*)?$\
|^(\s+)?update(\s*)?(\()?(\(.*)?$\
|^(\s+)?wfShellExec(\s*)?(\()?(\(.*)?$\
|^(\s+)?Xml::openElement(\s*)?(\()?(\(.*)?$\
|^(\s+)?Xml::tags(\s*)?(\()?(\(.*)?$"
# group 3: functions with callbacks
readonly dangerous_group_3="^(\s+)?call_user_func(\s*)?(\()?(\(.*)?$\
|^(\s+)?call_user_func_array(\s*)?(\()?(\(.*)?$\
|^(\s+)?ob_start(\s*)?(\()?(\(.*)?$\
|^(\s+)?array_diff_uassoc(\s*)?(\()?(\(.*)?$\
|^(\s+)?array_diff_ukey(\s*)?(\()?(\(.*)?$\
|^(\s+)?array_filter(\s*)?(\()?(\(.*)?$\
|^(\s+)?array_intersect_uassoc(\s*)?(\()?(\(.*)?$\
|^(\s+)?array_intersect_ukey(\s*)?(\()?(\(.*)?$\
|^(\s+)?array_map(\s*)?(\()?(\(.*)?$\
|^(\s+)?array_reduce(\s*)?(\()?(\(.*)?$\
|^(\s+)?array_udiff_assoc(\s*)?(\()?(\(.*)?$\
|^(\s+)?array_udiff_uassoc(\s*)?(\()?(\(.*)?$\
|^(\s+)?array_udiff(\s*)?(\()?(\(.*)?$\
|^(\s+)?array_uintersect_assoc(\s*)?(\()?(\(.*)?$\
|^(\s+)?array_uintersect_uassoc(\s*)?(\()?(\(.*)?$\
|^(\s+)?array_uintersect(\s*)?(\()?(\(.*)?$\
|^(\s+)?array_walk_recursive(\s*)?(\()?(\(.*)?$\
|^(\s+)?array_walk(\s*)?(\()?(\(.*)?$\
|^(\s+)?assert_options(\s*)?(\()?(\(.*)?$\
|^(\s+)?iterator_apply(\s*)?(\()?(\(.*)?$\
|^(\s+)?register_shutdown_function(\s*)?(\()?(\(.*)?$\
|^(\s+)?register_tick_function(\s*)?(\()?(\(.*)?$\
|^(\s+)?set_error_handler(\s*)?(\()?(\(.*)?$\
|^(\s+)?set_exception_handler(\s*)?(\()?(\(.*)?$\
|^(\s+)?session_set_save_handler(\s*)?(\()?(\(.*)?$\
|^(\s+)?spl_autoload_register(\s*)?(\()?(\(.*)?$\
|^(\s+)?sqlite_create_aggregate(\s*)?(\()?(\(.*)?$\
|^(\s+)?sqlite_create_function(\s*)?(\()?(\(.*)?$\
|^(\s+)?uasort(\s*)?(\()?(\(.*)?$\
|^(\s+)?uksort(\s*)?(\()?(\(.*)?$\
|^(\s+)?usort(\s*)?(\()?(\(.*)?$"
# group 4: filesystem functions
readonly dangerous_group_4="^(\s+)?bzopen(\s*)?(\()?(\(.*)?$\
|^(\s+)?chgrp(\s*)?(\()?(\(.*)?$\
|^(\s+)?chmod(\s*)?(\()?(\(.*)?$\
|^(\s+)?chown(\s*)?(\()?(\(.*)?$\
|^(\s+)?copy(\s*)?(\()?(\(.*)?$\
|^(\s+)?exif_read_data(\s*)?(\()?(\(.*)?$\
|^(\s+)?exif_thumbnail(\s*)?(\()?(\(.*)?$\
|^(\s+)?exif_imagetype(\s*)?(\()?(\(.*)?$\
|^(\s+)?file_exists(\s*)?(\()?(\(.*)?$\
|^(\s+)?file_get_contents(\s*)?(\()?(\(.*)?$\
|^(\s+)?file_put_contents(\s*)?(\()?(\(.*)?$\
|^(\s+)?file(\s*)?(\()?(\(.*)?$\
|^(\s+)?fileatime(\s*)?(\()?(\(.*)?$\
|^(\s+)?filectime(\s*)?(\()?(\(.*)?$\
|^(\s+)?filegroup(\s*)?(\()?(\(.*)?$\
|^(\s+)?fileinode(\s*)?(\()?(\(.*)?$\
|^(\s+)?filemtime(\s*)?(\()?(\(.*)?$\
|^(\s+)?fileowner(\s*)?(\()?(\(.*)?$\
|^(\s+)?fileperms(\s*)?(\()?(\(.*)?$\
|^(\s+)?filesize(\s*)?(\()?(\(.*)?$\
|^(\s+)?filetype(\s*)?(\()?(\(.*)?$\
|^(\s+)?fopen(\s*)?(\()?(\(.*)?$\
|^(\s+)?get_meta_tags(\s*)?(\()?(\(.*)?$\
|^(\s+)?getimagesize(\s*)?(\()?(\(.*)?$\
|^(\s+)?glob(\s*)?(\()?(\(.*)?$\
|^(\s+)?gzfile(\s*)?(\()?(\(.*)?$\
|^(\s+)?gzopen(\s*)?(\()?(\(.*)?$\
|^(\s+)?hash_file(\s*)?(\()?(\(.*)?$\
|^(\s+)?hash_hmac_file(\s*)?(\()?(\(.*)?$\
|^(\s+)?hash_update_file(\s*)?(\()?(\(.*)?$\
|^(\s+)?imagecreatefromgif(\s*)?(\()?(\(.*)?$\
|^(\s+)?imagecreatefromjpeg(\s*)?(\()?(\(.*)?$\
|^(\s+)?imagecreatefrompng(\s*)?(\()?(\(.*)?$\
|^(\s+)?imagecreatefromwbmp(\s*)?(\()?(\(.*)?$\
|^(\s+)?imagecreatefromxbm(\s*)?(\()?(\(.*)?$\
|^(\s+)?imagecreatefromxpm(\s*)?(\()?(\(.*)?$\
|^(\s+)?imagepng(\s*)?(\()?(\(.*)?$\
|^(\s+)?imagewbmp(\s*)?(\()?(\(.*)?$\
|^(\s+)?image2wbmp(\s*)?(\()?(\(.*)?$\
|^(\s+)?imagejpeg(\s*)?(\()?(\(.*)?$\
|^(\s+)?imagexbm(\s*)?(\()?(\(.*)?$\
|^(\s+)?imagegif(\s*)?(\()?(\(.*)?$\
|^(\s+)?imagegd(\s*)?(\()?(\(.*)?$\
|^(\s+)?imagegd2(\s*)?(\()?(\(.*)?$\
|^(\s+)?iptcembed(\s*)?(\()?(\(.*)?$\
|^(\s+)?is_dir(\s*)?(\()?(\(.*)?$\
|^(\s+)?is_executable(\s*)?(\()?(\(.*)?$\
|^(\s+)?is_file(\s*)?(\()?(\(.*)?$\
|^(\s+)?is_link(\s*)?(\()?(\(.*)?$\
|^(\s+)?is_readable(\s*)?(\()?(\(.*)?$\
|^(\s+)?is_uploaded_file(\s*)?(\()?(\(.*)?$\
|^(\s+)?is_writable(\s*)?(\()?(\(.*)?$\
|^(\s+)?is_writeable(\s*)?(\()?(\(.*)?$\
|^(\s+)?lchown(\s*)?(\()?(\(.*)?$\
|^(\s+)?link(\s*)?(\()?(\(.*)?$\
|^(\s+)?linkinfo(\s*)?(\()?(\(.*)?$\