CISOfy / lynis

Lynis - Security auditing tool for Linux, macOS, and UNIX-based systems. Assists with compliance testing (HIPAA/ISO27001/PCI DSS) and system hardening. Agentless, and installation optional.
https://cisofy.com/lynis/
GNU General Public License v3.0
13.48k stars 1.48k forks source link

small bug in /usr/share/lynis/include/tests_kernel line 695 #1529

Open garberw opened 3 months ago

garberw commented 3 months ago

Describe the bug /usr/share/lynis/include/tests_kernel line 695 is generating the error

line 695
                        FOUND_VMLINUZ=$(${LSBINARY} -v ${ROOTDIR}boot/vm[l0-9]* 2> /dev/null | ${GREPBINARY} -v '\-rescue\-' | ${TAILBINARY} -1)
grep: warning: stray \ before -

for the same reason

root@electron# mybug=$(ls -v /boot/vm[l0-9]* | grep -v '\-rescue\-' | tail -1)
grep: warning: stray \ before -
root@electron# echo $mybug
/boot/vmlinuz-6.9.10-200.fc40.x86_64

Version

Expected behavior it works but perhaps something is wrong with this command

garberw commented 3 months ago
root@electron# FOUND_VMLINUZ=$(ls -v /boot/vm[l0-9]* 2> /dev/null | grep -v '\-rescue-' | tail -1)
root@electron# echo $FOUND_VMLINUZ 
/boot/vmlinuz-6.9.11-200.fc40.x86_64

the solution is that you need grep -v '\-rescue-' and not grep -v '\-rescue\-' the second one has a backslash on the second '-' which is wrong.