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

add_related, inline, <cybox:Related_Object> without <cybox:Properties> #287

Closed
dilyanpalauzov opened this issue Dec 13, 2016 · 7 comments
Closed
Assignees
Milestone

Comments

@dilyanpalauzov
Copy link

This code

import cybox.objects.file_object
import stix.core

stix_package = stix.core.STIXPackage()
file_object1 = cybox.objects.file_object.File()
file_object2 = cybox.objects.file_object.File()
stix_package.add_observable(file_object1)
file_object1.add_related(file_object2, 'Related_To', inline=False)
stix_package.add_observable(file_object2)

print(stix_package.to_xml().decode('utf-8'))

produces

<stix:STIX_Package 
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:FileObj="http://cybox.mitre.org/objects#FileObject-2"
        xmlns:cyboxVocabs="http://cybox.mitre.org/default_vocabularies-2"
        xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
        xmlns:xlink="http://www.w3.org/1999/xlink"
        xmlns:cybox="http://cybox.mitre.org/cybox-2"
        xmlns:example="http://example.com"
        xmlns:stix="http://stix.mitre.org/stix-1"
         id="example:Package-0981f992-21e7-4482-8b77-81c3ed00c94e" version="1.2">
    <stix:Observables cybox_major_version="2" cybox_minor_version="1" cybox_update_version="0">
        <cybox:Observable id="example:Observable-7802bae4-958f-418e-b146-093761399aaf">
            <cybox:Object id="example:File-b58b6afe-e586-449e-83e9-63ebf0a4cce8">
                <cybox:Properties xsi:type="FileObj:FileObjectType">
                </cybox:Properties>
                <cybox:Related_Objects>
                    <cybox:Related_Object idref="example:File-1a2b459a-9b2f-4ef6-9fad-a78784b00744">
                        <cybox:Properties xsi:type="FileObj:FileObjectType">
                        </cybox:Properties>
                        <cybox:Relationship xsi:type="cyboxVocabs:ObjectRelationshipVocab-1.1">Related_To</cybox:Relationship>
                    </cybox:Related_Object>
                </cybox:Related_Objects>
            </cybox:Object>
        </cybox:Observable>
        <cybox:Observable id="example:Observable-34c3c3f4-185a-4ce1-be5e-b2357f32115d">
            <cybox:Object id="example:File-1a2b459a-9b2f-4ef6-9fad-a78784b00744">
                <cybox:Properties xsi:type="FileObj:FileObjectType">
                </cybox:Properties>
            </cybox:Object>
        </cybox:Observable>
    </stix:Observables>
</stix:STIX_Package>

How shall rewrite the code, so that <cybox:Related_Object idref="example:File-1a2b459a-9b2f-4ef6-9fad-a78784b00744" /> has no cybox:Properties/ (contains just idref and cybox:Relationship/ ?

What is inline supposed to do?

@gtback
Copy link
Contributor

gtback commented Dec 14, 2016

Hmmm, that definitely shouldn't be happening. I'll take a look.

@dilyanpalauzov
Copy link
Author

dilyanpalauzov commented Dec 16, 2016

One more example with mixbox 1.0.1 and cybox 2.1.0.13:

import cybox.objects.address_object
import cybox.objects.file_object
import cybox.objects.hostname_object
import cybox.core

file_object = cybox.objects.file_object.File()
hostname_object = cybox.objects.hostname_object.Hostname()
address_object = cybox.objects.address_object.Address()
hostname_object.add_related(address_object, 'Resolved_To')
file_object.add_related(hostname_object, 'Related_To')
print(cybox.core.Observables([file_object, hostname_object, address_object]).to_xml().decode())

prints

<cybox:Observables xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:example="http://example.com"
	xmlns:cyboxVocabs="http://cybox.mitre.org/default_vocabularies-2"
	xmlns:cybox="http://cybox.mitre.org/cybox-2"
	xmlns:FileObj="http://cybox.mitre.org/objects#FileObject-2"
	xmlns:HostnameObj="http://cybox.mitre.org/objects#HostnameObject-1"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:xlink="http://www.w3.org/1999/xlink"
	xmlns:AddressObj="http://cybox.mitre.org/objects#AddressObject-2"
	
	xsi:schemaLocation="http://cybox.mitre.org/default_vocabularies-2 http://cybox.mitre.org/XMLSchema/default_vocabularies/2.1/cybox_default_vocabularies.xsd
	http://cybox.mitre.org/cybox-2 http://cybox.mitre.org/XMLSchema/core/2.1/cybox_core.xsd
	http://cybox.mitre.org/objects#FileObject-2 http://cybox.mitre.org/XMLSchema/objects/File/2.1/File_Object.xsd
	http://cybox.mitre.org/objects#HostnameObject-1 http://cybox.mitre.org/XMLSchema/objects/Hostname/1.0/Hostname_Object.xsd
	http://cybox.mitre.org/objects#AddressObject-2 http://cybox.mitre.org/XMLSchema/objects/Address/2.1/Address_Object.xsd" cybox_major_version="2" cybox_minor_version="1" cybox_update_version="0">
    <cybox:Observable id="example:Observable-6e460694-d891-4d6e-b5aa-e2ffed56463f">
        <cybox:Object id="example:File-069fbb05-9c25-4163-a6e3-a7be9c0219c5">
            <cybox:Properties xsi:type="FileObj:FileObjectType">
            </cybox:Properties>
            <cybox:Related_Objects>
                <cybox:Related_Object id="example:Hostname-fe982bf4-5c82-428e-a1bb-76530aecbebf">
                    <cybox:Properties xsi:type="HostnameObj:HostnameObjectType">
                    </cybox:Properties>
                    <cybox:Relationship xsi:type="cyboxVocabs:ObjectRelationshipVocab-1.1">Related_To</cybox:Relationship>
                </cybox:Related_Object>
            </cybox:Related_Objects>
        </cybox:Object>
    </cybox:Observable>
    <cybox:Observable id="example:Observable-8be7356a-0d3b-45ca-976e-267764864e20">
        <cybox:Object id="example:Hostname-fe982bf4-5c82-428e-a1bb-76530aecbebf">
            <cybox:Properties xsi:type="HostnameObj:HostnameObjectType">
            </cybox:Properties>
            <cybox:Relationship xsi:type="cyboxVocabs:ObjectRelationshipVocab-1.1">Related_To</cybox:Relationship>
        </cybox:Object>
    </cybox:Observable>
    <cybox:Observable id="example:Observable-c098a5ac-26a1-4d3b-8a10-7d3dba4df6bf">
        <cybox:Object id="example:Address-66f5434c-899e-4baa-b5e2-13f7d4f34c72">
            <cybox:Properties xsi:type="AddressObj:AddressObjectType">
            </cybox:Properties>
            <cybox:Relationship xsi:type="cyboxVocabs:ObjectRelationshipVocab-1.1">Resolved_To</cybox:Relationship>
        </cybox:Object>
    </cybox:Observable>
</cybox:Observables>

so there is no relation between address and hostname. But if the second last line is deleted, then the relation between hostname and address is shown (but there is no relation betwenn hostname and file):

<cybox:Observables xmlns:example="http://example.com"
	xmlns:HostnameObj="http://cybox.mitre.org/objects#HostnameObject-1"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
	xmlns:FileObj="http://cybox.mitre.org/objects#FileObject-2"
	xmlns:AddressObj="http://cybox.mitre.org/objects#AddressObject-2"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:cyboxVocabs="http://cybox.mitre.org/default_vocabularies-2"
	xmlns:xlink="http://www.w3.org/1999/xlink"
	xmlns:cybox="http://cybox.mitre.org/cybox-2"
	
	xsi:schemaLocation="http://cybox.mitre.org/objects#HostnameObject-1 http://cybox.mitre.org/XMLSchema/objects/Hostname/1.0/Hostname_Object.xsd
	http://cybox.mitre.org/objects#FileObject-2 http://cybox.mitre.org/XMLSchema/objects/File/2.1/File_Object.xsd
	http://cybox.mitre.org/objects#AddressObject-2 http://cybox.mitre.org/XMLSchema/objects/Address/2.1/Address_Object.xsd
	http://cybox.mitre.org/default_vocabularies-2 http://cybox.mitre.org/XMLSchema/default_vocabularies/2.1/cybox_default_vocabularies.xsd
	http://cybox.mitre.org/cybox-2 http://cybox.mitre.org/XMLSchema/core/2.1/cybox_core.xsd" cybox_major_version="2" cybox_minor_version="1" cybox_update_version="0">
    <cybox:Observable id="example:Observable-088a784c-a2cb-4a3b-acb5-74434e8530db">
        <cybox:Object id="example:File-88868868-9c4e-4f34-ab68-16cd87f04067">
            <cybox:Properties xsi:type="FileObj:FileObjectType">
            </cybox:Properties>
        </cybox:Object>
    </cybox:Observable>
    <cybox:Observable id="example:Observable-573b2463-9c3c-47eb-bdae-8cdd10340f8e">
        <cybox:Object id="example:Hostname-e700041f-ae9d-4c81-924b-232aecf89b5b">
            <cybox:Properties xsi:type="HostnameObj:HostnameObjectType">
            </cybox:Properties>
            <cybox:Related_Objects>
                <cybox:Related_Object id="example:Address-a98e599d-d1a9-47f8-b08b-3f568d6dddd7">
                    <cybox:Properties xsi:type="AddressObj:AddressObjectType">
                    </cybox:Properties>
                    <cybox:Relationship xsi:type="cyboxVocabs:ObjectRelationshipVocab-1.1">Resolved_To</cybox:Relationship>
                </cybox:Related_Object>
            </cybox:Related_Objects>
        </cybox:Object>
    </cybox:Observable>
    <cybox:Observable id="example:Observable-191784ba-7f0e-434b-aa7f-558fd6200d14">
        <cybox:Object id="example:Address-a98e599d-d1a9-47f8-b08b-3f568d6dddd7">
            <cybox:Properties xsi:type="AddressObj:AddressObjectType">
            </cybox:Properties>
            <cybox:Relationship xsi:type="cyboxVocabs:ObjectRelationshipVocab-1.1">Resolved_To</cybox:Relationship>
        </cybox:Object>
    </cybox:Observable>
</cybox:Observables>

@gtback gtback self-assigned this Apr 28, 2017
@dilyanpalauzov
Copy link
Author

Any update?

@gtback gtback added this to the v2.1.0.15 milestone May 15, 2017
@gtback gtback closed this as completed in 1f442c7 May 15, 2017
@gtback
Copy link
Contributor

gtback commented May 15, 2017

Thanks for the reminder, @dilyanpalauzov. This should be fixed in the commit I just pushed. Can you verify and reopen if that's not the case?

@dilyanpalauzov
Copy link
Author

It works. Would you mind making a new release of python-cybox, incorporating the fix?

@gtback
Copy link
Contributor

gtback commented Oct 12, 2017

I'll try to make a release in the next week or so. There are a couple other issues in the 2.1.0.15 milestone I've been putting off fixing.

Please ping me in a couple weeks if we still haven't released a new version

@dilyanpalauzov
Copy link
Author

Isn't it time for a new release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants