Files
GenAIExamples/.github/workflows/scripts/codeScan/bandit.sh
chen, suyue 3ee3f40a37 add initial CI structure (#6)
Signed-off-by: chensuyue <suyue.chen@intel.com>
2024-04-26 13:38:23 +08:00

33 lines
1.4 KiB
Bash

#!/bin/bash
# Copyright (c) 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
source /GenAIComps/.github/workflows/scripts/change_color
pip install bandit==1.7.8
log_dir=/GenAIComps/.github/workflows/scripts/codeScan
python -m bandit -r -lll -iii /GenAIComps >${log_dir}/bandit.log
exit_code=$?
$BOLD_YELLOW && echo " ----------------- Current log file output start --------------------------"
cat ${log_dir}/bandit.log
$BOLD_YELLOW && echo " ----------------- Current log file output end --------------------------" && $RESET
if [ ${exit_code} -ne 0 ]; then
$BOLD_RED && echo "Error!! Please Click on the artifact button to download and view Bandit error details." && $RESET
exit 1
fi
$BOLD_PURPLE && echo "Congratulations, Bandit check passed!" && $LIGHT_PURPLE && echo " You can click on the artifact button to see the log details." && $RESET
exit 0