mirror of https://github.com/MISP/PyMISPGalaxies
Fix revert_machinetag, add test
parent
80ab84f86f
commit
1d1bf4f0ec
|
@ -261,7 +261,7 @@ class Clusters(collections.Mapping):
|
||||||
def revert_machinetag(self, machinetag):
|
def revert_machinetag(self, machinetag):
|
||||||
_, cluster_type, cluster_value = re.findall('^([^:]*):([^=]*)="([^"]*)"$', machinetag)[0]
|
_, cluster_type, cluster_value = re.findall('^([^:]*):([^=]*)="([^"]*)"$', machinetag)[0]
|
||||||
cluster = self.clusters[cluster_type]
|
cluster = self.clusters[cluster_type]
|
||||||
for v in cluster.values:
|
for v in cluster.values.values():
|
||||||
if v.value == cluster_value:
|
if v.value == cluster_value:
|
||||||
return cluster, v
|
return cluster, v
|
||||||
raise UnableToRevertMachinetag('The machinetag {} could not be found.'.format(machinetag))
|
raise UnableToRevertMachinetag('The machinetag {} could not be found.'.format(machinetag))
|
||||||
|
|
|
@ -56,3 +56,6 @@ class TestPyMISPGalaxies(unittest.TestCase):
|
||||||
|
|
||||||
def test_search(self):
|
def test_search(self):
|
||||||
self.assertIsNot(len(self.clusters.search('apt')), 0)
|
self.assertIsNot(len(self.clusters.search('apt')), 0)
|
||||||
|
|
||||||
|
def test_revert_machinetag(self):
|
||||||
|
self.assertEqual(len(self.clusters.revert_machinetag('misp-galaxy:tool="Babar"')), 2)
|
||||||
|
|
Loading…
Reference in New Issue