mirror of https://github.com/CISOfy/lynis.git
Add upload-only command
This commit is contained in:
parent
4da54cf95a
commit
063f50f39c
|
@ -77,6 +77,7 @@ unset LANG
|
|||
CONTROL_URL_APPEND=""
|
||||
CONTROL_URL_PREPEND=""
|
||||
CONTROL_URL_PROTOCOL=""
|
||||
CREATE_REPORT_FILE=1
|
||||
CSUMBINARY=""
|
||||
CUSTOM_URL_APPEND=""
|
||||
CUSTOM_URL_PREPEND=""
|
||||
|
|
|
@ -87,7 +87,14 @@
|
|||
|
||||
# Check report file
|
||||
if [ -f ${REPORTFILE} ]; then
|
||||
Output "${WHITE}Report file found.${NORMAL} Starting with connectivity check.."
|
||||
|
||||
Output "${WHITE}Report file found.${NORMAL} Starting with content check."
|
||||
|
||||
FIND=$(${GREPBINARY} "finish=true" ${REPORTFILE})
|
||||
if [ $? -gt 0 ]; then ExitFatal "The report is not complete, skipping upload"; fi
|
||||
|
||||
Output "${WHITE}Report file found.${NORMAL} Starting with connectivity check."
|
||||
|
||||
|
||||
if [ ! "${UPLOAD_PROXY_SERVER}" = "" ]; then
|
||||
LogText "Upload: Proxy is configured: ${UPLOAD_SERVER}"
|
||||
|
@ -208,6 +215,8 @@
|
|||
# Try to connect
|
||||
Output "Uploading data.."
|
||||
LogText "Command used: ${CURLBINARY}${CURL_OPTIONS} -s -S --data-urlencode \"data@${REPORTFILE}\" --data-urlencode \"licensekey=${LICENSE_KEY}\" --data-urlencode \"hostid=${HOSTID}\" ${UPLOAD_URL}"
|
||||
LogText "Tip: try running ${CURLBINARY}${CURL_OPTIONS} --data-urlencode \"data@${REPORTFILE}\" --data-urlencode \"licensekey=${LICENSE_KEY}\" --data-urlencode \"hostid=${HOSTID}\" ${UPLOAD_URL}
|
||||
LogText "Tip: to just retry an upload, use: lynis upload-only"
|
||||
UPLOAD=$(${CURLBINARY}${CURL_OPTIONS} -s -S --data-urlencode "data@${REPORTFILE}" --data-urlencode "licensekey=${LICENSE_KEY}" --data-urlencode "hostid=${HOSTID}" --data-urlencode "hostid2=${HOSTID2}" ${UPLOAD_URL} 2> /dev/null)
|
||||
EXITCODE=$?
|
||||
LogText "Exit code: ${EXITCODE}"
|
||||
|
@ -233,6 +242,7 @@
|
|||
fi
|
||||
else
|
||||
echo "${RED}Error${NORMAL}: No hostid and/or hostid2 found. Can not upload report file."
|
||||
echo "Suggested command: lynis show hostids"
|
||||
# Quit
|
||||
ExitFatal
|
||||
fi
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#
|
||||
######################################################################
|
||||
|
||||
COMMANDS="audit show update"
|
||||
COMMANDS="audit show update upload-only"
|
||||
HELPERS="audit configure show update"
|
||||
OPTIONS="--auditor\n--check-all (-c)\n--config\n--cronjob (--cron)\n--debug\n--developer\n--help (-h)\n--license-key\n--log-file\n--manpage (--man)\n--no-colors --no-log\n--pentest\n--profile\n--plugins-dir\n--quiet (-q)\n--quick (-Q)\n--report-file\n--reverse-colors\n--tests\n--tests-from-category\n--tests-from-group\n--upload\n--verbose\n--version (-V)\n--wait"
|
||||
|
||||
|
@ -104,6 +104,13 @@ UPDATE_HELP="
|
|||
|
||||
"
|
||||
|
||||
UPLOAD_ONLY_HELP="
|
||||
${CYAN}update-only${NORMAL}
|
||||
|
||||
Perform just a data upload
|
||||
|
||||
"
|
||||
|
||||
SHOW_SETTINGS_ARGS="--brief --configured-only --nocolors"
|
||||
SHOW_TESTS_ARGS="skipped"
|
||||
|
||||
|
@ -244,8 +251,9 @@ if [ $# -gt 0 ]; then
|
|||
"audit") ${ECHOCMD} "${AUDIT_HELP}" ;;
|
||||
"show") ${ECHOCMD} "${SHOW_HELP}" ;;
|
||||
"update") ${ECHOCMD} "${UPDATE_HELP}" ;;
|
||||
"upload-only") ${ECHOCMD} "${UPLOAD_ONLY_HELP}" ;;
|
||||
"?") ${ECHOCMD} "${SHOW_ARGS}" ;;
|
||||
*) ${ECHOCMD} "Invalid argument provided for lynis show help" ;;
|
||||
*) ${ECHOCMD} "Unknown argument provided for lynis show help" ;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
|
|
|
@ -151,6 +151,23 @@
|
|||
fi
|
||||
;;
|
||||
|
||||
# Perform just the upload
|
||||
"upload-only" | "only-upload")
|
||||
CHECK_BINARIES=1
|
||||
CREATE_REPORT_FILE=0
|
||||
#QUIET=1
|
||||
LOGTEXT=0
|
||||
RUN_HELPERS=0
|
||||
RUN_TESTS=0
|
||||
RUN_UPDATE_CHECK=0
|
||||
SKIP_PLUGINS=1
|
||||
SHOW_REPORT=0
|
||||
SHOW_TOOL_TIPS=0
|
||||
SHOW_PROGRAM_DETAILS=0
|
||||
UPLOAD_DATA=1
|
||||
if [ $# -gt 1 ]; then echo "No other parameters or options are allowed when using 'upload-only' command"; ExitFatal; fi
|
||||
;;
|
||||
|
||||
# Assign auditor to report
|
||||
--auditor)
|
||||
shift
|
||||
|
|
4
lynis
4
lynis
|
@ -29,7 +29,7 @@
|
|||
|
||||
# Version details
|
||||
PROGRAM_RELEASE_DATE="2016-10-05"
|
||||
PROGRAM_RELEASE_TIMESTAMP=1475653970
|
||||
PROGRAM_RELEASE_TIMESTAMP=1476382458
|
||||
PROGRAM_RELEASE_TYPE="dev" # dev or final
|
||||
PROGRAM_VERSION="2.3.5"
|
||||
|
||||
|
@ -492,7 +492,7 @@ ${NORMAL}
|
|||
LogText "### ${PROGRAM_COPYRIGHT} ###"
|
||||
|
||||
# Clear report file (to avoid appending to an existing file)
|
||||
echo "# ${PROGRAM_NAME} Report" > ${REPORTFILE}
|
||||
if [ ${CREATE_REPORT_FILE} -eq 1 ]; then echo "# ${PROGRAM_NAME} Report" > ${REPORTFILE}; fi
|
||||
Report "report_version_major=${REPORT_version_major}"
|
||||
Report "report_version_minor=${REPORT_version_minor}"
|
||||
CDATE=`date "+%F %H:%M:%S"`
|
||||
|
|
Loading…
Reference in New Issue