3
0
فهرست منبع

BaseAttack.add_param_value: Moved check for statistics object since we require it earlier already

Stefan Schmidt 6 سال پیش
والد
کامیت
8dbaace1b2
1فایلهای تغییر یافته به همراه5 افزوده شده و 5 حذف شده
  1. 5 5
      code/Attack/BaseAttack.py

+ 5 - 5
code/Attack/BaseAttack.py

@@ -371,6 +371,11 @@ class BaseAttack(metaclass=abc.ABCMeta):
         # Get parameter type of attack's required_params
         param_type = self.supported_params.get(param_name)
 
+        # This function call is valid only if there is a statistics object available.
+        if self.statistics is None:
+            raise RuntimeError(
+                'Error: Statistics-dependent attack parameter added without setting a statistics object first.')
+
         # Verify validity of given value with respect to parameter type
         if param_type is None:
             print('Parameter ' + str(param_name) + ' not available for chosen attack. Skipping parameter.')
@@ -412,11 +417,6 @@ class BaseAttack(metaclass=abc.ABCMeta):
         elif param_type == atkParam.ParameterTypes.TYPE_BOOLEAN:
             is_valid, value = self._is_boolean(value)
         elif param_type == atkParam.ParameterTypes.TYPE_PACKET_POSITION:
-            # This function call is valid only if there is a statistics object available.
-            if self.statistics is None:
-                raise RuntimeError(
-                    'Error: Statistics-dependent attack parameter added without setting a statistics object first.')
-
             ts = pr.pcap_processor(self.statistics.pcap_filepath, "False", Util.RESOURCE_DIR).get_timestamp_mu_sec(int(value))
             if 0 <= int(value) <= self.statistics.get_packet_count() and ts >= 0:
                 is_valid = True