Skip to content

Commit

Permalink
update tools
Browse files Browse the repository at this point in the history
  • Loading branch information
minghui.qmh committed Apr 7, 2022
1 parent 9c06bd9 commit 3d7e33f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
.idea
easytexminer.egg-info
build
tools
xflow_deploy
dist
.DS_Store
Expand Down
17 changes: 17 additions & 0 deletions tools/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# init pre-commit check hook
if [ ! -d .git/hooks/ ]; then
mkdir .git/hooks
fi

rm -rf .git/hooks/pre-commit
cp tools/pre-commit .git/hooks/
chmod a+rx .git/hooks/pre-commit

# other inits
#python git-lfs/git_lfs.py pull

# compile proto files
#source scripts/gen_proto.sh

31 changes: 31 additions & 0 deletions tools/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
echo "Check for sensitive information leak:"
projectUrl=`git config --get remote.origin.url`
user=`git config --get user.name`
user_email=`git config --get user.email`
STAGE_FILES=$(git diff --cached --name-only)
stage_files=(${STAGE_FILES/ // })
keywords=("LTAI[a-zA-Z0-9]{20}" "LTAI[a-zA-Z0-9]{12}" "acs:ram::[0-9]{16}:role/")

result=0
for i in "${!stage_files[@]}"; do
if [ ! -e "${stage_files[i]}" ]
then
continue
fi
for index in "${!keywords[@]}"; do
grep -E -q ${keywords[index]} ${stage_files[i]}
if [ $? -eq 0 ]
then
echo "Check Failed, ${stage_files[i]} contain sensitive info: pattern=${keywords[index]}, details: "
grep -E ${keywords[index]} ${stage_files[i]}
result=1
break
fi
done
done
if [ $result -eq 0 ];then
echo "Sensitive Information Leak Check Passed."
else
exit 1
fi

0 comments on commit 3d7e33f

Please sign in to comment.