Skip to content

Instantly share code, notes, and snippets.

@jaimevalero
Created September 20, 2021 13:27
Show Gist options
  • Save jaimevalero/234bb29b5d2faec24923e343b2526bd3 to your computer and use it in GitHub Desktop.
Save jaimevalero/234bb29b5d2faec24923e343b2526bd3 to your computer and use it in GitHub Desktop.
using gitleak to scan a github repo
#########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's@.git@@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