Skip to content

Commit

Permalink
Ability with multiple executors but not the one preferred by the agent (
Browse files Browse the repository at this point in the history
mitre#457)

* untrusted/trusted agents

* untrusted/trusted agents

* back to mitre/master

* back to mitre/master

* Update core.sql

* Update planning_svc.py

management of the case in which an agent can execute an ability that using more than one executors but not to his preferred executor.
  • Loading branch information
EmilioPanti authored and David Hunt committed Sep 1, 2019
1 parent 5d66b6e commit 3ff7804
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions app/service/planning_svc.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,13 @@ async def _add_test_variants(self, links, agent, operation):
async def capable_agent_abilities(phase_abilities, agent):
abilities = []
preferred = next((e['executor'] for e in agent['executors'] if e['preferred']))
executors = [e['executor'] for e in agent['executors']]
for ai in set([pa['ability_id'] for pa in phase_abilities]):
total_ability = [ab for ab in phase_abilities if ab['ability_id'] == ai]
if len(total_ability) > 1:
val = next((ta for ta in total_ability if ta['executor'] == preferred), False)
if val:
abilities.append(val)
elif total_ability[0]['executor'] in [e['executor'] for e in agent['executors']]:
abilities.append(total_ability[0])
total_ability = [ab for ab in phase_abilities if (ab['ability_id'] == ai)
and (ab['executor'] in executors)]
if len(total_ability) > 0:
val = next((ta for ta in total_ability if ta['executor'] == preferred), total_ability[0])
abilities.append(val)
return abilities

""" PRIVATE """
Expand Down

0 comments on commit 3ff7804

Please sign in to comment.