-
-
Notifications
You must be signed in to change notification settings - Fork 344
/
gsearch-reflog.sh
executable file
·72 lines (62 loc) · 1.01 KB
/
gsearch-reflog.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
t_keywords=(
"passwd"
"password"
# "key"
"secret"
"apikey"
"api_key",
"app_key"
"client_secret"
"secret_key"
"access_key"
"fb_secret"
"gsecr"
"id_rsa"
"id_dsa"
"amazonaws.com"
"storage.google"
"storage.cloud.google"
"digitaloceanspaces.com"
"cloudfront.net"
"blob.core.windows.net"
'ghp_'
'github_pat_'
'AKIA[A-Z0-9]{16}'
)
function usage {
echo "Usage: "$0" <repository url>"
if [ -n "$1" ] ; then
echo "Error: "$1"!"
fi
exit
}
if [ ! $# -eq 1 ] ; then
usage
fi
repo=$1
http=${repo:0:4}
repo_name=$(basename $repo)
if [ $http == "http" ] ; then
if [ ! -d $repo_name ] ; then
echo "Repository not found, cloning..."
git clone $repo
fi
repo=$repo_name
fi
if [ -d $repo ] ; then
echo "Repository already exists, updating..."
cd $repo
git pull
cd ..
else
echo "Something goes wrong!"
exit
fi
cd $repo
echo "Running reflog..."
git log --reflog -p > reflog.txt
echo
for w in ${t_keywords[@]} ; do
egrep -n --color "$w" reflog.txt -A 5 -B 5
done