MCPcopy Create free account
hub / github.com/STIXProject/python-stix / main

Function main

examples/campaign-reference.py:16–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14
15
16def main():
17 # Build Campaign instances
18 camp1 = Campaign(title='Campaign 1')
19 camp2 = Campaign(title='Campaign 2')
20
21 # Build a CampaignRef object, setting the `idref` to the `id_` value of
22 # our `camp2` Campaign object.
23 campaign_ref = CampaignRef(idref=camp2.id_)
24
25 # Build an Indicator object.
26 i = Indicator()
27
28 # Add CampaignRef object pointing to `camp2`.
29 i.add_related_campaign(campaign_ref)
30
31 # Add Campaign object, which gets promoted into an instance of
32 # CampaignRef type internally. Only the `idref` is set.
33 i.add_related_campaign(camp1)
34
35 # Build our STIX Package and attach our Indicator and Campaign objects.
36 package = STIXPackage()
37 package.add_indicator(i)
38 package.add_campaign(camp1)
39 package.add_campaign(camp2)
40
41 # Print!
42 print package.to_xml()
43
44if __name__ == "__main__":
45 main()

Callers 1

Calls 8

add_related_campaignMethod · 0.95
add_indicatorMethod · 0.95
add_campaignMethod · 0.95
CampaignClass · 0.90
CampaignRefClass · 0.90
IndicatorClass · 0.90
STIXPackageClass · 0.90
to_xmlMethod · 0.45

Tested by

no test coverage detected