Пример #1
0
def test_timestamp_property_valid(value):
    ts_prop = TimestampProperty()
    assert ts_prop.clean(value) == dt.datetime(2017,
                                               1,
                                               1,
                                               12,
                                               34,
                                               56,
                                               tzinfo=pytz.utc)
Пример #2
0
 class SomeSCO(stix2.v21._Observable):
     _type = "some-sco"
     _properties = OrderedDict((
         ('type', TypeProperty(_type, spec_version='2.1')),
         ('id', IDProperty(_type, spec_version='2.1')),
         ('extensions', ExtensionsProperty(spec_version='2.1')),
         ('timestamp', TimestampProperty()),
     ))
     _id_contributing_properties = ['timestamp']
Пример #3
0
class StixObservedData(_STIXBase):
    _type = 'observed-data'
    _properties = OrderedDict()
    _properties.update([
        ('type', TypeProperty(_type)), ('id', IDProperty(_type)),
        ('created_by_ref', ReferenceProperty(type="device_ref")),
        ('created',
         TimestampProperty(default=lambda: NOW, precision='millisecond')),
        ('modified',
         TimestampProperty(default=lambda: NOW, precision='millisecond')),
        ('first_observed', TimestampProperty(required=True)),
        ('last_observed', TimestampProperty(required=True)),
        ('number_observed', IntegerProperty(required=True)),
        ('objects', ObservableProperty()), ('revoked', BooleanProperty()),
        ('labels', ListProperty(StringProperty)),
        ('external_references', ListProperty(ExternalReference)),
        ('object_marking_refs',
         ListProperty(ReferenceProperty(type="marking-definition"))),
        ('granular_markings', ListProperty(GranularMarking)),
        ('device_ref', DeviceProperty('device'))
    ])
Пример #4
0
def test_timestamp_property_invalid():
    ts_prop = TimestampProperty()
    with pytest.raises(ValueError):
        ts_prop.clean(1)
    with pytest.raises(ValueError):
        ts_prop.clean("someday sometime")
Пример #5
0
def test_timestamp_property_valid(value):
    ts_prop = TimestampProperty()
    assert ts_prop.clean(value) == FAKE_TIME
Пример #6
0
    ('description', properties.StringProperty(required=True)),
    ('x_mitre_shortname', properties.StringProperty(required=True))
])
class Tactic(object):
    def __init__(self, x_mitre_shortname=None, **kwargs):
        if x_mitre_shortname and x_mitre_shortname not in ["strategic-planning", "objective-planning", "develop-people",
                                           "develop-networks", "microtargeting", "develop-content",
                                           "channel-selection", "pump-priming", "exposure", "go-physical",
                                           "persistence", "measure-effectiveness"]:
            raise ValueError("'%s' is not a recognized AMITT Tactic." % x_mitre_shortname)

@CustomObject('x-amitt-narrative', [
    ('name', StringProperty(required=True)),
    ('description', StringProperty()),
    ('aliases', ListProperty(StringProperty)),
    ('first_seen', TimestampProperty()),
    ('last_seen', TimestampProperty()),
    ('objective', StringProperty()),
    ('external_references', ListProperty(ExternalReference)),
    ('object_marking_refs', ListProperty(ReferenceProperty(valid_types='marking-definition', spec_version='2.0'))),
    ('granular_markings', ListProperty(GranularMarking))
])
class Narrative(object):
    def __init__(self, **kwargs):
        if True:
            pass

@CustomObject('x-amitt-incident', [
    ('name', StringProperty(required=True)),
    ('description', StringProperty()),
    ('aliases', ListProperty(StringProperty)),