Browse Source

add callable support to add_param_value

Jens Keim 5 years ago
parent
commit
ae80c2ff0e
1 changed files with 8 additions and 1 deletions
  1. 8 1
      code/Attack/BaseAttack.py

+ 8 - 1
code/Attack/BaseAttack.py

@@ -369,9 +369,16 @@ class BaseAttack(metaclass=abc.ABCMeta):
             sys.exit(-1)
 
         # if parameter is already specified, stop
-        if param_name in self.params.keys():
+        if param_name in self.params.keys()\
+                and not callable(value)\
+                and ((isinstance(value, list) and self.params.values() not in value)
+                     or value not in self.params.values()):
             return
 
+        # call function or method if necessary
+        if callable(value):
+            value = value()
+
         # Get parameter type of attack's required_params
         param_type = self.supported_params.get(param_name)