本文整理汇总了Python中cybox.core.Observable.to_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Observable.to_dict方法的具体用法?Python Observable.to_dict怎么用?Python Observable.to_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cybox.core.Observable
的用法示例。
在下文中一共展示了Observable.to_dict方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_observables_property_composition
# 需要导入模块: from cybox.core import Observable [as 别名]
# 或者: from cybox.core.Observable import to_dict [as 别名]
def test_observables_property_composition(self):
f1 = File()
f1.file_name = "README.txt"
f2 = File()
f2.file_name = "README2.txt"
obs1 = Observable(f1)
obs2 = Observable(f2)
comp = Observable(ObservableComposition('AND', [obs1, obs2]))
ind = Indicator()
ind.observable = comp
ind2 = Indicator.from_dict(ind.to_dict())
self.assertEqual([obs1.to_dict(), obs2.to_dict()],
[x.to_dict() for x in ind2.observables])
示例2: test_round_trip
# 需要导入模块: from cybox.core import Observable [as 别名]
# 或者: from cybox.core.Observable import to_dict [as 别名]
def test_round_trip(self):
o = Observable()
o.title = "An observable"
o.description = "some text"
o.description.structuring_format = "plain"
o.id_ = "abc123"
o.object_ = Object()
o2 = cybox.test.round_trip(o)
self.assertEqual(o.to_dict(), o2.to_dict())
示例3: test_observables_property_standard
# 需要导入模块: from cybox.core import Observable [as 别名]
# 或者: from cybox.core.Observable import to_dict [as 别名]
def test_observables_property_standard(self):
f = File()
f.file_name = "README.txt"
obs = Observable(f)
ind = Indicator()
ind.observable = obs
ind2 = Indicator.from_dict(ind.to_dict())
self.assertEqual([obs.to_dict()],
[x.to_dict() for x in ind2.observables])
示例4: test_round_trip_observable
# 需要导入模块: from cybox.core import Observable [as 别名]
# 或者: from cybox.core.Observable import to_dict [as 别名]
def test_round_trip_observable(self):
# Wrap the object in an observable before trying a round_trip test.
# Don't run this test on the base class
if type(self) == type(ObjectTestCase):
return
obj = self.klass.from_dict(self._full_dict)
observable = Observable(obj)
observable2 = cybox.test.round_trip(observable, output=True)
self.maxDiff = None
self.assertEqual(observable.to_dict(), observable2.to_dict())
示例5: test_round_trip
# 需要导入模块: from cybox.core import Observable [as 别名]
# 或者: from cybox.core.Observable import to_dict [as 别名]
def test_round_trip(self):
o = Observable()
o.title = "An observable"
o.description = "some text"
o.description.structuring_format = "plain"
o.id_ = "abc123"
o.object_ = Object()
pf = PatternFidelity()
ot = ObfuscationTechnique()
ot.description = "X0Rz"
pf.evasion_techniques = ObfuscationTechniques()
pf.evasion_techniques.append(ot)
o.pattern_fidelity = pf
o2 = round_trip(o)
self.assertEqual(o.to_dict(), o2.to_dict())