Esempio n. 1
0
def test_add_dict_object(collection):
    tc_sink = stix2.TAXIICollectionSink(collection)

    ta = {
        "type":
        "threat-actor",
        "id":
        "threat-actor--eddff64f-feb1-4469-b07c-499a73c96415",
        "created":
        "2018-04-23T16:40:50.847Z",
        "modified":
        "2018-04-23T16:40:50.847Z",
        "name":
        "Teddy Bear",
        "goals": [
            "compromising environment NGOs",
            "water-hole attacks geared towards energy sector",
        ],
        "sophistication":
        "innovator",
        "resource_level":
        "government",
        "labels": [
            "nation-state",
        ],
    }

    tc_sink.add(ta)
Esempio n. 2
0
def test_can_write_error(collection_no_rw_access):
    """create a TAXIICOllectionSink with a taxii2client.Collection
    instance that does not have write access, check ValueError exception is raised"""

    with pytest.raises(DataSourceError) as excinfo:
        stix2.TAXIICollectionSink(collection_no_rw_access)
    assert "Collection object provided does not have write access" in str(excinfo.value)
Esempio n. 3
0
def test_add_dict_bundle_object(collection):
    tc_sink = stix2.TAXIICollectionSink(collection)

    ta = {
        "type": "bundle",
        "id": "bundle--860ccc8d-56c9-4fda-9384-84276fb52fb1",
        "objects": [
            {
                "type": "threat-actor",
                "id": "threat-actor--dc5a2f41-f76e-425a-81fe-33afc7aabd75",
                "created": "2018-04-23T18:45:11.390Z",
                "modified": "2018-04-23T18:45:11.390Z",
                "name": "Teddy Bear",
                "goals": [
                    "compromising environment NGOs",
                    "water-hole attacks geared towards energy sector",
                ],
                "sophistication": "innovator",
                "resource_level": "government",
                "labels": [
                    "nation-state",
                ],
            },
        ],
    }

    tc_sink.add(ta)
Esempio n. 4
0
def test_add_stix2_bundle_object(collection):
    tc_sink = stix2.TAXIICollectionSink(collection)

    # create new STIX threat-actor
    ta = stix2.v20.ThreatActor(
        name="Teddy Bear",
        labels=["nation-state"],
        sophistication="innovator",
        resource_level="government",
        goals=[
            "compromising environment NGOs",
            "water-hole attacks geared towards energy sector",
        ],
    )

    tc_sink.add(stix2.v20.Bundle(objects=[ta]))
def test_add_list_object(collection, indicator):
    tc_sink = stix2.TAXIICollectionSink(collection)

    # create new STIX threat-actor
    ta = stix2.v21.ThreatActor(
        name="Teddy Bear",
        threat_actor_types=["nation-state"],
        sophistication="innovator",
        resource_level="government",
        goals=[
            "compromising environment NGOs",
            "water-hole attacks geared towards energy sector",
        ],
    )

    tc_sink.add([ta, indicator])