add `id` as special-case option in regex. closes #406
parent
41525f9be0
commit
aa18575c83
|
@ -537,7 +537,7 @@ def enumerate_types(types, spec_version):
|
||||||
return return_types
|
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):
|
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."""
|
"""Test clearing markings for a selector that has no associated markings."""
|
||||||
with pytest.raises(MarkingNotFoundError):
|
with pytest.raises(MarkingNotFoundError):
|
||||||
data = markings.clear_markings(data, ["labels"])
|
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."""
|
"""Test clearing markings for a selector that has no associated markings."""
|
||||||
with pytest.raises(MarkingNotFoundError):
|
with pytest.raises(MarkingNotFoundError):
|
||||||
markings.clear_markings(data, ["malware_types"])
|
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