123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- #!/bin/bash
-
- shellfu import preupg
- shellfu import preupg_fupath
- shellfu import xcase
- shellfu import jat_dump
-
-
- PREUPG__RULE=xccdf_preupg_rule_api_logging_check
-
-
- assert_msg_like() {
-
-
-
- preupg__get_messages > msgs
- jat__cmd grep "$1" msgs
- }
-
- xcase__enum() {
-
-
-
- xcase__permute lang py sh \
- | xcase__per fn log_debug log_info log_warning log_error \
- | xcase__per debug true false
- }
-
-
- xcase__setup() {
-
-
-
- local maybe_debug=""
- $debug && maybe_debug="--debug"
- echo "message$(head -c 1000 /dev/urandom | md5sum | head -c 7)" >t_message
- {
- echo "[MODULE]"
- echo "GROUP = api"
- echo "NAME = logging"
- echo "LANG = $lang"
- case $lang in
- sh)
- echo "CODE = $fn $(<t_message)"
- echo "CODE = exit_informational"
- ;;
- py)
- echo "CODE = $fn('$(<t_message)')"
- echo "CODE = exit_informational()"
- ;;
- esac
- } > module.mdef
- preupg_fupath RHEL6_7 module.mdef
- PREUPG__UPATH="RHEL6_7/all-xccdf.xml" \
- preupg__run1 $maybe_debug --skip-common
- }
-
- xcase__test() {
-
-
-
-
-
-
- local o_severity=""
- local o_msgnum=0
- local o_result=informational
- local o_not=""
-
- case $fn:$debug in
- log_debug:true) o_msgnum=1; o_severity=DEBUG ;;
- log_debug:false) o_msgnum=0; o_severity=DEBUG ;;
- log_info:*) o_msgnum=1; o_severity=INFO ;;
- log_warning:*) o_msgnum=1; o_severity=WARNING ;;
- log_error:*) o_msgnum=1; o_severity=ERROR ;;
- esac
- test "$o_msgnum" -eq 0 && o_not=-N
-
-
-
- preupg__assert \
- result "$o_result" \
- msgn "$o_msgnum" \
- $o_not msg.$o_severity "$(<t_message)"
- }
-
- xcase__diag() {
-
-
-
- jat_dump__file module.mdef
- preupg__get_messages | jat_dump__pipe MESSAGES
- }
-
- xcase__cleanup() {
-
-
-
- preupg__rmresult
- }
-
-
- PREUPG__UPATH=@pass \
- preupg__Run1
- xcase__run -v
- preupg__Cleanup
|