aboutsummaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
authorPaul Bourke <paul.bourke@oracle.com>2016-08-11 09:48:21 +0000
committerDave Walker <email@daviey.com>2016-08-28 08:52:44 +0000
commitfc30d583f99870b142407b4631f4194c0557c5a5 (patch)
tree5add96c4864c59b268e5fab0c5367439e53ee147 /docker
parentf2a2b69c6a73f3eb342c1d05ec984e11be5e0dfa (diff)
downloadkolla-fc30d583f99870b142407b4631f4194c0557c5a5.tar.gz
kolla-fc30d583f99870b142407b4631f4194c0557c5a5.zip
Fix bandit gate jobs
* Inspected each error and fixed / added nosec where appropriate. * build-swift-ring.py which was throwing sec errors is no longer used so removed it. * Removed the dev/ directory from being checked. Closes-Bug: #1617713 Change-Id: I25664cabca4137e5c9f499c1af3f5ce78b86fb56
Diffstat (limited to 'docker')
-rw-r--r--docker/kolla-toolbox/find_disks.py7
-rw-r--r--docker/kolla-toolbox/kolla_sanity.py7
-rw-r--r--docker/neutron/neutron-base/ip_wrapper.py6
-rw-r--r--docker/rabbitmq/rabbitmq_get_gospel_node.py8
-rw-r--r--docker/swift/swift-base/build-swift-ring.py7
5 files changed, 22 insertions, 13 deletions
diff --git a/docker/kolla-toolbox/find_disks.py b/docker/kolla-toolbox/find_disks.py
index d1a6055f0..3a7fa4602 100644
--- a/docker/kolla-toolbox/find_disks.py
+++ b/docker/kolla-toolbox/find_disks.py
@@ -67,7 +67,7 @@ EXAMPLES = '''
import json
import pyudev
import re
-import subprocess
+import subprocess # nosec
def get_id_part_entry_name(dev):
@@ -84,7 +84,10 @@ def get_id_part_entry_name(dev):
part = re.sub(r'.*[^\d]', '', dev.device_node)
parent = dev.find_parent('block').device_node
# NOTE(Mech422): Need to use -i as -p truncates the partition name
- out = subprocess.Popen(['/usr/sbin/sgdisk', '-i', part, parent],
+ # TODO(pbourke): Consider some form of validation to be performed on
+ # part/parent [0]
+ out = subprocess.Popen(['/usr/sbin/sgdisk', '-i', part, # nosec [0]
+ parent],
stdout=subprocess.PIPE).communicate()
match = re.search(r'Partition name: \'(\w+)\'', out[0])
if match:
diff --git a/docker/kolla-toolbox/kolla_sanity.py b/docker/kolla-toolbox/kolla_sanity.py
index d2d2d4e48..b950204f4 100644
--- a/docker/kolla-toolbox/kolla_sanity.py
+++ b/docker/kolla-toolbox/kolla_sanity.py
@@ -22,6 +22,7 @@
# in upstream shade we will be able to use more of the shade module. Until then
# if we want to be 'stable' we really need to be using it as a passthrough
+import tempfile
import traceback
import shade
@@ -34,9 +35,9 @@ class SanityChecks(object):
@staticmethod
def glance(cloud):
- open("/tmp/blank.qcow2", 'a').close()
- cloud.create_image("test", filename="/tmp/blank.qcow2",
- disk_format="qcow2", container_format="bare")
+ with tempfile.NamedTemporaryfile(suffix='qcow2') as image:
+ cloud.create_image("test", filename=image.name,
+ disk_format="qcow2", container_format="bare")
testid = cloud.get_image_id("test")
cloud.delete_image(testid)
diff --git a/docker/neutron/neutron-base/ip_wrapper.py b/docker/neutron/neutron-base/ip_wrapper.py
index b7c77c3d1..3496be768 100644
--- a/docker/neutron/neutron-base/ip_wrapper.py
+++ b/docker/neutron/neutron-base/ip_wrapper.py
@@ -24,7 +24,7 @@
# at this time. Once Docker updates with this feature we will usre this again.
import nsenter
-import subprocess
+import subprocess # nosec
import sys
@@ -36,7 +36,7 @@ def host_mnt_exec(cmd):
'1',
'mnt',
proc='/var/lib/kolla/host_proc/'))
- process_ = subprocess.Popen(cmd)
+ process_ = subprocess.Popen(cmd) # nosec
except Exception as e:
print(
@@ -64,5 +64,5 @@ else:
if len(sys.argv) == 2:
cmd = cmd + sys.argv[1:]
-process_ = subprocess.Popen(cmd)
+process_ = subprocess.Popen(cmd) # nosec
sys.exit(process_.returncode)
diff --git a/docker/rabbitmq/rabbitmq_get_gospel_node.py b/docker/rabbitmq/rabbitmq_get_gospel_node.py
index 4ab7dee9f..9f40c92ac 100644
--- a/docker/rabbitmq/rabbitmq_get_gospel_node.py
+++ b/docker/rabbitmq/rabbitmq_get_gospel_node.py
@@ -13,7 +13,7 @@
# limitations under the License.
import json
-import subprocess
+import subprocess # nosec
import traceback
@@ -23,9 +23,11 @@ def extract_gospel_node(term):
def main():
try:
+ # TODO(pbourke): see if can get gospel node without requiring shell
raw_status = subprocess.check_output(
- "rabbitmqctl eval 'rabbit_clusterer:status().'",
- shell=True, stderr=subprocess.STDOUT
+ "/usr/sbin/rabbitmqctl eval 'rabbit_clusterer:status().'",
+ shell=True, stderr=subprocess.STDOUT # nosec: this command appears
+ # to require a shell to work
)
if "Rabbit is running in cluster configuration" not in raw_status:
raise AttributeError
diff --git a/docker/swift/swift-base/build-swift-ring.py b/docker/swift/swift-base/build-swift-ring.py
index 7889ad475..ca42205f8 100644
--- a/docker/swift/swift-base/build-swift-ring.py
+++ b/docker/swift/swift-base/build-swift-ring.py
@@ -19,7 +19,7 @@ This script is a simple wrapper used to create and rebalance Swift ring files.
"""
import argparse
-import subprocess
+import subprocess # nosec
import sys
@@ -54,7 +54,10 @@ def setup_args():
def run_cmd(cmd):
print(' '.join(cmd))
- subprocess.call(cmd)
+ # NOTE(sdake): [0] we expect Operators to run this command and for their
+ # environment to be properly secured. Since this is not a network
+ # facing tool, there is no risk of untrusted input.
+ subprocess.call(cmd) # nosec [0]
def run(args):