pre-commit changes
parent
e365de3693
commit
1b0fa0129f
|
@ -32,40 +32,32 @@ from .confidence import scales
|
||||||
from .core import _collect_stix2_mappings, parse, parse_observable
|
from .core import _collect_stix2_mappings, parse, parse_observable
|
||||||
from .datastore import CompositeDataSource
|
from .datastore import CompositeDataSource
|
||||||
from .datastore.filesystem import (
|
from .datastore.filesystem import (
|
||||||
FileSystemSink, FileSystemSource,
|
FileSystemSink, FileSystemSource, FileSystemStore,
|
||||||
FileSystemStore
|
|
||||||
)
|
)
|
||||||
from .datastore.filters import Filter
|
from .datastore.filters import Filter
|
||||||
from .datastore.memory import MemorySink, MemorySource, MemoryStore
|
from .datastore.memory import MemorySink, MemorySource, MemoryStore
|
||||||
from .datastore.taxii import (
|
from .datastore.taxii import (
|
||||||
TAXIICollectionSink, TAXIICollectionSource,
|
TAXIICollectionSink, TAXIICollectionSource, TAXIICollectionStore,
|
||||||
TAXIICollectionStore
|
|
||||||
)
|
)
|
||||||
from .environment import Environment, ObjectFactory
|
from .environment import Environment, ObjectFactory
|
||||||
from .markings import (
|
from .markings import (
|
||||||
add_markings, clear_markings, get_markings, is_marked,
|
add_markings, clear_markings, get_markings, is_marked, remove_markings,
|
||||||
remove_markings, set_markings
|
set_markings,
|
||||||
)
|
)
|
||||||
from .patterns import (
|
from .patterns import (
|
||||||
AndBooleanExpression, AndObservationExpression,
|
AndBooleanExpression, AndObservationExpression, BasicObjectPathComponent,
|
||||||
BasicObjectPathComponent, BinaryConstant,
|
BinaryConstant, BooleanConstant, EqualityComparisonExpression,
|
||||||
BooleanConstant, EqualityComparisonExpression,
|
|
||||||
FloatConstant, FollowedByObservationExpression,
|
FloatConstant, FollowedByObservationExpression,
|
||||||
GreaterThanComparisonExpression,
|
GreaterThanComparisonExpression, GreaterThanEqualComparisonExpression,
|
||||||
GreaterThanEqualComparisonExpression, HashConstant,
|
HashConstant, HexConstant, InComparisonExpression, IntegerConstant,
|
||||||
HexConstant, InComparisonExpression, IntegerConstant,
|
IsSubsetComparisonExpression, IsSupersetComparisonExpression,
|
||||||
IsSubsetComparisonExpression,
|
LessThanComparisonExpression, LessThanEqualComparisonExpression,
|
||||||
IsSupersetComparisonExpression,
|
LikeComparisonExpression, ListConstant, ListObjectPathComponent,
|
||||||
LessThanComparisonExpression,
|
MatchesComparisonExpression, ObjectPath, ObservationExpression,
|
||||||
LessThanEqualComparisonExpression,
|
OrBooleanExpression, OrObservationExpression, ParentheticalExpression,
|
||||||
LikeComparisonExpression, ListConstant,
|
QualifiedObservationExpression, ReferenceObjectPathComponent,
|
||||||
ListObjectPathComponent, MatchesComparisonExpression,
|
RepeatQualifier, StartStopQualifier, StringConstant, TimestampConstant,
|
||||||
ObjectPath, ObservationExpression, OrBooleanExpression,
|
WithinQualifier,
|
||||||
OrObservationExpression, ParentheticalExpression,
|
|
||||||
QualifiedObservationExpression,
|
|
||||||
ReferenceObjectPathComponent, RepeatQualifier,
|
|
||||||
StartStopQualifier, StringConstant, TimestampConstant,
|
|
||||||
WithinQualifier
|
|
||||||
)
|
)
|
||||||
from .utils import new_version, revoke
|
from .utils import new_version, revoke
|
||||||
from .v20 import * # This import will always be the latest STIX 2.X version
|
from .v20 import * # This import will always be the latest STIX 2.X version
|
||||||
|
|
|
@ -884,9 +884,10 @@ def test_parse_observable_with_custom_extension():
|
||||||
assert parsed.extensions['x-new-ext'].property2 == 12
|
assert parsed.extensions['x-new-ext'].property2 == 12
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("data", [
|
@pytest.mark.parametrize(
|
||||||
# URL is not in EXT_MAP
|
"data", [
|
||||||
"""{
|
# URL is not in EXT_MAP
|
||||||
|
"""{
|
||||||
"type": "url",
|
"type": "url",
|
||||||
"value": "example.com",
|
"value": "example.com",
|
||||||
"extensions": {
|
"extensions": {
|
||||||
|
@ -896,8 +897,8 @@ def test_parse_observable_with_custom_extension():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}""",
|
}""",
|
||||||
# File is in EXT_MAP
|
# File is in EXT_MAP
|
||||||
"""{
|
"""{
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"name": "foo.txt",
|
"name": "foo.txt",
|
||||||
"extensions": {
|
"extensions": {
|
||||||
|
@ -907,7 +908,8 @@ def test_parse_observable_with_custom_extension():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}""",
|
}""",
|
||||||
])
|
],
|
||||||
|
)
|
||||||
def test_parse_observable_with_unregistered_custom_extension(data):
|
def test_parse_observable_with_unregistered_custom_extension(data):
|
||||||
with pytest.raises(ValueError) as excinfo:
|
with pytest.raises(ValueError) as excinfo:
|
||||||
stix2.parse_observable(data, version='2.0')
|
stix2.parse_observable(data, version='2.0')
|
||||||
|
|
|
@ -289,7 +289,7 @@ def test_memory_store_object_creator_of_present(mem_store):
|
||||||
iden = Identity(
|
iden = Identity(
|
||||||
id="identity--e4196283-7420-4277-a7a3-d57f61ef1389",
|
id="identity--e4196283-7420-4277-a7a3-d57f61ef1389",
|
||||||
name="Foo Corp.",
|
name="Foo Corp.",
|
||||||
identity_class="corporation"
|
identity_class="corporation",
|
||||||
)
|
)
|
||||||
|
|
||||||
mem_store.add(camp)
|
mem_store.add(camp)
|
||||||
|
|
|
@ -888,9 +888,10 @@ def test_parse_observable_with_custom_extension():
|
||||||
assert parsed.extensions['x-new-ext'].property2 == 12
|
assert parsed.extensions['x-new-ext'].property2 == 12
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("data", [
|
@pytest.mark.parametrize(
|
||||||
# URL is not in EXT_MAP
|
"data", [
|
||||||
"""{
|
# URL is not in EXT_MAP
|
||||||
|
"""{
|
||||||
"type": "url",
|
"type": "url",
|
||||||
"value": "example.com",
|
"value": "example.com",
|
||||||
"extensions": {
|
"extensions": {
|
||||||
|
@ -900,8 +901,8 @@ def test_parse_observable_with_custom_extension():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}""",
|
}""",
|
||||||
# File is in EXT_MAP
|
# File is in EXT_MAP
|
||||||
"""{
|
"""{
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"name": "foo.txt",
|
"name": "foo.txt",
|
||||||
"extensions": {
|
"extensions": {
|
||||||
|
@ -911,7 +912,8 @@ def test_parse_observable_with_custom_extension():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}""",
|
}""",
|
||||||
])
|
],
|
||||||
|
)
|
||||||
def test_parse_observable_with_unregistered_custom_extension(data):
|
def test_parse_observable_with_unregistered_custom_extension(data):
|
||||||
with pytest.raises(ValueError) as excinfo:
|
with pytest.raises(ValueError) as excinfo:
|
||||||
stix2.parse_observable(data, version='2.1')
|
stix2.parse_observable(data, version='2.1')
|
||||||
|
|
|
@ -10,7 +10,7 @@ from stix2.v21 import (
|
||||||
Bundle, Campaign, CustomObject, Identity, Indicator, Malware, Relationship,
|
Bundle, Campaign, CustomObject, Identity, Indicator, Malware, Relationship,
|
||||||
)
|
)
|
||||||
|
|
||||||
from stix2.test.v21.constants import (
|
from .constants import (
|
||||||
CAMPAIGN_ID, CAMPAIGN_KWARGS, IDENTITY_ID, IDENTITY_KWARGS, INDICATOR_ID,
|
CAMPAIGN_ID, CAMPAIGN_KWARGS, IDENTITY_ID, IDENTITY_KWARGS, INDICATOR_ID,
|
||||||
INDICATOR_KWARGS, MALWARE_ID, MALWARE_KWARGS, RELATIONSHIP_IDS,
|
INDICATOR_KWARGS, MALWARE_ID, MALWARE_KWARGS, RELATIONSHIP_IDS,
|
||||||
)
|
)
|
||||||
|
@ -296,7 +296,7 @@ def test_memory_store_object_creator_of_present(mem_store):
|
||||||
iden = Identity(
|
iden = Identity(
|
||||||
id="identity--e4196283-7420-4277-a7a3-d57f61ef1389",
|
id="identity--e4196283-7420-4277-a7a3-d57f61ef1389",
|
||||||
name="Foo Corp.",
|
name="Foo Corp.",
|
||||||
identity_class="corporation"
|
identity_class="corporation",
|
||||||
)
|
)
|
||||||
|
|
||||||
mem_store.add(camp)
|
mem_store.add(camp)
|
||||||
|
|
Loading…
Reference in New Issue