コード例 #1
0
def convert_campaign(c20):
    c1x = Campaign(id_=convert_id20(c20["id"]),
                   timestamp=text_type(c20["modified"]))
    if "name" in c20:
        c1x.title = c20["name"]
    if "description" in c20:
        c1x.add_description(c20["description"])
    if "labels" in c20:
        for l in c20["labels"]:
            add_missing_property_to_description(c1x, "label", l)
    names = Names()
    if "aliases" in c20:
        for a in c20["aliases"]:
            names.name.append(VocabString(a))
    if names:
        c1x.names = names
    if "first_seen" in c20:
        add_missing_property_to_description(c1x, "first_seen",
                                            text_type(c20["first_seen"]))
    if "last_seen" in c20:
        add_missing_property_to_description(c1x, "last_seen",
                                            text_type(c20["last_seen"]))
    if "objective" in c20:
        c1x.intended_effects = [Statement(description=c20["objective"])]
    if "object_marking_refs" in c20:
        for m_id in c20["object_marking_refs"]:
            ms = create_marking_specification(m_id)
            if ms:
                CONTAINER.add_marking(c1x, ms, descendants=True)
    if "granular_markings" in c20:
        error(
            "Granular Markings present in '%s' are not supported by stix2slider",
            604, c20["id"])
    record_id_object_mapping(c20["id"], c1x)
    return c1x
コード例 #2
0
ファイル: stix_export.py プロジェクト: HardlyHaki/Hiryu
def create_campaign(title=None, description=None):
    campaign = Campaign()
    campaign.title = title
    campaign.add_description(description)
    return campaign