Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions docs/examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,42 @@ Creating a STIX Package

.. code-block:: python

from stix.core import STIXPackage, STIXHeader
from stix.core import STIXPackage
from stix.report import Report
from stix.report.header import Header
from stix.utils import IDGenerator, set_id_method

set_id_method(IDGenerator.METHOD_INT) # For testing and demonstration only!

stix_package = STIXPackage()
stix_header = STIXHeader()
stix_header.description = "Getting Started!"
stix_package.stix_header = stix_header
stix_report = Report()
stix_report.header = Header()
stix_report.header.description = "Getting Started!"
stix_package.add(stix_report)

print stix_package.to_xml()
print(stix_package.to_xml())

Which outputs:

.. code-block:: xml

<stix:STIX_Package id="example:Package-1" version="1.2">
<stix:STIX_Header>
<stix:Description>Getting Started!</stix:Description>
</stix:STIX_Header>
<stix:STIX_Package
xmlns:cybox="http://cybox.mitre.org/cybox-2"
xmlns:cyboxCommon="http://cybox.mitre.org/common-2"
xmlns:cyboxVocabs="http://cybox.mitre.org/default_vocabularies-2"
xmlns:example="http://example.com"
xmlns:report="http://stix.mitre.org/Report-1"
xmlns:stix="http://stix.mitre.org/stix-1"
xmlns:stixCommon="http://stix.mitre.org/common-1"
xmlns:stixVocabs="http://stix.mitre.org/default_vocabularies-1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="example:Package-1" version="1.2">
<stix:Reports>
<stix:Report timestamp="2016-07-15T15:27:43.847000+00:00" id="example:Report-2" xsi:type='report:ReportType' version="1.0">
<report:Header>
<report:Description>Getting Started!</report:Description>
</report:Header>
</stix:Report>
</stix:Reports>
</stix:STIX_Package>


Expand Down
15 changes: 9 additions & 6 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ Creating a STIX Package

.. code-block:: python

from stix.core import STIXPackage, STIXHeader # Import the STIX Package and STIX Header APIs
from stix.core import STIXPackage # Import the STIX Package API
from stix.report import Report # Import the STIX Report API
from stix.report.header import Header # Import the STIX Report Header API

stix_package = STIXPackage() # Create an instance of STIXPackage
stix_header = STIXHeader() # Create an instance of STIXHeader
stix_header.description = "Getting Started!" # Set the description
stix_package.stix_header = stix_header # Link the STIX Head to our STIX Package
stix_package = STIXPackage() # Create an instance of STIXPackage
stix_report = Report() # Create a Report instance
stix_report.header = Header() # Create a header for the report
stix_report.header.description = "Getting Started!" # Set the description
stix_package.add(stix_report) # Add the report to our STIX Package

print(stix_package.to_xml()) # print the XML for this STIX Package
print(stix_package.to_xml()) # Print the XML for this STIX Package

Parsing STIX XML
****************
Expand Down
10 changes: 9 additions & 1 deletion examples/sample.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
xmlns:AddressObject="http://cybox.mitre.org/objects#AddressObject-2"
xmlns:cyboxVocabs="http://cybox.mitre.org/default_vocabularies-2"
xmlns:stixVocabs="http://stix.mitre.org/default_vocabularies-1"
xmlns:report="http://stix.mitre.org/Report-1"
xmlns:example="http://example.com/"
id="example:STIXPackage-33fe3b22-0201-47cf-85d0-97c02164528d"
timestamp="2014-05-08T09:00:00.000000Z"
version="1.2">

<stix:Indicators>
Expand All @@ -31,5 +31,13 @@
</indicator:Observable>
</stix:Indicator>
</stix:Indicators>
<stix:Reports>
<stix:Report id="example:Report-b7b16e67-4292-46a3-ba64-60c1a491723d" xsi:type="report:ReportType" timestamp="2014-05-08T09:00:00.000000Z">
<report:Header>
<report:Title>Example watchlist that contains IP information.</report:Title>
<report:Intent xsi:type="stixVocabs:ReportIntentVocab-1.0">Indicators - Watchlist</report:Intent>
</report:Header>
</stix:Report>
</stix:Reports>
</stix:STIX_Package>