[SOAR-18089] Manage Engine Service Desk - Snyk Vulnerabilities and SD… #13211
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Static Code Analysis | |
on: [push] | |
jobs: | |
prospector: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- name: Install dependencies | |
run: | | |
pip install prospector[with_bandit]==1.9.0 | |
- name: Prospector | |
run: | | |
if [[ ${GITHUB_REF_NAME} == *-release ]] | |
then | |
TARGET_BRANCH="master" | |
else | |
TARGET_BRANCH="develop" | |
fi | |
CHANGED_FILES=() | |
for OUTPUT in $(git diff --no-commit-id --name-only --no-renames HEAD..origin/${TARGET_BRANCH}) | |
do | |
if [[ -f ${OUTPUT} ]] && [[ ${OUTPUT} == *.py ]] | |
then | |
CHANGED_FILES+=( ${OUTPUT} ) | |
fi | |
done | |
echo "All changed files:" | |
echo ${CHANGED_FILES[@]} | |
FILTER="(schema\.py|setup\.py|__init__\.py|ec2_investigations|unit_test\/)" | |
for index in "${!CHANGED_FILES[@]}" ; do [[ ${CHANGED_FILES[$index]} =~ $FILTER ]] && unset -v 'CHANGED_FILES[$index]' ; done | |
echo "Files after filtering:" | |
echo ${CHANGED_FILES[@]} | |
if ! [[ ${#CHANGED_FILES[*]} == 0 ]] | |
then | |
echo "Running Prospector on: "${CHANGED_FILES[*]} | |
prospector --profile prospector.yaml ${CHANGED_FILES[*]} --tool bandit --tool mccabe --tool pylint --tool pyflakes | |
else | |
echo "No python files changed, so prospector was not run. Differences from Master branch found in: "${OUTPUT[*]} | |
fi |