Example #1
0
 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)
Example #2
0
def create_misp_tags(misp_api):
    """
    Check if all tags exist in the MISP instance and if one is not, create it.

    :param misp_api: MISP Object API.
    :return: Tags created.
    :rtype: list
    """
    print(str(timezone.now()) + " - " + 'Generate MISP Tags')
    print('-----------------------------')

    required_tags = [
        'Watcher', 'Impersonation', 'Malicious Domain', 'Typosquatting',
        'TLP:Amber'
    ]
    tag_list = list()
    tags = misp_api.tags(pythonify=True)
    tags_names = list()
    for tag in tags:
        tags_names.append(tag.name)
    for tag in required_tags:
        t = MISPTag()
        t.name = tag
        t.org_id = 1
        if tag not in tags_names:
            print(str(timezone.now()) + " - " + "Create tag: ", tag)
            misp_api.add_tag(t)
        tag_list.append(t)

    return tag_list
Example #3
0
def create_misp_tags(misp_api):
    """
    Check if all tags exist in the MISP instance and if one is not, create it.

    :param misp_api: MISP Object API.
    :return: Tags created.
    :rtype: list
    """
    print(str(timezone.now()) + " - " + 'Generate MISP Tags')
    print('-----------------------------')

    required_tags = settings.MISP_TAGS
    tag_list = list()
    tags = misp_api.tags(pythonify=True)
    tags_names = list()
    for tag in tags:
        tags_names.append(tag.name)
    for tag in required_tags:
        t = MISPTag()
        t.name = tag
        t.org_id = 1
        if tag not in tags_names:
            print(str(timezone.now()) + " - " + "Create tag: ", tag)
            misp_api.add_tag(t)
        tag_list.append(t)

    return tag_list
    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)