-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentrypoint.sh
executable file
·83 lines (76 loc) · 1.73 KB
/
entrypoint.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
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
function usage() {
echo "usage : [cmd] -t GIT_TOKEN -u ORG/USER_NAME [-m mode] [-h]"
echo ' -t: scm token to clone with'
echo ' -u: user name'
echo ' -o: organization name'
echo ' -s: type of scm used, github, gitlab or bitbucket (default: github)'
echo ' -b: branch left checked out for each repo cloned (default: default branch)'
echo ' -h: host url, for on self hosted git repository (default: uses github/gitlab public api)'
echo ' -f: Include repos are forks (default: skip fork repository)'
echo ' -a: Include repos are archived (default: skip archived repository)'
}
function checkuser() {
if [[ ! -z ${USER} ]];then
echo "Only set username or organization name"
exit 1
fi
}
TOKEN=
USER=
MODE=
HOST=
BRANCH=
SERVICE=
SKIP_FORK="--skip-forks"
SKIP_ARCHIVED="--skip-archived"
while getopts "t:u:o:s:b:h:fa" opt; do
case ${opt} in
t)
TOKEN=${OPTARG}
;;
u)
checkuser
USER=${OPTARG}
MODE=user
;;
o)
checkuser
USER=${OPTARG}
MODE=org
;;
s)
SERVICE="-s ${OPTARG}"
;;
b)
BRANCH="-b ${OPTARG}"
;;
h)
HOST="--base-url ${OPTARG}"
;;
f)
SKIP_FORK=""
;;
a)
SKIP_ARCHIVED=""
;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
exit 1
;;
esac
done
if [ -z "${TOKEN}" ]; then
echo "require -t TOKEN"
exit 1
fi
if [ -z "${USER}" ]; then
echo "require -u or -o"
exit 1
fi
ghorg clone "${USER}" -t "${TOKEN}" -c "${MODE}" $SERVICE $BRANCH $HOST $SKIP_FORK $SKIP_ARCHIVED -p / --output-dir secrets
for f in `\find /secrets_ghorg/ -type d -name ".git"`; do
echo "Start scanning ${f%/.git}"
shhgit -silent -local ${f%/.git}
done