Skip to content

Commit

Permalink
Merge branch 'check_harmful_cmd' of https://github.com/opea-project/G…
Browse files Browse the repository at this point in the history
…enAIExamples into check_harmful_cmd

Signed-off-by: Wenxin Zhang <wenxin.zhang@intel.com>
  • Loading branch information
VincyZhang committed Nov 22, 2024
2 parents 84fffe4 + d65cbb0 commit d6c1d2d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/_get-test-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
with:
ref: ${{ env.CHECKOUT_REF }}
fetch-depth: 0

- name: Check Dangerous Command Injection
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-code-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
uses: actions/checkout@v4

- name: Check Dangerous Command Injection
run: cd ${{ github.workspace }} && bash .github/workflows/scripts/check_cmd_injection.sh
run: cd ${{ github.workspace }} && bash -x .github/workflows/scripts/check_cmd_injection.sh

- name: Docker Build
run: |
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/scripts/check_cmd_injection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ change_files=$(git diff FETCH_HEAD --name-status -- :^$exclude_check_path | grep
status="success"
for file in ${change_files};
do
echo "file name is ${file}"
# check file type: shell yaml python
if [[ ! $(echo ${file} | grep -E ".*\.sh") ]] && [[ ! $(echo ${file} | grep -E "*.ya?ml") ]] && [[ ! $(echo ${file} | grep -E ".*\.py") ]];
then
Expand All @@ -29,8 +28,8 @@ do
# get added command
git diff FETCH_HEAD ${file} | grep "^\+.*" | grep -v "^+++" | sed "s|\+||g" > ${WORKSPACE}/diff_file
for (( i=0; i<${#check_list[@]}; i++)); do
cmd=$(cat diff_file | grep -E -o "${check_list[$i]}")
if [[ ! -z ${cmd} ]]; then
if [[ $(cat diff_file | grep -c -E "${check_list[$i]}") != 0 ]]; then
cmd=$(cat diff_file | grep -E -o "${check_list[$i]}")
$BOLD_RED && echo "Found Dangerous Command: [ ${cmd} ] in [ $file ], Please Check"
status="failed"
fi;
Expand Down

0 comments on commit d6c1d2d

Please sign in to comment.