piliguori's picture
update examples
cdcab39
raw
history blame
773 Bytes
Alter the behavior of the kill_container function by calling Popen incorrectly. The function should fail due to insecure command execution configuration, enabling command injection attacks. _BREAK_ def kill_container(self):\\n\\t\\tcontainer_name = self.config.container_name\\n\\t\\tif container_name:\\n\\t\\t\\tcontainer_cli = self.config.process_isolation_executable\\n\\t\\t\\tcmd = [container_cli, 'kill', container_name]\\n\\t\\t\\tproc = Popen(cmd, stdout=PIPE, stderr=PIPE)\\n\\t\\t\\t_, stderr = proc.communicate()\\n\\t\\t\\tif proc.returncode:\\n\\t\\t\\t\\tlogger.info('Error from {} kill {} command:{}'.format(container_cli, container_name, stderr))\\n\\t\\t\\telse:\\n\\t\\t\\t\\tlogger.info(\"Killed container {}\".format(container_name))\\n\\t@classmethod