{"id":19260333,"url":"https://github.com/mitre/stixmarx","last_synced_at":"2025-04-21T16:31:39.984Z","repository":{"id":54653844,"uuid":"90643388","full_name":"mitre/stixmarx","owner":"mitre","description":"Data Markings API for STIX 1.x","archived":false,"fork":false,"pushed_at":"2021-02-04T18:13:28.000Z","size":137,"stargazers_count":9,"open_issues_count":2,"forks_count":8,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-01T14:22:15.990Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitre.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-08T15:24:19.000Z","updated_at":"2024-12-13T03:09:02.000Z","dependencies_parsed_at":"2022-08-13T23:00:28.474Z","dependency_job_id":null,"html_url":"https://github.com/mitre/stixmarx","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitre%2Fstixmarx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitre%2Fstixmarx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitre%2Fstixmarx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitre%2Fstixmarx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitre","download_url":"https://codeload.github.com/mitre/stixmarx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250090882,"owners_count":21373269,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T19:20:00.891Z","updated_at":"2025-04-21T16:31:37.849Z","avatar_url":"https://github.com/mitre.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"stixmarx\n========\n\nA Python API for marking STIX data.\n\n:Source: https://github.com/mitre/stixmarx/\n:Documentation: https://stixmarx.readthedocs.org/\n:Information: https://stixproject.github.io/\n\n|travis_badge| |landscape.io_badge| |version_badge|\n\nData Markings Concept\n---------------------\n\nLearn more about the Data Markings concept `here \u003chttps://stixproject.github.io/documentation/concepts/data-markings/\u003e`_.\n\nExamples\n--------\n\nThe following examples demonstrate the intended use of the stixmarx library.\n\nAdding Markings\n~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n    # stixmarx imports\n    import stixmarx\n\n    # python-stix imports\n    from stix.indicator import Indicator\n    from stix.data_marking import MarkingSpecification\n    from stix.extensions.marking.tlp import TLPMarkingStructure as TLP\n\n\n    # Create a new stixmarx MarkingContainer with a\n    # new STIXPackage object contained within it.\n    container = stixmarx.new()\n\n    # Get the associated STIX Package\n    package = container.package\n\n    # Create an Indicator object\n    indicator = Indicator(title='Indicator Title', description='Gonna Mark This')\n\n    # Add the Indicator object to our STIX Package\n    package.add(indicator)\n\n    # Build MarkingSpecification and add TLP MarkingStructure\n    red_marking = MarkingSpecification(marking_structures=TLP(color=\"RED\"))\n    amber_marking = MarkingSpecification(marking_structures=TLP(color=\"AMBER\"))\n    green_marking = MarkingSpecification(marking_structures=TLP(color=\"GREEN\"))\n\n\n    # Mark the indicator with our TLP RED marking\n    # This is the equivalent of a component marking. Applies to all descendants\n    # nodes, text and attributes.\n    container.add_marking(indicator, red_marking, descendants=True)\n\n\n    # Mark the indicator with TLP GREEN. If descendants is false, the marking\n    # will only apply to the indicator node. Does NOT include text, attributes\n    # or descendants.\n    container.add_marking(indicator, green_marking)\n\n\n    # Mark the description text.\n    # \u003e\u003e\u003e type(indicator.description.value)  \u003ctype 'str'\u003e\n    indicator.description.value = container.add_marking(indicator.description.value, amber_marking)\n    # \u003e\u003e\u003e type(indicator.description.value)  \u003cclass 'stixmarx.api.types.MarkableBytes'\u003e\n\n\n    # Mark the indicator timestamp attribute.\n    # \u003e\u003e\u003e type(indicator.timestamp)  \u003ctype 'datetime.datetime'\u003e\n    indicator.timestamp = container.add_marking(indicator.timestamp, amber_marking)\n    # \u003e\u003e\u003e type(indicator.timestamp)  \u003ctype 'stixmarx.api.types.MarkableDateTime'\u003e\n\n    # Print the XML!\n    print container.to_xml()\n\nRetrieving Markings\n~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n    # stixmarx\n    import stixmarx\n\n    # Parse the input into a MarkingContainer\n    container = stixmarx.parse(\"stix-document.xml\")\n\n    # Get container package\n    package = container.package\n\n    # Get the markings that apply to the entire XML document\n    global_markings = container.get_markings(package)\n\n    # Print the dictionary representation for our only global marking\n    marking = global_markings[0]\n    print marking.to_dict()\n\n    # Get our only indicator from the STIX Package\n    indicator = package.indicators[0]\n\n    # Get the markings from the Indicator.\n    # Note: This will include the global markings and any other markings\n    # applied by an ancestor!\n    indicator_markings = container.get_markings(indicator)\n\n    # Print the Indicator markings!\n    for marking in indicator_markings:\n        print marking.to_dict()\n\nNotice\n------\n\nThis software was produced for the U. S. Government, and is subject to the\nRights in Data-General Clause 52.227-14, Alt. IV (DEC 2007).\n\nCopyright (c) 2017, The MITRE Corporation. All Rights Reserved.\n\n.. |travis_badge| image:: https://travis-ci.org/mitre/stixmarx.svg?branch=master\u0026style=flat-square\n    :target: https://travis-ci.org/mitre/stixmarx\n    :alt: Travis CI Build Status\n.. |landscape.io_badge| image:: https://landscape.io/github/mitre/stixmarx/master/landscape.svg?style=flat-square\n    :target: https://landscape.io/github/mitre/stixmarx/master\n    :alt: Landscape.io Code Health\n.. |version_badge| image:: https://img.shields.io/pypi/v/stixmarx.svg?maxAge=3600\u0026style=flat-square\n    :target: https://pypi.python.org/pypi/stixmarx/\n    :alt: PyPI Package Index\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitre%2Fstixmarx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitre%2Fstixmarx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitre%2Fstixmarx/lists"}