Log4j – three stages of self awareness

Log4j – three stages of self awareness :)

1. find

> find . -name "*log4j*"

– you know that there is a problem

2. dependency:tree

> mvn dependency:tree -Dverbose

– you already know that your project has a problem

3. find_log4j.sh

--- CUT HERE --- find_log4j.sh --- CUT HERE ---
#!/bin/sh

POM_FILE=$1

PLUGIN=org.apache.maven.plugins:maven-dependency-plugin:3.2.0:list
SIZE=`mvn $PLUGIN -f $1 | grep "org\.apache\.logging\.log4j" | wc -l`

if [ $SIZE -ne 0 ]
then
  echo File: $1
  echo "-------------------------------------------------"
  mvn $PLUGIN -f $1 | grep "org\.apache\.logging\.log4j"
  echo "-------------------------------------------------"
fi
--- CUT HERE --- find_log4j.sh --- CUT HERE ---

and then, inside ~/.m2

> find . -name "*.pom" -exec $HOME/find_log4j.sh {} \;

– you stay in Wonderland and I show you how deep the rabbit-hole goes ;)