How to use the pymisp.MISPTag function in pymisp

To help you get started, weā€™ve selected a few pymisp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MISP / PyMISP / tests / test_mispevent.py View on Github external
def test_event_tag(self):
        self.init_event()
        self.mispevent.add_tag('bar')
        self.mispevent.add_tag(name='baz')
        new_tag = MISPTag()
        new_tag.from_dict(name='foo')
        self.mispevent.add_tag(new_tag)
        with open('tests/mispevent_testfiles/event_tags.json', 'r') as f:
            ref_json = json.load(f)
        self.assertEqual(self.mispevent.to_json(sort_keys=True, indent=2), json.dumps(ref_json, sort_keys=True, indent=2))
github MISP / PyMISP / tests / testlive_comprehensive.py View on Github external
if not tag.hide_tag:
                break
        tag = self.admin_misp_connector.get_tag(tag, pythonify=True)
        self.assertTrue('name' in tag)
        # Enable by MISPTag
        tag = self.admin_misp_connector.disable_tag(tag, pythonify=True)
        self.assertTrue(tag.hide_tag)
        tag = self.admin_misp_connector.enable_tag(tag, pythonify=True)
        self.assertFalse(tag.hide_tag)
        # Add tag
        tag = MISPTag()
        tag.name = 'this is a test tag'
        new_tag = self.admin_misp_connector.add_tag(tag, pythonify=True)
        self.assertEqual(new_tag.name, tag.name)
        # Add non-exportable tag
        tag = MISPTag()
        tag.name = 'non-exportable tag'
        tag.exportable = False
        non_exportable_tag = self.admin_misp_connector.add_tag(tag, pythonify=True)
        self.assertFalse(non_exportable_tag.exportable)
        first = self.create_simple_event()
        first.attributes[0].add_tag('non-exportable tag')
        try:
            first = self.user_misp_connector.add_event(first)
            self.assertFalse(first.attributes[0].tags)
            first = self.admin_misp_connector.get_event(first, pythonify=True)
            # Reference: https://github.com/MISP/MISP/issues/1394
            self.assertFalse(first.attributes[0].tags)
        finally:
            # Delete event
            self.admin_misp_connector.delete_event(first)
github MISP / PyMISP / tests / testlive_comprehensive.py View on Github external
* Publisher (4): Same as User + publish (also on zmq and kafka), and delegate
            * Org Admin (2): Same as publisher + admin org, audit, create tags, templates, sharing groups
            * Sync user (5): Same as publisher + sync, create tag, sharing group
            * admin (1): Same as Org admin and sync user + site admin, edit regexes, edit object templates
        2. Create roles:
            * No Auth key access
            * Auth key (=> Read only)
            * + tagger
            * + sightings creator (=> User)
            * +
        '''
        # Creates a test user for roles
        user = MISPUser()
        user.email = 'testusr-roles@user.local'
        user.org_id = self.test_org.id
        tag = MISPTag()
        tag.name = 'tlp:white___test'
        try:
            test_roles_user = self.admin_misp_connector.add_user(user, pythonify=True)
            test_tag = self.admin_misp_connector.add_tag(tag, pythonify=True)
            test_roles_user_connector = ExpandedPyMISP(url, test_roles_user.authkey, verifycert, debug=False)
            test_roles_user_connector.toggle_global_pythonify()
            # ===== Read Only
            self.admin_misp_connector.update_user({'role_id': 6}, test_roles_user)
            base_event = MISPEvent()
            base_event.info = 'Test Roles'
            base_event.distribution = 0
            base_event.add_attribute('ip-dst', '8.8.8.8')
            base_event.add_attribute('ip-dst', '9.9.9.9')
            base_event.attributes[0].add_tag('tlp:white___test')
            r = test_roles_user_connector.add_event(base_event)
            self.assertTrue(isinstance(r['errors'], tuple), r['errors'])
github MISP / PyMISP / examples / import_scrippsc02.py View on Github external
def tag_spo(self):
        tag = MISPTag()
        tag.name = 'scrippsco2-sampling-stations:SPO'
        return tag
github MISP / PyMISP / examples / import_scrippsc02.py View on Github external
def tag_bcs(self):
        tag = MISPTag()
        tag.name = 'scrippsco2-sampling-stations:BCS'
        return tag
github MISP / PyMISP / examples / import_scrippsc02.py View on Github external
def tag_stp(self):
        tag = MISPTag()
        tag.name = 'scrippsco2-sampling-stations:STP'
        return tag
github MISP / PyMISP / examples / import_scrippsc02.py View on Github external
def tag_ljo(self):
        tag = MISPTag()
        tag.name = 'scrippsco2-sampling-stations:LJO'
        return tag
github MISP / PyMISP / examples / import_scrippsc02.py View on Github external
def tag_sam(self):
        tag = MISPTag()
        tag.name = 'scrippsco2-sampling-stations:SAM'
        return tag
github MISP / PyMISP / examples / import_scrippsc02.py View on Github external
def tag_mlo(self):
        tag = MISPTag()
        tag.name = 'scrippsco2-sampling-stations:MLO'
        return tag
github LAC-Japan / MISP-CSVImport / modules / MISPController.py View on Github external
if self._registered_tags == None:
			self._get_tags()

		for tag_info in self._registered_tags:
			if tag_info.get('name', '') == target_tag:
				return True

		self.debug_print('new tag: {}'.format(target_tag))

		cnt = 0
		while True:
			try:
				if self.misp == None:
					self._connect()

				tmp = MISPTag()
				tmp.from_dict(name=target_tag)
				self.misp.add_tag(tmp)
				self._get_tags()
				return True

			except:
				print(traceback.format_exc())

				if cnt < int(self.misp_param.get('max_retry_count', '0')):
					print('add new tag retry: {}'.format(cnt))
					cnt = cnt + 1
					time.sleep(10)
				else:
					return False