Welcome to mirror list, hosted at ThFree Co, Russian Federation.

lynis « bash_completion.d « extras - github.com/CISOfy/lynis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5c816aea0c18960951d29dd2e0ef91ba662d4ff0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# bash completion for lynis

# version 1.0.1 (2019-07-13)
# Michael Boelen <michael.boelen@cisofy.com>

# lynis(8) completion
_lynis()
{
    local cur prev
    # opts nodig nosig

    COMPREPLY=()
    _get_comp_words_by_ref cur prev words

    if [ $COMP_CWORD -eq 1 ]; then
        # first parameter on line
        case $cur in
            -*)
                COMPREPLY=( $( compgen -W '--help --info --version' -- "$cur" ) )
                ;;
            *)
                COMPREPLY=( $( compgen -W 'audit generate show' -- "$cur" ) )
                ;;
        esac
        return 0
    elif [ $COMP_CWORD -eq 4 ]; then
        # Stop after some specifics
        if [ "${COMP_WORDS[1]}" = "show" -a "${COMP_WORDS[2]}" = "details" ]; then
            return 0
        fi
    fi

    # Check previous argument to share the available options
    case $prev in
        audit)
            COMPREPLY=( $( compgen -W 'dockerfile system ' -- "$cur" ) )
            ;;

        show)
            COMPREPLY=( $( compgen -W 'categories changelog commands dbdir details environment eol groups help hostids includedir language license logfile man options os pidfile plugindir profiles release releasedate report settings tests  version workdir ' -- "$cur" ) )
            ;;

        # Related items to show (lynis show XYZ)
        categories)
            return 0
            ;;
        changelog)
            return 0
            ;;
        commands)
            return 0
            ;;
        dbdir)
            return 0
            ;;
        details)
            local dbfile=""
            local dirs="/data/development/lynis /usr/local/lynis /usr/share/lynis"
            for d in ${dirs}; do
                if [ -f "${d}/db/tests.db" ]; then
                    local dbfile="/data/development/lynis/db/tests.db"
                fi
            done
            if [ -f "${dbfile}" ]; then
                local suggestions=($(compgen -W "$(awk -F: '$1 ~ /^[A-Z]/ {print $1}' ${dbfile})" -- "${cur}"))
                COMPREPLY=("${suggestions[@]}")
            else
                COMPREPLY=($(compgen -W "TEST-1234" -- "$cur"))
            fi
            ;;
        environment)
            return 0
            ;;
        eol)
            return 0
            ;;
        groups)
            return 0
            ;;
        help)
            return 0
            ;;
        hostids)
            if [ "${COMP_WORDS[1]}" = "generate" -a "${COMP_WORDS[2]}" = "hostids" ]; then
                COMPREPLY=($(compgen -W "save" -- "$cur"))
            else
                return 0
            fi
            ;;
        includedir)
            return 0
            ;;
        language)
            return 0
            ;;
        license)
            return 0
            ;;
        logfile)
            return 0
            ;;
        man)
            return 0
            ;;
        options)
            return 0
            ;;
        os)
            return 0
            ;;
        pidfile)
            return 0
            ;;
        plugindir)
            return 0
            ;;
        profiles)
            return 0
            ;;
        release)
            return 0
            ;;
        releasedate)
            return 0
            ;;
        report)
            return 0
            ;;
        settings)
            return 0
            ;;
        tests)
            return 0
            ;;
        version)
            return 0
            ;;
        workdir)
            return 0
            ;;

        generate)
            COMPREPLY=( $( compgen -W 'hostids ' -- "$cur" ) )
            ;;

        # Options
        --auditor)
            COMPREPLY=( '"Mr. Auditor"' )
            #return 0
            ;;
        --check-update|--help|--info|--version)
            # all other options are noop with this command
            return 0
            ;;
        --logfile)
            COMPREPLY=( 'myfile.log' )
            return 0
            ;;
        --plugin-dir)
            _filedir -d
            return 0
            ;;
        --profile)
            COMPREPLY=( 'default.prf' )
            return 0
            ;;
        --tests)
            COMPREPLY=( '"TEST-0001 TEST-0002 TEST-0003"' )
            return 0
            ;;
        --tests-from-category)
            COMPREPLY=( '"performance privacy security"' )
            return 0
            ;;
        --tests-from-groups)
            COMPREPLY=( '"accounting authentication"' )
            return 0
            ;;
        *)
            COMPREPLY=( $( compgen -W ' \
                --auditor --cronjob --debug --quick --quiet --logfile --no-colors --no-log --pentest --reverse-colors \
                --tests --tests-from-category --tests-from-group --upload --verbose --slow-warning' -- "$cur" ) )
            ;;
    esac

    return 0
}

complete -F _lynis lynis

# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh