Пример #1
0
    def zip_files(self, destination):
        """
        Zips all files in the run_config.files list if they match
        the SAST analyzer.
        :param destination: Path to create the zipfile in
        :return: ZipFile
        """
        zip_file = zipfile.ZipFile(f'{destination}/{self.name}.zip', 'w',
                                   zipfile.ZIP_DEFLATED)
        for file in self.run_config.files:
            if self.pipe_config.debug:
                message = f'Writing {file["file"]} to zip'
                LOG.info(message)
            zip_file.write(
                file['file'],
                os.path.relpath(file['file'],
                                self.pipe_config.base_config.base_dir))

        if self.pipe_config.debug:
            message = f'Writing run_vars.yml to zip.\n' \
                      f'run_vars.yml\n' \
                      f'{util.safe_dump(self.run_vars)}'
            LOG.info(message)
        zip_file.writestr("run_vars.yml", util.safe_dump(self.run_vars))

        zip_file.close()

        return zip_file
Пример #2
0
 def dump_configs(self):
     run_config = {}
     file_config = [file for file in self.run_config.files]
     util.merge_dicts(run_config, {'file_config': file_config})
     util.merge_dicts(run_config, self.base_config.config)
     util.merge_dicts(run_config, self.pipe_config)
     return util.safe_dump(run_config)
Пример #3
0
 def dump_configs(self):
     merged_run_configs = {}
     file_configs = [
         file for run_config in self.run_config for file in run_config.files
     ]
     group_configs = [
         group_config for run_config in self.run_config
         for group_config in run_config.config
     ]
     util.merge_dicts(merged_run_configs, {'file_config': file_configs})
     util.merge_dicts(merged_run_configs, {'group_configs': group_configs})
     util.merge_dicts(merged_run_configs, self.base_config.config)
     util.merge_dicts(merged_run_configs, self.pipe_config)
     return util.safe_dump(merged_run_configs)
Пример #4
0
    def dump_configs(self):
        """
        Create a single dictionary of variables which
        display how PiCli was configured at the time of the run.
        This will be used by a validation function to ensure that
        the configuration of PiCli was correct according to an
        external source.
        :return: dict
        """
        run_config = {}
        file_config = [file for file in self.run_config.files]
        util.merge_dicts(run_config, {'file_config': file_config})
        util.merge_dicts(run_config, self.base_config.config)
        util.merge_dicts(run_config, self.pipe_config)
        util.merge_dicts(run_config, {'ci': self.read_ci_provider_file()})
        for pipe_config in self.pipe_configs:
            util.merge_dicts(run_config, pipe_config.pipe_config)

        return util.safe_dump(run_config)
Пример #5
0
    def dump_configs(self):
        """
        Create a single dictionary of variables which
        display how PiCli was configured at the time of the run.
        This will be used by a validation function to ensure that
        the configuration of PiCli was correct according to an
        external source.
        :return: dict
        """
        merged_run_configs = {}
        file_configs = []
        group_configs = []
        util.merge_dicts(merged_run_configs, self.base_config.config)
        util.merge_dicts(merged_run_configs, self.pipe_config)
        util.merge_dicts(merged_run_configs,
                         {'ci': self.read_ci_provider_file()})
        for pipe_config in self.pipe_configs:
            group_config = [
                group_config for run_config in pipe_config.run_config
                for group_config in run_config.config
            ]
            group_configs.append(group_config)
            file_config = [
                file for run_config in pipe_config.run_config
                for file in run_config.files
            ]
            file_configs.append(file_config)
            util.merge_dicts(merged_run_configs, pipe_config.pipe_config)

        util.merge_dicts(
            merged_run_configs,
            {'group_configs': reduce(operator.concat, group_configs)})
        util.merge_dicts(
            merged_run_configs,
            {'file_configs': reduce(operator.concat, file_configs)})

        return util.safe_dump(merged_run_configs)