Exemplo n.º 1
0
def populate_malware():
    m1 = Malware(name='Gootkit').save()
    m1.family = ['banker', 'trojan']
    m1.save()
    m2 = Malware(name='Sofacy').save()
    m2.family = ['trojan']
    m2.save()
    return [m1, m2]
Exemplo n.º 2
0
def test_malware_versionning():
    """Tests that a getting a Malware object returns the most recent version."""
    malware = Malware(name='asd', labels=['label1'])
    malware.save()
    stix_id = malware.id
    malware.update({'name': 'dsa'})
    fetched = Malware.get(stix_id)
    assert fetched.id == stix_id
    assert fetched.created < fetched.modified
Exemplo n.º 3
0
def test_malware_creation():
    """Tests the creation of a single malware."""
    mal = Malware(name='Gootkit')
    assert mal.id is None
    mal = mal.save()
    assert isinstance(mal, Malware)
    assert mal.id is not None
Exemplo n.º 4
0
def test_update_malware():
    """Tests that a Malware object is succesfully updated."""
    kc_phases = [{'kill_chain_name': 'cyber', 'phase_name': 'cyber1'}]
    malware = Malware(name='asd',
                      labels=['label1'],
                      description='123',
                      kill_chain_phases=kc_phases)
    malware.save()
    modified = malware.modified
    stix_id = malware.id
    updated = malware.update({'name': 'dsa'})
    assert updated.name == 'dsa'
    assert updated.description == '123'
    assert updated.kill_chain_phases == kc_phases
    assert malware.modified > modified
    assert updated.id == stix_id
Exemplo n.º 5
0
def test_save_malware():
    """Tests that a Malware object missing fields cannot be created."""
    malware = Malware(name='asd', labels=['label1'])
    saved = malware.save()
    assert saved is not None