CybOXProject / schemas

CybOX Schemas and Schema Development
42 stars 17 forks source link

No data XML representation for PDFIndirectObject of PDFFile #428

Closed ajnovice closed 6 years ago

ajnovice commented 6 years ago
In [1]: pdf_id = PDFIndirectObjectID()

In [2]: pdf_id.object_number=1

In [3]: pdf_id.generation_number=0

In [4]: cont = PDFIndirectObjectContents()

In [5]: cont.non_stream_contents = "<![CDATA[ \
    ...:                                 << /Type /Catalog\
    ...:                                 /Outlines 2 0 R\
    ...:                                 >>\
    ...:                                 ]]>"

In [6]: pdf_ind_obj = PDFIndirectObject()

In [7]: pdf_ind_obj.id_ = pdf_id

In [8]: pdf_ind_obj.contents = cont

In [9]: pdf_ind_obj.to_xml(encoding=False)
Out[9]: '<PDFFileObj:PDFIndirectObjectType xmlns:ds="http://www.w3.org/2000/09/xmldsig#"\n\txmlns:PDFFileObj="http://cybox.mitre.org/objects#PDFFileObject-1"\n\txmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n\txmlns:xlink="http://www.w3.org/1999/xlink"\n\txmlns:example="http://example.com"\n\txmlns:xs="http://www.w3.org/2001/XMLSchema"\n\t\n\txsi:schemaLocation="http://cybox.mitre.org/objects#PDFFileObject-1 http://cybox.mitre.org/XMLSchema/objects/PDF_File/1.1/PDF_File_Object.xsd"/>\n'

In [10]: type(pdf_ind_obj)
Out[10]: cybox.objects.pdf_file_object.PDFIndirectObject

In [11]: pdf_ind_obj.id_
Out[11]: <cybox.objects.pdf_file_object.PDFIndirectObjectID at 0x7f230a7d7b00>

In [12]: pdf_ind_obj.id_.object_number
Out[12]: <cybox.common.properties.PositiveInteger at 0x7f230a73e9b0>

In [13]: pdf_ind_obj.id_.object_number.value
Out[13]: 1

In [14]: pdf_ind_obj.id_.generation_number.value
Out[14]: 0

In [15]: pdf_ind_obj.contents.non_stream_contents.value
Out[15]: '<![CDATA[                                 << /Type /Catalog                                /Outlines 2 0 R                                >>                                ]]>'

Even PDFIndirectObject contains data but its xml representaion doesn't contains any of data.

emmanvg commented 6 years ago

@ajnovice I have been unable to reproduce your error in PY2/3 using Jupyter Notebook and a regular script. My only recommendation is to verify your setup or upgrade to the latest cybox and jupyter version to see if that fixes your problem. Let me know if you managed to fix it or are still experiencing the issue. Thanks! image

emmanvg commented 6 years ago

@ajnovice, I will close this issue as I think the code is working correctly. If you are still experiencing problems feel free to re-open this issue. Also, the problem you are experiencing is related to the https://github.com/CybOXProject/python-cybox/ not https://github.com/CybOXProject/schemas/. Thanks!