(simulated_test_case: RTTestCase)
| 126 | simulated_attacks: Dict[str, str] = {} |
| 127 | |
| 128 | async def process_attack(simulated_test_case: RTTestCase): |
| 129 | vulnerability_type = simulated_test_case.vulnerability_type |
| 130 | input_text = simulated_test_case.input |
| 131 | |
| 132 | target_output = await model_callback(input_text) |
| 133 | |
| 134 | red_teaming_test_case = RTTestCase( |
| 135 | vulnerability=simulated_test_case.vulnerability, |
| 136 | vulnerability_type=vulnerability_type, |
| 137 | attackMethod=simulated_test_case.attack_method, |
| 138 | riskCategory=getRiskCategory(vulnerability_type), |
| 139 | input=input_text, |
| 140 | actual_output=target_output, |
| 141 | ) |
| 142 | |
| 143 | metric = self._get_metric(vulnerability_type) |
| 144 | await metric.a_measure(red_teaming_test_case) |
| 145 | |
| 146 | red_teaming_test_case.score = metric.score |
| 147 | red_teaming_test_case.reason = metric.reason |
| 148 | |
| 149 | res[vulnerability_type] = metric |
| 150 | simulated_attacks[vulnerability_type.value] = input_text |
| 151 | |
| 152 | return vulnerability_type, red_teaming_test_case |
| 153 | |
| 154 | all_tasks = [ |
| 155 | process_attack(simulated_test_case) |
nothing calls this directly
no test coverage detected