Commit Graph

139 Commits

Author SHA1 Message Date
hlein e054e9757c Lots of cleanups (#366)
* Description fix: SafePerms works on files not dirs.

All uses of SafePerms are on files (and indeed, it would reject
directories which would have +x set).

* Lots of whitespace cleanups.

Enforce everywhere(?) the same indentations for if/fi blocks.
The standard for the Lynis codebase is 4 spaces.  But sometimes
it's 1, sometimes 3, sometimes 8.

These patches standardize all(?) if blocks but _not_ else's (which
are usually indented 2, but sometimes zero); I was too lazy to
identify those (see below).

This diff is giant, but should not change code behavior at all;
diff -w shows no changes apart from whitespace.

FWIW I identified instances to check by using:

  perl -ne 'if ($oldfile ne $ARGV) { $.=1; $oldfile=$ARGV; }; chomp; if ($spaces) { next unless /^( *)([^ ]+)/; $newspaces=length($1); $firsttok = $2; next unless defined($firsttok); $offset = ($firsttok eq "elif" ? 0 : 4); if ($newspaces != $spaces + $offset) { print "$ARGV:$ifline\n$ARGV:$.:$_\n\n" }; $ifline=""; $spaces="";  } if (/^( *)if (?!.*[; ]fi)/) { $ifline = "$.:$_"; $spaces = length($1); }' $(find . -type f -print0 | xargs -0 file | egrep shell | cut -d: -f1)

Which produced output like:

  ./extras/build-lynis.sh:217:            if [ ${VERSION_IN_SPECFILE} = "" -o ! "${VERSION_IN_SPECFILE}" = "${LYNIS_VERSION}" ]; then
  ./extras/build-lynis.sh:218:               echo "[X] Version in specfile is outdated"

  ./plugins/plugin_pam_phase1:69:        if [ -d ${PAM_DIRECTORY} ]; then
  ./plugins/plugin_pam_phase1:70:                LogText "Result: /etc/pam.d exists"

...There's probably formal shellscript-beautification tools that
I'm oblivious about.

* More whitespace standardization.

* Fix a syntax error.

This looks like an if [ foo -o bar ]; was converted to if .. elif,
but incompletely.

* Add whitespace before closing ].

Without it, the shell thinks the ] is part of the last string, and
emits warnings like:

  .../lynis/include/tests_authentication: line 1028: [: missing `]'
2017-03-07 19:23:08 +00:00
hlein b595cc0fb5 Various cleanups (#363)
* Typo fix.

* Style change: always use $(), never ``.

The Lynis code already mostly used $(), but backticks were sprinkled
around.  Converted all of them.

* Lots of minor spelling/typo fixes.

FWIW these were found with:

  find . -type f -print0 | xargs -0 cat | aspell list | sort -u | egrep '^[a-z]+$' | less

And then reviewing the list to pick out things that looked like
misspelled words as opposed to variables, etc., and then manual
inspection of context to determine the intention.
2017-03-06 07:41:21 +00:00
Michael Boelen 34ba1ba184 Changed date and preparing for release 2017-02-09 13:35:40 +01:00
Michael Boelen 22d27434c9 Enhance pkg support on FreeBSD 2016-10-15 16:38:33 +02:00
Michael Boelen f1c3c23cae Corrected error redirection 2016-10-15 16:22:18 +02:00
Michael Boelen 8777a5e616 Use rootdir and proper error redirection 2016-10-15 16:20:04 +02:00
Michael Boelen f0b9a64c47 [PKGS-7381] bugfix at detection of pkg tool 2016-10-15 16:16:26 +02:00
Michael Boelen d88f755f40 [PKGS-7381] check pkg audit and report when the vulnerability database is missing 2016-10-15 16:12:49 +02:00
Michael Boelen d0d76c44cb Improved logging 2016-10-15 15:38:06 +02:00
Michael Boelen 9caf3005b5 Style improvements and hardening points 2016-09-26 12:05:30 +02:00
Michael Boelen a3f57e6d01 Mark tests PKGS-7320 and PKGS-7322 as Linux-only 2016-09-24 16:17:11 +02:00
Michael Boelen 98d9096739 Mark arch-audit as a package audit tool 2016-09-24 15:36:45 +02:00
Michael Boelen 1418e0404b Extended message for arch-audit 2016-09-24 15:34:31 +02:00
Michael Boelen 263c0b558b Changes to show more details for warnings 2016-09-24 15:27:42 +02:00
Michael Boelen 1bc29ebb2e Added solution to arch-audit test 2016-09-24 15:20:24 +02:00
Michael Boelen 1063c8f3e8 Replace calls to binaries and changes in output within report 2016-09-24 15:07:20 +02:00
Michael Boelen 780e66ea81 Use OS full name to detect distribution 2016-09-24 14:58:30 +02:00
Michael Boelen db419495bf Added support for arch-audit tooling 2016-09-24 14:49:14 +02:00
Michael Boelen 9d91f7dac7 [PKGS-7381] Improved output of log and warning 2016-09-22 14:54:55 +02:00
Michael Boelen 6a7ec8795a [PKGS-7381] Collect FreeBSD details for vulnerable packages 2016-09-22 14:47:06 +02:00
Michael Boelen 82ededed31 Style improvements and command replacements 2016-09-08 21:04:17 +02:00
Michael Boelen 679e8c628e Use detected binaries 2016-08-25 15:31:33 +02:00
Michael Boelen e176011912 Allow repository update to be disabled 2016-08-11 10:01:29 +02:00
Michael Boelen f9b2993f35 Removed unneeded field 2016-08-10 07:24:10 +02:00
Michael Boelen fc2d9b935c Removed unneeded field for warnings and suggestions 2016-08-10 07:13:38 +02:00
Michael Boelen 2fe1819c35 [PKGS-7383] Simplified test 2016-07-31 15:51:34 +02:00
beelsr 4143cd69b5 fix yum gpgenabled check to allow spaces around = (#247)
Issue 245

yum.conf allows an arbitrary number of spaces to surround the equals assignment.
2016-07-30 17:14:51 +02:00
Michael Boelen cfdc8228fd [PKGS-7388] Readability improvements and initialization 2016-07-30 16:40:44 +02:00
Michael Boelen 2f4c854ba7 Rename of categories, introduction of groups 2016-07-24 17:22:00 +02:00
Michael Boelen 983e293eb1 Replaced text strings to allow translations 2016-06-18 11:14:01 +02:00
Michael Boelen 02fdaf4c1e [PKGS-7328] Set non-interactive as first option like other calls to Zypper 2016-05-30 19:43:10 +02:00
Andreas Stieger ece464b1da improve non-interactive use of zypper (#208)
* PKGS-7328: only list installed items of type package

Otherwise the package list may contain duplicate items of type application or patch

Signed-off-by: Andreas Stieger <astieger@suse.com>

* PKGS-7328, PKGS-7330: run zypper with non-interactive flag

Otherwise the test will hang if zypper issues an interactive query or warning,
such as for new/changed keys, network issues or other errors.

Signed-off-by: Andreas Stieger <astieger@suse.com>
2016-05-30 19:20:37 +02:00
Michael Boelen 90f196f067 [PKGS-7381] Check for vuln.xml file 2016-05-04 21:59:52 +02:00
Michael Boelen eded02cfde Rewritten counters and dealing with values 2016-05-03 14:57:53 +02:00
Michael Boelen 99236b13f4 Mark apt-get related tests to be root-only 2016-05-02 17:13:31 +02:00
mboelen 42607ceaf5 Replaced old function names with new ones 2016-04-28 12:31:57 +02:00
mboelen 60a7abf877 [PKGS-7354] Test for DNF repoquery plugin before using it 2016-04-21 11:44:42 +02:00
mboelen 95df056ca8 Don't use type -p, as it won't work on all systems 2016-03-24 14:35:12 +01:00
Kamil Boratyński 85236bb996 Added brew as package manager. 2016-03-22 23:06:10 +01:00
Michael Boelen 2fe5fa2cc6 Merge pull request #135 from rhyven/patch-5
Accept apt-get as a package audit tool
2016-03-16 11:02:35 +01:00
Eric Light a97bcb2142 Accept apt-get as a package audit tool 2016-03-14 12:02:18 +13:00
mboelen 8cc47819b4 Removed copyright line, added description 2016-03-13 16:03:46 +01:00
mboelen 6197ac08e7 Added link to website, blog, github 2016-03-13 16:00:39 +01:00
mboelen 647b482c53 Use the right columns from DNF to split package name and version 2016-01-25 15:47:24 +01:00
mboelen d3e58a0537 Adjusted stderr redirecting and improve logging of packages 2016-01-25 15:38:46 +01:00
mboelen 5c53d16189 Show on screen if vulnerable packages are found 2016-01-25 15:04:46 +01:00
mboelen acafb316d3 Add warning if DNF found vulnerable packages 2016-01-25 13:57:31 +01:00
mboelen 727ff26283 Show on screen that DNF is being used 2016-01-25 13:52:58 +01:00
mboelen e3c88fe766 Additional DNF tests 2016-01-25 13:43:05 +01:00
mboelen 1e12852b12 Initial support for DNF package manager 2016-01-25 13:18:59 +01:00
mboelen d16b38eff8 Rename of logtext and report functions, upcoming year change 2015-12-21 21:17:15 +01:00
mboelen 83a44827e0 Define queryformat for rpm command 2015-12-21 19:20:34 +01:00
mboelen 360e6b66f6 Split name and version information for RPM based package manager 2015-12-21 19:10:22 +01:00
mboelen 756c09cb4a Added YUM details 2015-11-18 15:57:33 +01:00
mboelen c68b70ff2e Extended YUM test for security plugin testing 2015-11-18 15:55:49 +01:00
mboelen 69cbabfed2 Log when vulnerable packages are found 2015-10-21 21:45:53 +02:00
SiemKorteweg bf1da50c14 Combine "sort | uniq" into "sort -u" to reduce the number of processes used for running Lynis. The busybox version of sort also supports the -u option. 2015-10-04 17:59:28 +02:00
mboelen 31363e9b39 Extended description for vulnerable package tests on FreeBSD 2015-09-24 20:14:59 +02:00
mboelen c17fcfd92d Corrected PKGS-7380 and undoubled PKGS-7381 2015-09-24 20:10:30 +02:00
Laurent Quillerou 3cdd9ea949 Delete trailing whitespace 2015-09-07 18:35:07 +03:00
mboelen 66fb369593 Copyright line changes and cleanups 2015-07-22 16:28:11 +02:00
mboelen 5f3c47df68 Added debsecan, debsums and kernel package counting 2015-05-27 12:35:56 +02:00
mboelen 4c8a6dc3d2 Rename of package auditing tool, for upcoming plugin/module 2015-04-17 15:50:46 +02:00
mboelen 017c145357 Zypper enhancements 2015-04-16 19:59:51 +02:00
mboelen de60926705 Changed sed statement 2015-04-13 22:06:14 +02:00
mboelen 7f97bfa973 Typos corrected 2015-03-25 15:55:29 +01:00
mboelen 5caf4ddc4f Update of the files to reflect HTTPS version of website and 2015. Happy New Year! 2015-01-03 12:45:22 +01:00
mboelen 1fa4416a7a Check for /var/db/pkg/pkgs-vulnerabilities presence before performing audit with pkg_admin [PKGS-7381] 2014-12-05 19:43:35 +01:00
mboelen 46de3f8d99 Hide RPM related database errors, show suggestion instead 2014-10-26 23:33:26 +01:00
mboelen f465da5351 Small adjustment to avoid getting error when no files are in APT sources.list.d directory 2014-10-24 01:23:35 +02:00
mboelen 1e624d5f2e Improved text 2014-10-14 10:54:02 +02:00
mboelen d6dbbeedb5 Added warning when GLSA finds security updates 2014-10-14 10:39:34 +02:00
mboelen 381fbf25d0 Escaping --security option as string search 2014-10-13 20:47:42 +02:00
mboelen 20815d8133 Changed typo cly.py to cli.py 2014-10-13 20:45:43 +02:00
mboelen 19fd348249 Changed typo cly.py to cli.py 2014-10-13 20:43:46 +02:00
mboelen 5e840367ca Test for built-in security measures in YUM [PKGS-7386] 2014-10-13 20:36:09 +02:00
d4t4king fab2ea5e5e Minor tweak to glsa-check to show '0' when all tests are compliant 2014-10-13 00:19:59 -07:00
mboelen 616209560f Use quiet mode when checking emerge-webrsync 2014-09-25 19:10:58 +02:00
mboelen b36be2f82c Missing -eq statement 2014-09-25 16:55:47 +02:00
mboelen 6dbeb9f6cb Gentoo updates to gather packages and test for vulnerabilities 2014-09-23 22:54:38 +02:00
mboelen e9557423cc Gentoo updates to gather packages and test for vulnerabilities 2014-09-23 22:48:20 +02:00
mboelen 6fbcf20c96 Added new tests for pacman based systems 2014-09-22 23:40:53 +02:00
mboelen 2530256d85 Small textual replacements for logging purposes 2014-09-19 02:02:22 +02:00
mboelen c9fde8c2d1 Code cleanup and small enhancements 2014-09-15 12:01:09 +02:00
mboelen 35d32fb5e4 Add pre-test before running test [PKGS-7388] 2014-09-15 11:17:26 +02:00
mboelen dd2ea3efaf Made adjustments to run in non-privileged scans 2014-09-09 14:49:37 +02:00
mboelen 56cc2df2c2 Adjustments to allow non-privileged scan and reduce errors on screen 2014-09-08 23:51:27 +02:00
mboelen b121be4317 Improved vulnerable packages test when using apt-check 2014-09-04 20:38:21 +02:00
mboelen c0ae2e217b Initial import 2014-08-26 17:33:55 +02:00