MCPcopy
hub / github.com/apache/caldera / Fact

Class Fact

app/objects/secondclass/c_fact.py:67–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65
66
67class Fact(BaseObject):
68
69 schema = FactSchema()
70 load_schema = FactSchema(exclude=['unique'])
71
72 @property
73 def unique(self):
74 return self.hash('%s%s' % (self.trait, self.value))
75
76 @property
77 def name(self):
78 return self._trait
79
80 @name.setter
81 def name(self, value):
82 # Keep both values in sync if changed. (backwards compatibility)
83 self._trait = value
84
85 @property
86 def trait(self):
87 return self._trait
88
89 @trait.setter
90 def trait(self, value):
91 # Keep both values in sync if changed. (backwards compatibility)
92 self._trait = value
93
94 def escaped(self, executor):
95 if executor not in escape_ref:
96 return self.value
97 escaped_value = str(self.value)
98 for char in escape_ref[executor]['special']:
99 escaped_value = escaped_value.replace(char, (escape_ref[executor]['escape_prefix'] + char))
100 return escaped_value
101
102 def __eq__(self, other):
103 if isinstance(other, Fact):
104 return self.unique == other.unique and self.source == other.source
105 return False
106
107 def __init__(self, trait, value=None, score=1, source=None, origin_type=None, links=None,
108 relationships=None, limit_count=-1, collected_by=None, technique_id=None):
109 super().__init__()
110 self.trait = trait
111 self.value = value
112 self.created = datetime.now(timezone.utc)
113 self.score = score
114 self.source = source
115 self.origin_type = origin_type
116 self.links = links or []
117 self.relationships = relationships or []
118 self.limit_count = limit_count
119 self.collected_by = collected_by or []
120 self.technique_id = technique_id

Callers 15

save_factMethod · 0.90
_generate_factFunction · 0.90
test_sourceFunction · 0.90
TestIPRuleClass · 0.90
test_link_eqMethod · 0.90
test_link_neqMethod · 0.90
test_escaped_cmdMethod · 0.90
test_escaped_shMethod · 0.90

Calls 1

FactSchemaClass · 0.85