async def _create_ability(self, ability_id, tactic, technique_name, technique_id, name, test, description, executor, platform, cleanup=None, payload=None, parsers=None, requirements=None, privilege=None): ps = [] for module in parsers: pcs = [(ParserConfig(**m)) for m in parsers[module]] ps.append(Parser(module=module, parserconfigs=pcs)) rs = [] for module in requirements: relation = [Relationship(source=r['source'], edge=r.get('edge'), target=r.get('target')) for r in requirements[module]] rs.append(Requirement(module=module, relationships=relation)) await self.store(Ability(ability_id=ability_id, name=name, test=test, tactic=tactic, technique_id=technique_id, technique=technique_name, executor=executor, platform=platform, description=description, cleanup=cleanup, payload=payload, parsers=ps, requirements=rs, privilege=privilege))
def from_json(cls, json): parsers = [Parser.from_json(p) for p in json['parsers']] requirements = [Requirement.from_json(r) for r in json['requirements']] return cls(ability_id=json['ability_id'], tactic=json['tactic'], technique_id=json['technique_id'], technique=json['technique_name'], name=json['name'], test=json['test'], description=json['description'], cleanup=json['cleanup'], executor=json['executor'], platform=json['platform'], payload=json['payload'], parsers=parsers, requirements=requirements, privilege=json['privilege'], timeout=json['timeout'])