Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.119.108.233
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /etc/bash_completion.d/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //etc/bash_completion.d/oscap
# check for non-parametric options
# returns number of params
function _oscap_noarg {
    case "$1" in
      --definitions|--syschar|--results|--skip-schematron|-f|--force|-q|--quiet|--oval-results) return 0 ;;
      --version|--help|-V|-h) return 256 ;; # stop cmdline processing
      *) return 1 ;;
    esac
}

function _oscap {

	# commands for individual modules
    local -A cmds=()
    cmds[oscap]="info oval xccdf ds cpe cvss cve"
    cmds[oscap:oval]="collect eval analyse validate generate"
    cmds[oscap:oval:generate]="report"
    cmds[oscap:cvss]="score describe"
    cmds[oscap:xccdf]="eval remediate resolve validate export-oval-variables generate"
    cmds[oscap:xccdf:generate]="report guide fix custom"
    cmds[oscap:ds]="sds-add sds-compose sds-split sds-validate rds-create rds-split rds-validate"
    cmds[oscap:cpe]="check match validate"
    cmds[oscap:cve]="validate find"

    # command options
    local -A opts=()
	opts[oscap]="--version --quiet --help -V -q -h"
    opts[oscap:oval:validate]="--version --definitions --variables --syschar --results --directives --skip-schematron"
    opts[oscap:oval:eval]="--datastream-id --oval-id --id --variables --directives --without-syschar --results --report --skip-valid --skip-validation --fetch-remote-resources --local-files --verbose --verbose-log-file"
    opts[oscap:oval:analyse]="--variables --directives --verbose --verbose-log-file --skip-valid --skip-validation"
    opts[oscap:oval:collect]="--id --syschar --skip-valid --skip-validation --variables --verbose --verbose-log-file"
    opts[oscap:oval:generate:report]="-o --output"
    opts[oscap:xccdf:eval]="--benchmark-id --check-engine-results --cpe --datastream-id --enforce-signature --export-variables --fetch-remote-resources --local-files --oval-results --profile --progress --progress-full --remediate --report --results --results-arf --rule --skip-rule --skip-valid --skip-validation --skip-signature-validation --stig-viewer --tailoring-file --tailoring-id --thin-results --verbose --verbose-log-file --without-syschar --xccdf-id"
    opts[oscap:xccdf:validate]="--skip-schematron"
    opts[oscap:xccdf:export-oval-variables]="--datastream-id --xccdf-id --profile --skip-valid --skip-validation --fetch-remote-resources --local-files --cpe"
    opts[oscap:xccdf:remediate]="--result-id --skip-valid --skip-validation --fetch-remote-resources --local-files --results --results-arf --report --oval-results --export-variables --cpe --check-engine-results --progress --progress-full"
    opts[oscap:xccdf:resolve]="-o --output -f --force"
    opts[oscap:xccdf:generate]="--profile"
    opts[oscap:xccdf:generate:report]="-o --output --result-id --profile --oval-template --sce-template"
    opts[oscap:xccdf:generate:guide]="-o --output --hide-profile-info --profile --benchmark-id --xccdf-id --tailoring-file --tailoring-id --skip-signature-validation --enforce-signature"
    opts[oscap:xccdf:generate:fix]="-o --output --template --profile --result-id --profile --fix-type --xccdf-id --benchmark-id --tailoring-file --tailoring-id --skip-signature-validation --enforce-signature"
    opts[oscap:xccdf:generate:custom]="-o --output --stylesheet"
    opts[oscap:ds:sds-add]="--datastream-id --skip-valid --skip-validation"
    opts[oscap:ds:sds-compose]="--skip-valid --skip-validation"
    opts[oscap:ds:sds-split]="--datastream-id --xccdf-id --skip-valid --skip-validation --fetch-remote-resources --local-files"
    opts[oscap:ds:rds-create]="--skip-valid --skip-validation"
    opts[oscap:ds:rds-split]="--report-id --skip-valid --skip-validation"
    opts[oscap:cvss:score]=""
    opts[oscap:cvss:describe]=""
    opts[oscap:info]="--fetch-remote-resources --local-files --profile --profiles"

    # local variables
	local std cmd i prev
	local c=1
	local cur="`_get_cword`"
	local prog="${COMP_WORDS[0]}"
    local modpath='oscap'
	_split_longopt || prev="${COMP_WORDS[$COMP_CWORD-1]}"

    # get module path
	while [ $c -lt $COMP_CWORD ]; do
		i="${COMP_WORDS[c]}"
		case "$i" in
			# TODO handle generic switches
			-*) _oscap_noarg "$i"; c=$((c + $?)) ;;
			*) modpath="$modpath:$i" ;;
		esac
		c=$((c + 1))
	done

	if [ "x${prev:0:1}" == "x-" ] && ! _oscap_noarg "$prev"; then
		# an option argument

        local cmd=${modpath##*:}

		case "$prev" in
			--AV|--AC|--AU|--CI|--II|--AI|--EX|--RL|--RC|--CD|--TD|--CR|--IR|--AR)
				COMPREPLY=( $(compgen -W "`$prog cvss $cmd -h | sed -r -n -e "s:^\s+$prev=\[(.+)\].+$:\1:gp" | tr '|' ' '`" -- ${cur}) ) ;;
			--results|-o|--output|--template|--oval-template) _filedir 'xml.bz2|xml' ;;
            --report) _filedir 'html' ;;
		esac

	elif [ "x${cur:0:1}" == "x-" ] || [ "${modpath:0:11}" == 'oscap:cvss:' ]; then
		# an option
		COMPREPLY=( $(compgen -W "${opts[$modpath]}" -- ${cur}) )
    elif [ "x${cmds[$modpath]}" != 'x' ]; then
        # a submodule
		COMPREPLY=( $(compgen -W "${cmds[$modpath]}" -- ${cur}) )
	else
		# a positional argument

		case "$modpath" in
			oscap:cvss:*) ;; # no positional args for cvss
			*) _filedir 'xml.bz2|xml' ;;
		esac

	fi

}

[ "${BASH_VERSINFO[0]}" -ge '4' ] && complete -F _oscap -o filenames oscap


Stv3n404 - 2023