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', enclosing_type=_type, ), ), ('string', StringProperty()), ('int', IntegerProperty()), ('float', FloatProperty()), ('bool', BooleanProperty()), ('list', ListProperty(IntegerProperty())), ('dict', DictionaryProperty(spec_version="2.1")), )) _id_contributing_properties = [ 'string', 'int', 'float', 'bool', 'list', 'dict', ]
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')), )) _id_contributing_properties = []
def test_type_property(): prop = TypeProperty('my-type') assert prop.clean('my-type') with pytest.raises(ValueError): prop.clean('not-my-type') assert prop.clean(prop.default())
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', enclosing_type=_type, ), ), ('sub_obj', EmbeddedObjectProperty(type=SubObj)), )) _id_contributing_properties = ['sub_obj']
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', enclosing_type=_type, ), ), ('hashes', HashesProperty(HASHING_ALGORITHM)), )) _id_contributing_properties = ['hashes']
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')) ])