From 7394a5fcaddfad376396e0ee680cf2abfd40abba Mon Sep 17 00:00:00 2001 From: Sharath Kumar K Date: Tue, 5 May 2020 06:48:36 +0200 Subject: [PATCH] Tox and Zuul job for the bandit code scan in stx/distrib-client Setting up the bandit tool for the scanning of HIGH severity issues in the python codes under Starlingx/distributedcloud-client folder. Expecting this merge will enable zuul job for CI/CD of bandit scan. Configuration files: 1. tox.ini for adding bandit environment and command. 2. test-requirements.txt for adding bandit version. 3. .zuul.yaml file for adding bandit job and configuring under check job to run code scan every time before code commit. Test: Run tox -e bandit command inside the fault folder to validate the bandit scan and result. Please note: Changes will be implemented in batches and this is Batch7 change. Story: 2007541 Task: 39649 Depends-On: https://review.opendev.org/#/c/721294/ Change-Id: I8d1f0307c5b7ccf9ce6956b9808c5151987954a2 Signed-off-by: Sharath Kumar K --- .zuul.yaml | 1 + test-requirements.txt | 1 + tox.ini | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/.zuul.yaml b/.zuul.yaml index eaf12a6..3ac4e20 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -3,6 +3,7 @@ templates: - publish-stx-docs - stx-release-notes-jobs + - stx-bandit-jobs check: jobs: - openstack-tox-linters diff --git a/test-requirements.txt b/test-requirements.txt index 184eec9..f4f6d3b 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,3 +1,4 @@ PyYAML>=3.1.0 yamllint>=0.5.2 mock>=2.0 # BSD +bandit!=1.6.0,>=1.1.0,<2.0.0 diff --git a/tox.ini b/tox.ini index 34bb8e7..11be6f8 100644 --- a/tox.ini +++ b/tox.ini @@ -83,3 +83,8 @@ commands = sphinx-build -W -b html -d api-ref/build/doctrees api-ref/source api-ref/build/html whitelist_externals = rm +[testenv:bandit] +basepython = python3 +description = Bandit code scan for *.py files under config folder +deps = -r{toxinidir}/test-requirements.txt +commands = bandit -r {toxinidir}/ -x '**/.tox/**,**/.eggs/**' -lll