Skip to content

Instantly share code, notes, and snippets.

@Auronmatrix
Last active November 27, 2018 10:35
Show Gist options
  • Save Auronmatrix/7bb3c4ae1a0a01360aef4c5e7aec63f7 to your computer and use it in GitHub Desktop.
Save Auronmatrix/7bb3c4ae1a0a01360aef4c5e7aec63f7 to your computer and use it in GitHub Desktop.
BashScript to check all subfolders for compromised dependency (https://github.com/dominictarr/event-stream/issues/116)
#!/bin/bash
function recursiveCheck() {
for d in * ; do
if [ $d == "node_modules" ] ; then
#echo "Skipping $PWD"
else if [ -d "$d" ]; then
cd "$d"
#echo "Checking $PWD"
if [ -f "package.json" ];
then
npm ls event-stream flatmap-stream
else
recursiveCheck
fi
cd ..
fi
fi
done
}
recursiveCheck
@caffeinum
Copy link

caffeinum commented Nov 27, 2018

It didn't work for me on Mac, so I edited this a bit:

Run from home dir, found one project that used the package as a dev-dependency. Thanks a lot!

#!/bin/bash

function recursiveCheck() {

for d in * ; do
    if [ -d "$d" ];
    then
        # echo "checking $d"
        cd "$d"
        if [ -d ".git" ];
            then
                npm ls event-stream flatmap-stream
            else 
                recursiveCheck
            fi
        cd ..
    fi
done

}

recursiveCheck

@Auronmatrix
Copy link
Author

Thanks. I'll add that and changes recommended by @luchsamapparat (dominictarr/event-stream#116 (comment)) to a new revision

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment