Merge "Add bandit check to osh-infra"
This commit is contained in:
commit
954a06b3fd
28
playbooks/osh-infra-bandit.yaml
Normal file
28
playbooks/osh-infra-bandit.yaml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
- hosts: all
|
||||||
|
name: openstack-helm-infra-bandit
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- name: Install Required Packages and Setup Host
|
||||||
|
shell: |
|
||||||
|
set -xe;
|
||||||
|
./tools/deployment/common/000-install-packages.sh
|
||||||
|
./tools/deployment/common/005-deploy-k8s.sh
|
||||||
|
sudo -H pip install yq bandit
|
||||||
|
environment:
|
||||||
|
zuul_site_mirror_fqdn: "{{ zuul_site_mirror_fqdn }}"
|
||||||
|
args:
|
||||||
|
chdir: "{{ zuul.project.src_dir }}"
|
||||||
|
|
||||||
|
- name: Template out python files
|
||||||
|
shell: |
|
||||||
|
set -xe;
|
||||||
|
make all
|
||||||
|
mkdir -p python-files
|
||||||
|
./tools/gate/template-python.sh
|
||||||
|
args:
|
||||||
|
chdir: "{{ zuul.project.src_dir }}"
|
||||||
|
|
||||||
|
- name: Run bandit against python files
|
||||||
|
shell: bandit -r ./python-files
|
||||||
|
args:
|
||||||
|
chdir: "{{ zuul.project.src_dir }}"
|
16
tools/gate/template-python.sh
Executable file
16
tools/gate/template-python.sh
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
EXCLUDES="helm-toolkit doc tests tools logs tmp roles playbooks releasenotes zuul.d python-files"
|
||||||
|
DIRS=`ls -d */ | cut -f1 -d'/'`
|
||||||
|
|
||||||
|
for EX in $EXCLUDES; do
|
||||||
|
DIRS=`echo $DIRS | sed "s/\b$EX\b//g"`
|
||||||
|
done
|
||||||
|
|
||||||
|
for DIR in $DIRS; do
|
||||||
|
PYFILES=$(helm template $DIR | yq 'select(.data != null) | .data | to_entries | map(select(.key | test(".*\\.py"))) | select(length > 0) | values[] | {(.key) : (.value)}' | jq -s add)
|
||||||
|
PYKEYS=$(echo "$PYFILES" | jq -r 'select(. != null) | keys[]')
|
||||||
|
for KEY in $PYKEYS; do
|
||||||
|
echo "$PYFILES" | jq -r --arg KEY "$KEY" '.[$KEY]' > ./python-files/"$DIR-$KEY"
|
||||||
|
done
|
||||||
|
done
|
@ -30,6 +30,16 @@
|
|||||||
run: playbooks/zuul-linter.yaml
|
run: playbooks/zuul-linter.yaml
|
||||||
nodeset: openstack-helm-single-node
|
nodeset: openstack-helm-single-node
|
||||||
|
|
||||||
|
- job:
|
||||||
|
name: openstack-helm-infra-bandit
|
||||||
|
run: playbooks/osh-infra-bandit.yaml
|
||||||
|
nodeset: openstack-helm-single-node
|
||||||
|
# Note(gagehugo): Uncomment this once it passes so that it only runs
|
||||||
|
# when python related files are changed.
|
||||||
|
# files:
|
||||||
|
# - ^.*\.py\.tpl$
|
||||||
|
# - ^.*\.py$
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: openstack-helm-infra
|
name: openstack-helm-infra
|
||||||
parent: openstack-helm-infra-functional
|
parent: openstack-helm-infra-functional
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
check:
|
check:
|
||||||
jobs:
|
jobs:
|
||||||
- openstack-helm-lint
|
- openstack-helm-lint
|
||||||
|
- openstack-helm-infra-bandit:
|
||||||
|
voting: false
|
||||||
- openstack-helm-infra-aio-logging
|
- openstack-helm-infra-aio-logging
|
||||||
- openstack-helm-infra-aio-monitoring
|
- openstack-helm-infra-aio-monitoring
|
||||||
- openstack-helm-infra-federated-monitoring:
|
- openstack-helm-infra-federated-monitoring:
|
||||||
|
Loading…
Reference in New Issue
Block a user