Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • perun/perun-proxyidp/perun-proxy-utils
1 result
Show changes
Commits on Source (3)
# [1.9.0](https://gitlab.ics.muni.cz/perun-proxy-aai/python/perun-proxy-utils/compare/v1.8.5...v1.9.0) (2023-08-21)
### Features
* check_php_syntax ([0d9e162](https://gitlab.ics.muni.cz/perun-proxy-aai/python/perun-proxy-utils/commit/0d9e162433d54e72dfd6b19dd11c4da6715bc077))
## [1.8.5](https://gitlab.ics.muni.cz/perun-proxy-aai/python/perun-proxy-utils/compare/v1.8.4...v1.8.5) (2023-08-10)
......
#!/bin/bash
#The root directory to check
dir="/etc/simplesamlphp"
cd $dir
paths=$(find . -type f -name "*.php")
globalResult=""
for path in $paths
do
if [[ -f $path ]] ; then
result=$(php -l $path 2>&1)
if [[ ! $result =~ ^No.syntax.errors.*$ ]] ; then
globalResult+="$result | "
fi
fi
done
if [[ -z $globalResult ]] ; then
echo "0 php_syntax_check - OK"
else
echo "2 php_syntax_check - $globalResult"
fi
#!/usr/bin/env python3
import os
import subprocess
import sys
import argparse
# nagios return codes
UNKNOWN = -1
OK = 0
WARNING = 1
CRITICAL = 2
def get_args():
parser = argparse.ArgumentParser(
description=(
"Checks whether PHP files have valid syntax, primarily used for checking"
" automatically generated files"
)
)
parser.add_argument(
"-d",
"--directory",
required=True,
help="path which will be scanned for PHP files, including subdirectories",
)
return parser.parse_args()
def main():
dir = get_args().directory
os.chdir(dir)
paths = []
for (
dirpath,
dirname,
filenames,
) in os.walk("."):
for f in filenames:
if f.endswith(".php"):
paths.append(
os.path.join(
dirpath,
f,
)
)
global_result = ""
for path in paths:
if os.path.isfile(path):
result = subprocess.getoutput(f"php -l {path}")
if not result.startswith("No syntax errors"):
global_result += f"{result} | "
if not global_result:
print(f"{OK} check_php_syntax - OK")
sys.exit(OK)
else:
print(f"{CRITICAL} check_php_syntax - {global_result}")
sys.exit(CRITICAL)
if __name__ == "__main__":
main()
[metadata]
version = 1.8.5
version = 1.9.0
license_files = LICENSE
long_description = file: README.md
long_description_content_type = text/markdown
......
......@@ -37,6 +37,7 @@ setuptools.setup(
"check_rpc_status=perun.proxy.utils.nagios.check_rpc_status:main",
"check_saml=perun.proxy.utils.nagios.check_saml:main",
"check_user_logins=perun.proxy.utils.nagios.check_user_logins:main",
"check_php_syntax=perun.proxy.utils.nagios.check_php_syntax:main",
"check_webserver_availability="
"perun.proxy.utils.nagios.webserver_availability:main",
"metadata_expiration=perun.proxy.utils.metadata_expiration:main",
......