diff options
author | sanghyeok.oh <sanghyeok.oh@samsung.com> | 2019-10-21 17:15:10 +0900 |
---|---|---|
committer | sanghyeok oh <sanghyeok.oh@samsung.com> | 2019-11-01 08:17:14 +0000 |
commit | 8a94244c5b2321dccc3c70607fcb11a3ca15a20d (patch) | |
tree | f378623c8ea38333621d2d029c57ebc35123bc51 | |
parent | c302e6270859212d58d0a1e61b7249e9a17f1efa (diff) | |
download | dbus-tools-8a94244c5b2321dccc3c70607fcb11a3ca15a20d.tar.gz dbus-tools-8a94244c5b2321dccc3c70607fcb11a3ca15a20d.tar.bz2 dbus-tools-8a94244c5b2321dccc3c70607fcb11a3ca15a20d.zip |
policychecker: skip preprocessor iso_dsdl_include.xsl
* change option argument (--system,--session) to (-s,-u)
* add option (-v, -p) for checker developement
* skip preprocessor
policy checker using single schema file(rules.xsl) and it doesn't need XPath syntax check.
This reduce policy checking time. (3min -> 19sec at tm1)
Schematron's readme.txt states this:
1) First, preprocess your Schematron schema with iso_dsdl_include.xsl.
This is a macro processor to assemble the schema from various parts.
If your schema is not in separate parts, you can skip this stage.
This stage also generates error messages for some common XPath syntax problems.
Change-Id: Id8dbf03d3a4a5107440823b9bcb0ce1830cc4380
Signed-off-by: sanghyeok.oh <sanghyeok.oh@samsung.com>
(cherry picked from commit 2f6d6ba8ca8c7453be598bf45c5dae79ae2cf87b)
-rwxr-xr-x | policychecker/check.in | 74 |
1 files changed, 59 insertions, 15 deletions
diff --git a/policychecker/check.in b/policychecker/check.in index 3e5b6ec..393785a 100755 --- a/policychecker/check.in +++ b/policychecker/check.in @@ -4,14 +4,14 @@ PATH="/usr/bin:/bin:/usr/sbin:/sbin" set -e xslt_processor="xsltproc --nonet --novalid --maxdepth 25000" -#xslt_processor="xsltproc --nonet --novalid --maxdepth 25000 --profile" tmpdir=`mktemp -d` checker_dir="@datadir@/dbus-tools/policychecker" schematron_dir="@datadir@/dbus-tools/policychecker/xslt" conf_path=("/usr/share/dbus-1" "/etc/dbus-1") sub_conf_path=("system.d" "session.d") bus_type=-1 -config_file=$1 +config_file=-1 +checker_include_all=0 schema_file="$checker_dir/rules.xsl" system_privileges_file="$tmpdir/privileges_system" @@ -25,18 +25,58 @@ cleanup() { trap cleanup 0 -if [ "$#" -ne 1 ]; then - echo "Usage: $0 config-file" - exit 1 -fi +usage() { + echo "Usage: $0 [-v] [-p] [-s|-u|filename]" + echo "" + echo -e "\tfilename dbus policy configuration file" + echo -e "\t-s system bus" + echo -e "\t-u session bus" + echo -e "\t-v include every iso xsls" + echo -e "\t-p enable profile mode" +} -if [ $config_file == "--system" ]; then - bus_type=0 -elif [ $config_file == "--session" ]; then - bus_type=1 -elif [ ! -f $config_file ]; then - echo "config file does not exist" - exit 1 +# use "checker opt + config-file" +# getopts doesn't support - "checker config-file + opt" +while getopts :suvp opt +do case "$opt" in + s) if [ $bus_type -eq -1 ]; then + bus_type=0 + echo "check system bus" + fi + ;; + u) if [ $bus_type -eq -1 ]; then + bus_type=1 + echo "check session bus" + fi + ;; + v) checker_include_all=1 + echo "use iso_dsdl_include.xsl" + ;; + p) echo "enable profile mode" + xslt_processor="$xslt_processor --profile" + ;; + ?) echo "Unknown arg:$OPTARG" + usage + exit 1 + ;; + esac +done + +shift $(( OPTIND - 1 )) + +if [ $bus_type -eq -1 ]; then + if [ "$#" -ne 1 ]; then + echo "unknown opts: $@" + usage + exit 1 + fi + + config_file=$1 + if [ ! -f $config_file ]; then + echo "config file '$config_file' does not exist" + usage + exit 1 + fi fi if [ ! -d $cynara_db ]; then @@ -87,8 +127,12 @@ function check_policy_file(){ cat $schema_file | sed -e "s/USERS_TEST/$users_test/g" -e "s/GROUPS_TEST/$groups_test/g" > $tmpname.0 - $xslt_processor $schematron_dir/iso_dsdl_include.xsl $tmpname.0 > $tmpname.1 - $xslt_processor $schematron_dir/iso_abstract_expand.xsl $tmpname.1 > $tmpname.2 + if [ $checker_include_all -eq 1 ]; then + $xslt_processor $schematron_dir/iso_dsdl_include.xsl $tmpname.0 > $tmpname.1 + $xslt_processor $schematron_dir/iso_abstract_expand.xsl $tmpname.1 > $tmpname.2 + else + $xslt_processor $schematron_dir/iso_abstract_expand.xsl $tmpname.0 > $tmpname.2 + fi $xslt_processor $schematron_dir/iso_svrl_for_xslt1.xsl $tmpname.2 > $tmpname.3 $xslt_processor $tmpname.3 $config_file > $tmpname.4 $xslt_processor $checker_dir/report.xsl $tmpname.4 |