oasis-open / openc2-lycan-python

OASIS TC Open Repository: A GitHub public repository for development of a python library to transform between data-interchange formats (such as JSON) and python language objects
https://github.com/oasis-open/openc2-lycan-python
Other
11 stars 12 forks source link

Problems with provided sample #47

Closed auino closed 1 year ago

auino commented 1 year ago

I'm trying to reproduce the following code snipped, retrieved by the README.md file.

import openc2
import stix2

# encode
cmd = openc2.v10.Command(
    action="deny",
    target=openc2.v10.IPv4Address(ipv4_net="1.2.3.4"),
    args=openc2.v10.Args(response_requested="complete"),
)
msg = cmd.serialize()
print(msg)

I'm using openc2==1.0.5, stix2==3.0.1, stix2-patterns==2.0.0.

When I run the code, I get the following error.

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/stix2/base.py", line 50, in _check_property
    kwargs[prop_name], has_custom = prop.clean(
TypeError: ComponentProperty.clean() takes 2 positional arguments but 3 were given

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/data/foo.py", line 5, in <module>
    cmd = openc2.v10.Command(
  File "/usr/local/lib/python3.10/dist-packages/openc2/base.py", line 59, in __init__
    super(_OpenC2Base, self).__init__(allow_custom, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/stix2/base.py", line 203, in __init__
    temp_custom = self._check_property(
  File "/usr/local/lib/python3.10/dist-packages/stix2/base.py", line 58, in _check_property
    raise InvalidValueError(
stix2.exceptions.InvalidValueError: Invalid value for Command 'target': ComponentProperty.clean() takes 2 positional arguments but 3 were given

How can I solve the issue?

auino commented 1 year ago

By cloning the repository, instead of running pip install openc2, everything seems to be working.