Found file log4j?

@robin.gierse hey , i think you made mistake as COUNT=echo “$RESULT” | grep “vulnerable files” | awk ‘{ print $2}’`` is giving up 2 rows also “… $SHORT\n$LONG " is messing it up as it goes to line below ,so it’s messing out the output this is how i solved it , COUNT will give value 10 if there is 1 vulnerable files and 01 if there is 1 potentially vulnerable files:
#!/bin/bash
DESTPATH=”/opt"
RESULT=/usr/lib/check_mk_agent/bin/log4j2-scan $DESTPATH
COUNT=echo "$RESULT" | grep "vulnerable files" | awk '{printf "%s", $2}'
SHORT=echo "$RESULT" | grep "vulnerable files"
LONG=echo "$RESULT" | awk 1 ORS='\\\\n'
echo “P CVE-2021-44228_log4j count=”$COUNT";1;1 $LONG"

1 Like