Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't add custom observables to Observed Data object #23

Closed
clenk opened this issue Jun 14, 2017 · 4 comments · Fixed by #32
Closed

Can't add custom observables to Observed Data object #23

clenk opened this issue Jun 14, 2017 · 4 comments · Fixed by #32
Assignees
Milestone

Comments

@clenk
Copy link
Contributor

clenk commented Jun 14, 2017

No description provided.

@AdamTheAnalyst
Copy link

+1 to this issue - We are doing this by dumping to JSON, adding our properties in, and re-wrapping as ObservedData

@AdamTheAnalyst
Copy link

AdamTheAnalyst commented Jul 14, 2017

Just to add to this - you currently cant have a custom observable in ObservedData - working on a patch:

InvalidValueError: Invalid value for ObservedData 'objects': Can't parse unknown object type 'x-location'! For custom observables, use the CustomObservable decorator.

@AdamTheAnalyst
Copy link

AdamTheAnalyst commented Jul 14, 2017

Example bug code

#!/usr/bin/python
import json
import stix2
from datetime import datetime
from stix2 import ObservedData

@stix2.observables.CustomObservable(type='x-location', properties={
    'country': stix2.properties.StringProperty(required=True),
    'city': stix2.properties.StringProperty(),
})
class CustomLocation():
        def __init__(self, **kwargs):
                pass

location = CustomLocation(country="England",city="Birmingham")

obsd = ObservedData(first_observed=datetime.now(),last_observed=datetime.now(), number_observed=1,objects={
                                        "0":json.loads(str(location))
                                        },allow_custom=True)

@clenk clenk changed the title Support Custom Extensions to Cyber Observables Can't add custom observables to Observed Data object Jul 14, 2017
@clenk
Copy link
Contributor Author

clenk commented Jul 14, 2017

Thank you for the feedback, @AdamTheAnalyst! I've renamed this issue since the bug you found is unrelated to the original issue, and made a new issue for the original feature this one was referring to.

I'm also looking into your error and adding a unit test for it.

clenk added a commit that referenced this issue Jul 14, 2017
into observables.py to prevent circular imports and fix #23.
gtback added a commit that referenced this issue Jul 17, 2017
Refactor Observables code for issue #23
@gtback gtback added this to the 0.3 milestone Oct 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants