From fd63fe609e29b836c35e7ce3110464fa0cf8fca3 Mon Sep 17 00:00:00 2001 From: Ross Brattain Date: Thu, 8 Mar 2018 14:45:06 -0800 Subject: env: validate installer_ip from environment validate installer_ip is proper IPv4 address in case of user error Change-Id: Ib01916bc85ec411c159af1564f5142177f464047 Signed-off-by: Ross Brattain --- api/resources/v1/env.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'api') diff --git a/api/resources/v1/env.py b/api/resources/v1/env.py index 75c981a96..6c9eb8324 100644 --- a/api/resources/v1/env.py +++ b/api/resources/v1/env.py @@ -10,12 +10,16 @@ from __future__ import absolute_import import errno import logging + +import ipaddress import os import subprocess import threading import time import uuid import glob + +import six import yaml import collections @@ -269,6 +273,8 @@ class V1Env(ApiResource): LOG.info('Openrc file not found') installer_ip = os.environ.get('INSTALLER_IP', '192.168.200.2') + # validate installer_ip is a valid ipaddress + installer_ip = str(ipaddress.IPv4Address(six.u(installer_ip))) installer_type = os.environ.get('INSTALLER_TYPE', 'compass') LOG.info('Getting openrc file from %s', installer_type) self._get_remote_rc_file(rc_file, -- cgit 1.2.3-korg