コード例 #1
0
ファイル: test_parsers.py プロジェクト: serksimper/stockpile
 def test_bookmarks(self):
     p = Parser(
         dict(mappers=[
             ParserConfig(source='host.chrome.bookmark_name',
                          edge='resolves_to',
                          target='host.chrome.bookmark_url')
         ],
              used_facts=[]))
     with open('plugins/stockpile/tests/data/bookmarks.json',
               'r') as bookmarks:
         relationships = p.parse(blob=bookmarks.read())
         self.assertEqual(len(relationships), 6)
コード例 #2
0
 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))
コード例 #3
0
 def from_json(cls, json):
     parserconfigs = [
         ParserConfig.from_json(r) for r in json['relationships']
     ]
     return cls(module=json['module'], parserconfigs=parserconfigs)