Shdep is an analysis tool to trace the shell script dependency.
-
Prerequisite
Shdep leverages shfmt/v2.0 to parse the script syntax tree. A copy can be found in
tools
folder. Put it in one of your path in $PATH. -
Build Gradle Task
./gradlew shdep
-
Security Concerns
Some commands in scripts could be run for anlaysis. For security concerns, it is recommanded to run the tool in a docker container or a vitual machine.
-
Execute JAR
java -jar build/libs/shdep.jar sample/cramfs-root # To unpack the sample file first.
-
Output
/sbin/rc.init -> /sbin/rc.factorydefault -> /bin/readbits /sbin/rc.init -> /sbin/rc.factorydefault -> /bin/eraseflash /sbin/rc.init -> /sbin/rc.factorydefault -> /bin/echo /sbin/rc.init -> /sbin/rc.factorydefault -> /bin/cp /sbin/rc.init -> /sbin/rc.factorydefault -> /bin/set_led -> /bin/statusled /sbin/rc.init -> /sbin/rc.factorydefault -> /bin/set_led -> /var/run/statusled /sbin/rc.init -> /sbin/rc.factorydefault -> /bin/set_led -> /bin/networkled /sbin/rc.init -> /sbin/rc.factorydefault -> /bin/set_led -> /bin/powerled ... ... ...