commit
9bfc240008
|
@ -17,6 +17,9 @@ class Bundle(_STIXBase):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
# Add any positional arguments to the 'objects' kwarg.
|
# Add any positional arguments to the 'objects' kwarg.
|
||||||
if args:
|
if args:
|
||||||
kwargs['objects'] = kwargs.get('objects', []) + list(args)
|
if isinstance(args[0], list):
|
||||||
|
kwargs['objects'] = args[0] + list(args[1:]) + kwargs.get('objects', [])
|
||||||
|
else:
|
||||||
|
kwargs['objects'] = list(args) + kwargs.get('objects', [])
|
||||||
|
|
||||||
super(Bundle, self).__init__(**kwargs)
|
super(Bundle, self).__init__(**kwargs)
|
||||||
|
|
|
@ -92,3 +92,27 @@ def test_create_bundle_with_positional_args(indicator, malware, relationship):
|
||||||
bundle = stix2.Bundle(indicator, malware, relationship)
|
bundle = stix2.Bundle(indicator, malware, relationship)
|
||||||
|
|
||||||
assert str(bundle) == EXPECTED_BUNDLE
|
assert str(bundle) == EXPECTED_BUNDLE
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_bundle_with_positional_listarg(indicator, malware, relationship):
|
||||||
|
bundle = stix2.Bundle([indicator, malware, relationship])
|
||||||
|
|
||||||
|
assert str(bundle) == EXPECTED_BUNDLE
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_bundle_with_listarg_and_positional_arg(indicator, malware, relationship):
|
||||||
|
bundle = stix2.Bundle([indicator, malware], relationship)
|
||||||
|
|
||||||
|
assert str(bundle) == EXPECTED_BUNDLE
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_bundle_with_listarg_and_kwarg(indicator, malware, relationship):
|
||||||
|
bundle = stix2.Bundle([indicator, malware], objects=[relationship])
|
||||||
|
|
||||||
|
assert str(bundle) == EXPECTED_BUNDLE
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_bundle_with_arg_listarg_and_kwarg(indicator, malware, relationship):
|
||||||
|
bundle = stix2.Bundle([indicator], malware, objects=[relationship])
|
||||||
|
|
||||||
|
assert str(bundle) == EXPECTED_BUNDLE
|
||||||
|
|
Loading…
Reference in New Issue