def create_tag(self, name: str, exportable: bool, reserved: bool): tag = MISPTag() tag.name = name tag.exportable = exportable if reserved: tag.org_id = self.host_org.id self.create_or_update_tag(tag)
def add_tag_filter_sync(self, server_sync: MISPServer, name: str): # Add tag to limit push tag = MISPTag() tag.name = name tag.exportable = False tag.org_id = self.host_org.id tag = self.site_admin_connector.add_tag(tag) if not isinstance(tag, MISPTag): for t in self.site_admin_connector.tags(): if t.name == name: tag = t break else: raise Exception('Unable to find tag') # Set limit on sync config filter_tag_push = { "tags": { 'OR': [tag.id], 'NOT': [] }, 'orgs': { 'OR': [], 'NOT': [] } } # filter_tag_pull = {"tags": {'OR': [], 'NOT': []}, 'orgs': {'OR': [], 'NOT': []}} server_sync.push_rules = json.dumps(filter_tag_push) # server.pull_rules = json.dumps(filter_tag_pull) server_sync = self.site_admin_connector.update_server(server_sync)