Skip to content

Commit 3d7e33f

Browse files
author
minghui.qmh
committed
update tools
1 parent 9c06bd9 commit 3d7e33f

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
.idea
88
easytexminer.egg-info
99
build
10-
tools
1110
xflow_deploy
1211
dist
1312
.DS_Store

tools/init.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# init pre-commit check hook
4+
if [ ! -d .git/hooks/ ]; then
5+
mkdir .git/hooks
6+
fi
7+
8+
rm -rf .git/hooks/pre-commit
9+
cp tools/pre-commit .git/hooks/
10+
chmod a+rx .git/hooks/pre-commit
11+
12+
# other inits
13+
#python git-lfs/git_lfs.py pull
14+
15+
# compile proto files
16+
#source scripts/gen_proto.sh
17+

tools/pre-commit

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
echo "Check for sensitive information leak:"
3+
projectUrl=`git config --get remote.origin.url`
4+
user=`git config --get user.name`
5+
user_email=`git config --get user.email`
6+
STAGE_FILES=$(git diff --cached --name-only)
7+
stage_files=(${STAGE_FILES/ // })
8+
keywords=("LTAI[a-zA-Z0-9]{20}" "LTAI[a-zA-Z0-9]{12}" "acs:ram::[0-9]{16}:role/")
9+
10+
result=0
11+
for i in "${!stage_files[@]}"; do
12+
if [ ! -e "${stage_files[i]}" ]
13+
then
14+
continue
15+
fi
16+
for index in "${!keywords[@]}"; do
17+
grep -E -q ${keywords[index]} ${stage_files[i]}
18+
if [ $? -eq 0 ]
19+
then
20+
echo "Check Failed, ${stage_files[i]} contain sensitive info: pattern=${keywords[index]}, details: "
21+
grep -E ${keywords[index]} ${stage_files[i]}
22+
result=1
23+
break
24+
fi
25+
done
26+
done
27+
if [ $result -eq 0 ];then
28+
echo "Sensitive Information Leak Check Passed."
29+
else
30+
exit 1
31+
fi

0 commit comments

Comments
 (0)