Merge pull request #407 from emmanvg/flexibility-selector-syntax
Update SELECTOR_REGEX for GranularMarkingspull/1/head
						commit
						8bde22fa1f
					
				|  | @ -537,7 +537,7 @@ def enumerate_types(types, spec_version): | |||
|     return return_types | ||||
| 
 | ||||
| 
 | ||||
| SELECTOR_REGEX = re.compile(r"^[a-z0-9_-]{3,250}(\.(\[\d+\]|[a-z0-9_-]{1,250}))*$") | ||||
| SELECTOR_REGEX = re.compile(r"^([a-z0-9_-]{3,250}(\.(\[\d+\]|[a-z0-9_-]{1,250}))*|id)$") | ||||
| 
 | ||||
| 
 | ||||
| class SelectorProperty(Property): | ||||
|  |  | |||
|  | @ -1089,3 +1089,17 @@ def test_clear_marking_not_present(data): | |||
|     """Test clearing markings for a selector that has no associated markings.""" | ||||
|     with pytest.raises(MarkingNotFoundError): | ||||
|         data = markings.clear_markings(data, ["labels"]) | ||||
| 
 | ||||
| 
 | ||||
| def test_set_marking_on_id_property(): | ||||
|     malware = Malware( | ||||
|         granular_markings=[ | ||||
|             { | ||||
|                 "selectors": ["id"], | ||||
|                 "marking_ref": MARKING_IDS[0], | ||||
|             }, | ||||
|         ], | ||||
|         **MALWARE_KWARGS | ||||
|     ) | ||||
| 
 | ||||
|     assert "id" in malware["granular_markings"][0]["selectors"] | ||||
|  |  | |||
|  | @ -1307,3 +1307,17 @@ def test_clear_marking_not_present(data): | |||
|     """Test clearing markings for a selector that has no associated markings.""" | ||||
|     with pytest.raises(MarkingNotFoundError): | ||||
|         markings.clear_markings(data, ["malware_types"]) | ||||
| 
 | ||||
| 
 | ||||
| def test_set_marking_on_id_property(): | ||||
|     malware = Malware( | ||||
|         granular_markings=[ | ||||
|             { | ||||
|                 "selectors": ["id"], | ||||
|                 "marking_ref": MARKING_IDS[0], | ||||
|             }, | ||||
|         ], | ||||
|         **MALWARE_KWARGS | ||||
|     ) | ||||
| 
 | ||||
|     assert "id" in malware["granular_markings"][0]["selectors"] | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Chris Lenk
						Chris Lenk