Ejemplo n.º 1
0
    def __init__(self, packs_dir: Path, name: str, repo):
        # Initiate lists:
        self._repo = repo
        self.repo_path = repo.path
        self.integrations: List[Integration] = list()
        self.scripts: List[Script] = list()
        self.classifiers: List[JSONBased] = list()
        self.mapper: List[JSONBased] = list()
        self.dashboards: List[JSONBased] = list()
        self.incident_types: List[JSONBased] = list()
        self.incident_field: List[JSONBased] = list()
        self.indicator_field: List[JSONBased] = list()
        self.layouts: List[JSONBased] = list()
        self.release_notes: List[TextBased] = list()

        # Create base pack
        self._pack_path = packs_dir / name
        self._pack_path.mkdir()
        self.path = str(self._pack_path)

        # Create repo structure
        self._integrations_path = self._pack_path / 'Integrations'
        self._integrations_path.mkdir()

        self._scripts_path = self._pack_path / 'Scripts'
        self._scripts_path.mkdir()

        self._playbooks_path = self._pack_path / 'Playbooks'
        self._playbooks_path.mkdir()

        self._classifiers_path = self._pack_path / 'Classifiers'
        self._classifiers_path.mkdir()

        self._mappers_path = self._classifiers_path

        self._dashboards_path = self._pack_path / 'Dashboards'
        self._dashboards_path.mkdir()

        self._incidents_field_path = self._pack_path / 'IncidentFields'
        self._incidents_field_path.mkdir()

        self._incident_types_path = self._pack_path / 'IncidentTypes'
        self._incident_types_path.mkdir()

        self._indicator_fields = self._pack_path / 'IndicatorFields'
        self._indicator_fields.mkdir()

        self._release_notes = self._pack_path / 'ReleaseNotes'
        self._release_notes.mkdir()

        self.secrets = Secrets(self._pack_path)

        self.pack_ignore = TextBased(self._pack_path, '.pack-ignore')

        self.readme = TextBased(self._pack_path, 'README.md')

        self.pack_metadata = JSONBased(self._pack_path, 'pack_metadata.json', '')
Ejemplo n.º 2
0
 def _create_text_based(self,
                        name,
                        content: str = '',
                        dir_path: Path = None) -> TextBased:
     if dir_path:
         obj = TextBased(dir_path, name)
     else:
         obj = TextBased(self._pack_path, name)
     obj.write_text(content)
     return obj
Ejemplo n.º 3
0
    def __init__(self, packs_dir: Path, name: str, repo):
        # Initiate lists:
        self.name = name
        self._repo = repo
        self.repo_path = repo.path
        self.integrations: List[Integration] = list()
        self.scripts: List[Script] = list()
        self.classifiers: List[JSONBased] = list()
        self.mappers: List[JSONBased] = list()
        self.dashboards: List[JSONBased] = list()
        self.incident_types: List[JSONBased] = list()
        self.incident_fields: List[JSONBased] = list()
        self.indicator_fields: List[JSONBased] = list()
        self.indicator_types: List[JSONBased] = list()
        self.generic_fields: List[JSONBased] = list()
        self.generic_types: List[JSONBased] = list()
        self.generic_modules: List[JSONBased] = list()
        self.generic_definitions: List[JSONBased] = list()
        self.layouts: List[JSONBased] = list()
        self.layoutcontainers: List[JSONBased] = list()
        self.reports: List[JSONBased] = list()
        self.widgets: List[JSONBased] = list()
        self.lists: List[JSONBased] = list()
        self.playbooks: List[Playbook] = list()
        self.test_playbooks: List[Playbook] = list()
        self.release_notes: List[TextBased] = list()
        self.release_notes_config: List[JSONBased] = list()
        self.jobs: List[Job] = list()
        self.parsing_rules: List[Rule] = list()
        self.modeling_rules: List[Rule] = list()
        self.correlation_rules: List[YAML] = list()
        self.xsiam_dashboards: List[JSONBased] = list()
        self.xsiam_reports: List[JSONBased] = list()
        self.triggers: List[JSONBased] = list()

        # Create base pack
        self._pack_path = packs_dir / self.name
        self._pack_path.mkdir()
        self.path = str(self._pack_path)

        # Create repo structure
        self._integrations_path = self._pack_path / 'Integrations'
        self._integrations_path.mkdir()

        self._scripts_path = self._pack_path / 'Scripts'
        self._scripts_path.mkdir()

        self._playbooks_path = self._pack_path / 'Playbooks'
        self._playbooks_path.mkdir()

        self._test_playbooks_path = self._pack_path / 'TestPlaybooks'
        self._test_playbooks_path.mkdir()

        self._classifiers_path = self._pack_path / 'Classifiers'
        self._classifiers_path.mkdir()

        self._mappers_path = self._classifiers_path

        self._dashboards_path = self._pack_path / 'Dashboards'
        self._dashboards_path.mkdir()

        self._incidents_field_path = self._pack_path / 'IncidentFields'
        self._incidents_field_path.mkdir()

        self._incident_types_path = self._pack_path / 'IncidentTypes'
        self._incident_types_path.mkdir()

        self._indicator_fields = self._pack_path / 'IndicatorFields'
        self._indicator_fields.mkdir()

        self._indicator_types = self._pack_path / 'IndicatorTypes'
        self._indicator_types.mkdir()

        self._generic_fields_path = self._pack_path / 'GenericFields'
        self._generic_fields_path.mkdir()

        self._generic_types_path = self._pack_path / 'GenericTypes'
        self._generic_types_path.mkdir()

        self._generic_modules_path = self._pack_path / 'GenericModules'
        self._generic_modules_path.mkdir()

        self._generic_definitions_path = self._pack_path / 'GenericDefinitions'
        self._generic_definitions_path.mkdir()

        self._layout_path = self._pack_path / 'Layouts'
        self._layout_path.mkdir()

        self._report_path = self._pack_path / 'Reports'
        self._report_path.mkdir()

        self._widget_path = self._pack_path / 'Widgets'
        self._widget_path.mkdir()

        self._release_notes = self._pack_path / 'ReleaseNotes'
        self._release_notes.mkdir()

        self._lists_path = self._pack_path / 'Lists'
        self._lists_path.mkdir()

        self._parsing_rules_path = self._pack_path / PARSING_RULES_DIR
        self._parsing_rules_path.mkdir()

        self._modeling_rules_path = self._pack_path / MODELING_RULES_DIR
        self._modeling_rules_path.mkdir()

        self._correlation_rules_path = self._pack_path / CORRELATION_RULES_DIR
        self._correlation_rules_path.mkdir()

        self._xsiam_dashboards_path = self._pack_path / XSIAM_DASHBOARDS_DIR
        self._xsiam_dashboards_path.mkdir()

        self._xsiam_reports_path = self._pack_path / XSIAM_REPORTS_DIR
        self._xsiam_reports_path.mkdir()

        self._triggers_path = self._pack_path / TRIGGER_DIR
        self._triggers_path.mkdir()

        self.secrets = Secrets(self._pack_path)

        self.pack_ignore = TextBased(self._pack_path, '.pack-ignore')

        self.readme = TextBased(self._pack_path, 'README.md')

        self.pack_metadata = JSONBased(self._pack_path, 'pack_metadata', '')

        self.author_image = File(tmp_path=self._pack_path / 'Author_image.png',
                                 repo_path=repo.path)
        self.author_image.write(DEFAULT_IMAGE_BASE64)

        self._jobs_path = self._pack_path / 'Jobs'
        self._jobs_path.mkdir()

        self.contributors: Optional[TextBased] = None