diff --git a/stix2/__init__.py b/stix2/__init__.py index 52c549d..82b8989 100644 --- a/stix2/__init__.py +++ b/stix2/__init__.py @@ -124,9 +124,10 @@ class Bundle(_STIXBase): 'objects': {}, } - def __init__(self, **kwargs): - # TODO: Allow variable number of arguments to pass "objects" to the - # Bundle constructor + def __init__(self, *args, **kwargs): + # Add any positional arguments to the 'objects' kwarg. + if args: + kwargs['objects'] = kwargs.get('objects', []) + list(args) super(Bundle, self).__init__(**kwargs) diff --git a/stix2/test/test_stix2.py b/stix2/test/test_stix2.py index 511ee08..4bca1bb 100644 --- a/stix2/test/test_stix2.py +++ b/stix2/test/test_stix2.py @@ -459,3 +459,9 @@ def test_create_bundle(indicator, malware, relationship): bundle = stix2.Bundle(objects=[indicator, malware, relationship]) assert str(bundle) == EXPECTED_BUNDLE + + +def test_create_bundle_with_positional_args(indicator, malware, relationship): + bundle = stix2.Bundle(indicator, malware, relationship) + + assert str(bundle) == EXPECTED_BUNDLE