()
| 14 | |
| 15 | |
| 16 | def 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 | |
| 44 | if __name__ == "__main__": |
| 45 | main() |
no test coverage detected