Created
September 20, 2021 13:27
-
-
Save jaimevalero/234bb29b5d2faec24923e343b2526bd3 to your computer and use it in GitHub Desktop.
using gitleak to scan a github repo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#########Scan a given github url passed as parameter with gitleaks | |
#eg: REPO=https://github.com/Telefonica/epg-airflow | |
# Other Param | |
#SERVER_DESTINO_SSH="github.com" | |
Scan_Repo() | |
{ | |
REPO="$1" | |
REPO_FORMATED=`echo "$REPO" | sed -e 's@https://github.com/@@g' -e'[email protected]@@g' ` | |
REPO_FORMATED_SHORT_NAME=` echo $REPO_FORMATED | cut -d\/ -f2` | |
DIRECTORIO_DE_TRABAJO=/tmp/scans | |
mkdir -p ${DIRECTORIO_DE_TRABAJO} ; cd ${DIRECTORIO_DE_TRABAJO} | |
echo Cloning $REPO ::: | |
echo "git clone git@${SERVER_DESTINO_SSH}:${REPO_FORMATED}.git" | |
git clone git@${SERVER_DESTINO_SSH}:${REPO_FORMATED}.git | |
cd ${REPO_FORMATED_SHORT_NAME} | |
pwd ; ls -altr | |
echo "Scann $REPO using gitleaks..." | |
gitleaks -p . -q --threads 5 | jq ". += {\"source_repository\":\"$REPO_FORMATED\"}" | tee -a /tmp/vulnerabilities.json | |
cd /tmp ; rm -rf ${DIRECTORIO_DE_TRABAJO} | |
INCIDENCIAS_ACUMULADAS=`grep -c '"file"' /tmp/vulnerabilities.json` | |
echo "Vulnerabilities found: ${INCIDENCIAS_ACUMULADAS}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment