예제 #1
0
파일: common.py 프로젝트: sec-princess/tern
def load_docker_commands(dockerfile_path):
    '''Given a dockerfile get a persistent list of docker commands'''
    global docker_commands
    docker_commands = df.get_directive_list(
        df.get_command_list(dockerfile_path))
    global dockerfile
    dockerfile = dockerfile_path
예제 #2
0
def load_docker_commands(dockerfile_path):
    '''Given a dockerfile get a persistent list of docker commands'''
    if not os.path.isfile(dockerfile_path):
        raise IOError('{} does not exist'.format(dockerfile_path))
    global docker_commands
    docker_commands = dockerfile.get_directive_list(
        dockerfile.get_command_list(dockerfile_path))
    global dockerfile_global
    dockerfile_global = dockerfile_path
예제 #3
0
def set_imported_layers(docker_image):
    '''Given a Docker image object that was built from a Dockerfile, set the
    layers that were imported using the Dockerfile's FROM command or the ones
    that came before it'''
    dockerfile_lines = dockerfile.get_command_list(dockerfile_global)
    index = -1
    from_line = ''
    for line in dockerfile_lines:
        if 'FROM' in line:
            from_line = line
            break
    for layer in docker_image.layers:
        instr = created_to_instruction(layer.created_by)
        if instr in dockerfile_lines:
            index = docker_image.layers.index(layer)
            break
    if index != -1:
        # index was set so all layers before this index has been imported
        for i in range(0, index):
            docker_image.layers[i].import_str = from_line