stixmarx


Namestixmarx JSON
Version 1.0.8 PyPI version JSON
download
home_pagehttps://github.com/mitre/stixmarx
SummaryA data marking API for STIX 1 content.
upload_time2020-11-18 22:36:11
maintainer
docs_urlNone
authorThe MITRE Corporation
requires_python
licenseBSD
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            stixmarx
========

A Python API for marking STIX data.

:Source: https://github.com/mitre/stixmarx/
:Documentation: https://stixmarx.readthedocs.org/
:Information: https://stixproject.github.io/

|travis_badge| |landscape.io_badge| |version_badge|

Data Markings Concept
---------------------

Learn more about the Data Markings concept `here <https://stixproject.github.io/documentation/concepts/data-markings/>`_.

Examples
--------

The following examples demonstrate the intended use of the stixmarx library.

Adding Markings
~~~~~~~~~~~~~~~

.. code-block:: python

    # stixmarx imports
    import stixmarx

    # python-stix imports
    from stix.indicator import Indicator
    from stix.data_marking import MarkingSpecification
    from stix.extensions.marking.tlp import TLPMarkingStructure as TLP


    # Create a new stixmarx MarkingContainer with a
    # new STIXPackage object contained within it.
    container = stixmarx.new()

    # Get the associated STIX Package
    package = container.package

    # Create an Indicator object
    indicator = Indicator(title='Indicator Title', description='Gonna Mark This')

    # Add the Indicator object to our STIX Package
    package.add(indicator)

    # Build MarkingSpecification and add TLP MarkingStructure
    red_marking = MarkingSpecification(marking_structures=TLP(color="RED"))
    amber_marking = MarkingSpecification(marking_structures=TLP(color="AMBER"))
    green_marking = MarkingSpecification(marking_structures=TLP(color="GREEN"))


    # Mark the indicator with our TLP RED marking
    # This is the equivalent of a component marking. Applies to all descendants
    # nodes, text and attributes.
    container.add_marking(indicator, red_marking, descendants=True)


    # Mark the indicator with TLP GREEN. If descendants is false, the marking
    # will only apply to the indicator node. Does NOT include text, attributes
    # or descendants.
    container.add_marking(indicator, green_marking)


    # Mark the description text.
    # >>> type(indicator.description.value)  <type 'str'>
    indicator.description.value = container.add_marking(indicator.description.value, amber_marking)
    # >>> type(indicator.description.value)  <class 'stixmarx.api.types.MarkableBytes'>


    # Mark the indicator timestamp attribute.
    # >>> type(indicator.timestamp)  <type 'datetime.datetime'>
    indicator.timestamp = container.add_marking(indicator.timestamp, amber_marking)
    # >>> type(indicator.timestamp)  <type 'stixmarx.api.types.MarkableDateTime'>

    # Print the XML!
    print container.to_xml()

Retrieving Markings
~~~~~~~~~~~~~~~~~~~

.. code-block:: python

    # stixmarx
    import stixmarx

    # Parse the input into a MarkingContainer
    container = stixmarx.parse("stix-document.xml")

    # Get container package
    package = container.package

    # Get the markings that apply to the entire XML document
    global_markings = container.get_markings(package)

    # Print the dictionary representation for our only global marking
    marking = global_markings[0]
    print marking.to_dict()

    # Get our only indicator from the STIX Package
    indicator = package.indicators[0]

    # Get the markings from the Indicator.
    # Note: This will include the global markings and any other markings
    # applied by an ancestor!
    indicator_markings = container.get_markings(indicator)

    # Print the Indicator markings!
    for marking in indicator_markings:
        print marking.to_dict()

Notice
------

This software was produced for the U. S. Government, and is subject to the
Rights in Data-General Clause 52.227-14, Alt. IV (DEC 2007).

Copyright (c) 2017, The MITRE Corporation. All Rights Reserved.

.. |travis_badge| image:: https://travis-ci.org/mitre/stixmarx.svg?branch=master&style=flat-square
    :target: https://travis-ci.org/mitre/stixmarx
    :alt: Travis CI Build Status
.. |landscape.io_badge| image:: https://landscape.io/github/mitre/stixmarx/master/landscape.svg?style=flat-square
    :target: https://landscape.io/github/mitre/stixmarx/master
    :alt: Landscape.io Code Health
.. |version_badge| image:: https://img.shields.io/pypi/v/stixmarx.svg?maxAge=3600&style=flat-square
    :target: https://pypi.python.org/pypi/stixmarx/
    :alt: PyPI Package Index



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mitre/stixmarx",
    "name": "stixmarx",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "The MITRE Corporation",
    "author_email": "stix@mitre.org",
    "download_url": "https://files.pythonhosted.org/packages/18/20/746954e0fd7bb01be6d3669e1af5933fc6406a9a7398f0093aae9845630c/stixmarx-1.0.8.tar.gz",
    "platform": "",
    "description": "stixmarx\r\n========\r\n\r\nA Python API for marking STIX data.\r\n\r\n:Source: https://github.com/mitre/stixmarx/\r\n:Documentation: https://stixmarx.readthedocs.org/\r\n:Information: https://stixproject.github.io/\r\n\r\n|travis_badge| |landscape.io_badge| |version_badge|\r\n\r\nData Markings Concept\r\n---------------------\r\n\r\nLearn more about the Data Markings concept `here <https://stixproject.github.io/documentation/concepts/data-markings/>`_.\r\n\r\nExamples\r\n--------\r\n\r\nThe following examples demonstrate the intended use of the stixmarx library.\r\n\r\nAdding Markings\r\n~~~~~~~~~~~~~~~\r\n\r\n.. code-block:: python\r\n\r\n    # stixmarx imports\r\n    import stixmarx\r\n\r\n    # python-stix imports\r\n    from stix.indicator import Indicator\r\n    from stix.data_marking import MarkingSpecification\r\n    from stix.extensions.marking.tlp import TLPMarkingStructure as TLP\r\n\r\n\r\n    # Create a new stixmarx MarkingContainer with a\r\n    # new STIXPackage object contained within it.\r\n    container = stixmarx.new()\r\n\r\n    # Get the associated STIX Package\r\n    package = container.package\r\n\r\n    # Create an Indicator object\r\n    indicator = Indicator(title='Indicator Title', description='Gonna Mark This')\r\n\r\n    # Add the Indicator object to our STIX Package\r\n    package.add(indicator)\r\n\r\n    # Build MarkingSpecification and add TLP MarkingStructure\r\n    red_marking = MarkingSpecification(marking_structures=TLP(color=\"RED\"))\r\n    amber_marking = MarkingSpecification(marking_structures=TLP(color=\"AMBER\"))\r\n    green_marking = MarkingSpecification(marking_structures=TLP(color=\"GREEN\"))\r\n\r\n\r\n    # Mark the indicator with our TLP RED marking\r\n    # This is the equivalent of a component marking. Applies to all descendants\r\n    # nodes, text and attributes.\r\n    container.add_marking(indicator, red_marking, descendants=True)\r\n\r\n\r\n    # Mark the indicator with TLP GREEN. If descendants is false, the marking\r\n    # will only apply to the indicator node. Does NOT include text, attributes\r\n    # or descendants.\r\n    container.add_marking(indicator, green_marking)\r\n\r\n\r\n    # Mark the description text.\r\n    # >>> type(indicator.description.value)  <type 'str'>\r\n    indicator.description.value = container.add_marking(indicator.description.value, amber_marking)\r\n    # >>> type(indicator.description.value)  <class 'stixmarx.api.types.MarkableBytes'>\r\n\r\n\r\n    # Mark the indicator timestamp attribute.\r\n    # >>> type(indicator.timestamp)  <type 'datetime.datetime'>\r\n    indicator.timestamp = container.add_marking(indicator.timestamp, amber_marking)\r\n    # >>> type(indicator.timestamp)  <type 'stixmarx.api.types.MarkableDateTime'>\r\n\r\n    # Print the XML!\r\n    print container.to_xml()\r\n\r\nRetrieving Markings\r\n~~~~~~~~~~~~~~~~~~~\r\n\r\n.. code-block:: python\r\n\r\n    # stixmarx\r\n    import stixmarx\r\n\r\n    # Parse the input into a MarkingContainer\r\n    container = stixmarx.parse(\"stix-document.xml\")\r\n\r\n    # Get container package\r\n    package = container.package\r\n\r\n    # Get the markings that apply to the entire XML document\r\n    global_markings = container.get_markings(package)\r\n\r\n    # Print the dictionary representation for our only global marking\r\n    marking = global_markings[0]\r\n    print marking.to_dict()\r\n\r\n    # Get our only indicator from the STIX Package\r\n    indicator = package.indicators[0]\r\n\r\n    # Get the markings from the Indicator.\r\n    # Note: This will include the global markings and any other markings\r\n    # applied by an ancestor!\r\n    indicator_markings = container.get_markings(indicator)\r\n\r\n    # Print the Indicator markings!\r\n    for marking in indicator_markings:\r\n        print marking.to_dict()\r\n\r\nNotice\r\n------\r\n\r\nThis software was produced for the U. S. Government, and is subject to the\r\nRights in Data-General Clause 52.227-14, Alt. IV (DEC 2007).\r\n\r\nCopyright (c) 2017, The MITRE Corporation. All Rights Reserved.\r\n\r\n.. |travis_badge| image:: https://travis-ci.org/mitre/stixmarx.svg?branch=master&style=flat-square\r\n    :target: https://travis-ci.org/mitre/stixmarx\r\n    :alt: Travis CI Build Status\r\n.. |landscape.io_badge| image:: https://landscape.io/github/mitre/stixmarx/master/landscape.svg?style=flat-square\r\n    :target: https://landscape.io/github/mitre/stixmarx/master\r\n    :alt: Landscape.io Code Health\r\n.. |version_badge| image:: https://img.shields.io/pypi/v/stixmarx.svg?maxAge=3600&style=flat-square\r\n    :target: https://pypi.python.org/pypi/stixmarx/\r\n    :alt: PyPI Package Index\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "A data marking API for STIX 1 content.",
    "version": "1.0.8",
    "project_urls": {
        "Homepage": "https://github.com/mitre/stixmarx"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ba67ca70fbceeb4e0dbece631ebd10fd919d3da77ca68efd95b53d53a85e2fee",
                "md5": "e639ba03865c6e4d1b4cea461d23f95a",
                "sha256": "6f506aee25a921fe7cd073d20787c4cdca305debbe72fc2cbd0169ca6c894d11"
            },
            "downloads": -1,
            "filename": "stixmarx-1.0.8-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e639ba03865c6e4d1b4cea461d23f95a",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 32261,
            "upload_time": "2020-11-18T22:36:10",
            "upload_time_iso_8601": "2020-11-18T22:36:10.384903Z",
            "url": "https://files.pythonhosted.org/packages/ba/67/ca70fbceeb4e0dbece631ebd10fd919d3da77ca68efd95b53d53a85e2fee/stixmarx-1.0.8-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1820746954e0fd7bb01be6d3669e1af5933fc6406a9a7398f0093aae9845630c",
                "md5": "d521d4b8bb814bf48e238dcc15ad447b",
                "sha256": "f2a5855bb8a788c578cae8ecb0371a869030ec5ee3fb6f879eff7a3a0b85f075"
            },
            "downloads": -1,
            "filename": "stixmarx-1.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "d521d4b8bb814bf48e238dcc15ad447b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 27654,
            "upload_time": "2020-11-18T22:36:11",
            "upload_time_iso_8601": "2020-11-18T22:36:11.575805Z",
            "url": "https://files.pythonhosted.org/packages/18/20/746954e0fd7bb01be6d3669e1af5933fc6406a9a7398f0093aae9845630c/stixmarx-1.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-11-18 22:36:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mitre",
    "github_project": "stixmarx",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "landscape": true,
    "requirements": [],
    "tox": true,
    "lcname": "stixmarx"
}
        
Elapsed time: 0.21393s