Exemplo n.º 1
0
    def test_get_tech_mitigation(self):
        """
        There are some techniques that do not have mitigations.
        We will test few and if at least one of the first 5 has mitigations we're ok,
        otherwise we probably need to check if there's an error.
        """
        techs = MitreAttackTechnique.get_all(self.mitre_conn)
        assert len(techs)
        try:
            count = 0
            for tech in techs:
                id = tech.id
                assert (id)
                mitigation = tech.get_mitigations(self.mitre_conn)

                count += 1

                if len(mitigation):
                    assert MitreAttackMitigation.get_by_name(
                        self.mitre_conn, mitigation[0].name)
                    break

                if count > MAXIMUM_N_TECHNIQUES_WITHOUT_MITIGATION:
                    assert False
        except Exception as e:
            assert (False)
 def test_get_tech_mitigation(self):
     techs = MitreAttackTechnique.get_all(self.mitre_conn)
     assert len(techs)
     try:
         #
         #   There are more than 200 techs. Try first 5 only
         #
         count = 0
         for tech in techs:
             id = tech.id
             assert (id)
             mitigation = tech.get_mitigations(self.mitre_conn)
             assert mitigation
             count += 1
             if count > 2:
                 break
             # Test getting mitigation using name
             mitigation = tech.get_mitigations(self.mitre_conn)
             assert mitigation
     except Exception as e:
         assert (False)
Exemplo n.º 3
0
 def test_tech_get_all(self):
     assert len(MitreAttackTechnique.get_all(
         self.mitre_attack)) == len(MitreQueryMocker.TECHNIQUES[0]) + len(
             MitreQueryMocker.TECHNIQUES[1]) + len(
                 MitreQueryMocker.TECHNIQUES[2])