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

parameters « include - github.com/CISOfy/lynis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 790fa2f87a1201164d7e7eb99d4a1dde2600534e (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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#!/bin/sh

#################################################################################
#
#   Lynis
# ------------------
#
# Copyright 2007-2015, Michael Boelen (michael.boelen@cisofy.com)
# Web site: https://cisofy.com
#
# Lynis comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
# welcome to redistribute it under the terms of the GNU General Public License.
# See LICENSE file for usage of this software.
#
#################################################################################
#
# Parameter checks
#
#################################################################################
#

    # Check number of parameters submitted (at least one is needed)
    PARAMCOUNT=$#
    while [ $# -ge 1 ]; do
        case $1 in
            audit)
                CHECK_BINARIES=0
                RUN_HELPERS=1
                HELPER="audit"
                RUN_PLUGINS=0
                RUN_TESTS=0
                if [ ! $2 = "" ]; then
                    case $2 in
                        "dockerfile")
                            if [ "$3" = "" ]; then
                                Display --text "${RED}Error: ${WHITE}Missing file name or URL${NORMAL}"
                                Display --text "Example: lynis audit dockerfile /root/Dockerfile"
                                ExitFatal
                              else
                                shift; shift
                                HELPER_PARAMS="$1 $2 $3"
                                HELPER="audit_dockerfile"
                                break
                            fi
                        ;;
                        "system")
                            CHECK_BINARIES=1
                            HELPER=""
                            RUN_PLUGINS=1
                            RUN_TESTS=1
                            shift
                            #break
                        ;;
                    esac
                  else
                    Display --text "${RED}Error: ${WHITE}Need a target to audit${NORMAL}"
                    Display --text " "
                    Display --text "Examples:"
                    Display --text "lynis audit dockerfile"
                    Display --text "lynis audit system"
                    ExitFatal
                fi
                #break
            ;;

          # Assign auditor to report
          --auditor)
             shift
             AUDITORNAME=$1
          ;;

          # Perform tests
          -c | --check-all | --checkall)
             CHECK=1
          ;;

          # Cronjob support
          --cronjob | --cron)
             CRONJOB=1;
             # Use some defaults (-c, -Q, no colors)
             CHECK=1; QUICKMODE=1; NEVERBREAK=1
             # Get rid of the colors
             NORMAL=""; WARNING=""; SECTION=""; NOTICE=""; OK=""; BAD=""; CYAN=""; MAGENTA=""; PURPLE=""; YELLOW=""; WHITE=""; GREEN=""; RED=""
          ;;

          # Perform tests with additional debugging information on screen
          --debug)
              DEBUG=1
          ;;

          --dump-options | --dumpoptions)
              OPTIONS="--auditor --check-all_(-c) --cronjob --debug --help --info --license-key --log-file --manpage --no-colors --no-log --pentest --profile --plugins-dir --quiet --quick --report-file --reverse-colors --tests --tests-category --upload --version --view-categories"
              for I in ${OPTIONS}; do
                  echo "${I}"
              done
              ExitClean
          ;;
          # View help
          --help | -h)
              VIEWHELP=1
          ;;

          # View program/database information
          --check-update | --check-updates | --info)
              VIEWUPDATEINFO=1
          ;;

          # License key for Lynis Enterprise
          --license-key)
             shift
             LICENSE_KEY=$1
          ;;

          # Adjust default logfile location
          --logfile | --log-file)
             shift
             LOGFILE=$1
          ;;

          # Don't use colors
          --no-colors | --nocolors)
              NORMAL=""; WARNING=""; SECTION=""; NOTICE=""; OK=""; BAD=""; CYAN=""; MAGENTA=""; PURPLE=""; YELLOW=""; WHITE=""; GREEN=""; RED=""
          ;;

          # Disable logging
          --no-log | --nolog)
             LOGFILE="/dev/null"
          ;;

          --pentest | --pen-test)
             PENTESTINGMODE=1
          ;;

          # Define a custom profile file
          --profile)
             shift
             PROFILE=$1
          ;;

          # Define a custom plugin directory
          --plugin-dir | --plugins-dir)
             shift
             PLUGINDIR=$1
             LASTCHAR=`echo $1 | awk '{ print substr($0, length($0))}'`
             if [ "${LASTCHAR}" = "/" ]; then
                 echo "${RED}Error:${WHITE} plugin directory path should not end with a slash${NORMAL}"
                 ExitFatal
             fi
             if [ ! -d ${PLUGINDIR} ]; then
                 echo "${RED}Error:${WHITE} invalid plugin directory ${PLUGINDIR}${NORMAL}"
                 ExitFatal
             fi
          ;;

          # Quiet mode
          -q | --quiet)
             QUIET=1
             # Run non-interactive
             QUICKMODE=1
          ;;

          # Non-interactive mode
          -Q | --quick)
             QUICKMODE=1
          ;;

          --report-file)
              shift
              REPORTFILE=$1
          ;;

          # Strip the colors which aren't clearly visible on light backgrounds
          --reverse-colors)
              #NORMAL="";
              SECTION="${NORMAL}";
              NOTICE="${NORMAL}";
              #OK="";
              #BAD="";
              CYAN="${NORMAL}";
              GREEN="${NORMAL}";
              YELLOW="${NORMAL}";
              WHITE="${NORMAL}";
              PURPLE="${NORMAL}";
              #GREEN="";
              #RED=""
          ;;

          # Only scan these tests
          --tests)
              shift
              TESTS_TO_PERFORM=$1
          ;;

          # Scan one or more categories only
          --tests-category)
              shift
              TESTS_CATEGORY_TO_PERFORM=$1
          ;;

          # Lynis Enterprise: upload data to central node
          --upload)
              UPLOAD_DATA=1
          ;;

          # Version number
          -V | --version)
             echo "${PROGRAM_version}"
             exit 0
          ;;

          --view-categories | --list-categories | --show-categories)
             ViewCategories
             exit 0
          ;;

          # View man page
          --view-manpage | --man | --manpage)
             if [ -f lynis.8 ]; then
                 nroff -man lynis.8
                 exit 0
               else
                 echo "Error: man page file not found (lynis.8)"
                 echo "If you are running an installed version of Lynis, use 'man lynis'"
                 exit 1
             fi
          ;;

          # Drop out when using wrong option(s)
          *)
              # Wrong option used, we bail out later
              WRONGOPTION=1
              WRONGOPTION_value=$1
          ;;

        esac
        shift

    done

#================================================================================
# Lynis - Copyright 2007-2015, Michael Boelen - www.rootkit.nl - The Netherlands