@@ -53,6 +53,7 @@ public class PassiveScanApi extends ApiImplementor {
5353 private static final String VIEW_CURRENT_RULE = "currentRule" ;
5454 private static final String VIEW_CURRENT_TASKS = "currentTasks" ;
5555 private static final String VIEW_MAX_ALERTS_PER_RULE = "maxAlertsPerRule" ;
56+ private static final String VIEW_MAX_BODY_SIZE_IN_BYTES = "maxBodySizeInBytes" ;
5657
5758 private static final String ACTION_SET_ENABLED = "setEnabled" ;
5859 private static final String ACTION_SET_SCAN_ONLY_IN_SCOPE = "setScanOnlyInScope" ;
@@ -62,6 +63,7 @@ public class PassiveScanApi extends ApiImplementor {
6263 private static final String ACTION_DISABLE_SCANNERS = "disableScanners" ;
6364 private static final String ACTION_SET_SCANNER_ALERT_THRESHOLD = "setScannerAlertThreshold" ;
6465 private static final String ACTION_SET_MAX_ALERTS_PER_RULE = "setMaxAlertsPerRule" ;
66+ private static final String ACTION_SET_MAX_BODY_SIZE_IN_BYTES = "setMaxBodySizeInBytes" ;
6567 private static final String ACTION_DISABLE_ALL_TAGS = "disableAllTags" ;
6668 private static final String ACTION_ENABLE_ALL_TAGS = "enableAllTags" ;
6769 private static final String ACTION_CLEAR_QUEUE = "clearQueue" ;
@@ -72,6 +74,7 @@ public class PassiveScanApi extends ApiImplementor {
7274 private static final String PARAM_ID = "id" ;
7375 private static final String PARAM_ALERT_THRESHOLD = "alertThreshold" ;
7476 private static final String PARAM_MAX_ALERTS = "maxAlerts" ;
77+ private static final String PARAM_MAX_SIZE = "maxSize" ;
7578
7679 private final ExtensionPassiveScan2 extension ;
7780 private final PassiveScannersManager scannersManager ;
@@ -97,6 +100,8 @@ public PassiveScanApi(ExtensionPassiveScan2 extension, PassiveScannersManager sc
97100 new String [] {PARAM_ID , PARAM_ALERT_THRESHOLD }));
98101 this .addApiAction (
99102 new ApiAction (ACTION_SET_MAX_ALERTS_PER_RULE , new String [] {PARAM_MAX_ALERTS }));
103+ this .addApiAction (
104+ new ApiAction (ACTION_SET_MAX_BODY_SIZE_IN_BYTES , new String [] {PARAM_MAX_SIZE }));
100105 this .addApiAction (new ApiAction (ACTION_DISABLE_ALL_TAGS ));
101106 this .addApiAction (new ApiAction (ACTION_ENABLE_ALL_TAGS ));
102107 this .addApiAction (new ApiAction (ACTION_CLEAR_QUEUE ));
@@ -113,6 +118,7 @@ public PassiveScanApi(ExtensionPassiveScan2 extension, PassiveScannersManager sc
113118 this .addApiView (currentRule );
114119 this .addApiView (new ApiView (VIEW_CURRENT_TASKS ));
115120 this .addApiView (new ApiView (VIEW_MAX_ALERTS_PER_RULE ));
121+ this .addApiView (new ApiView (VIEW_MAX_BODY_SIZE_IN_BYTES ));
116122 }
117123
118124 @ Override
@@ -162,6 +168,11 @@ public ApiResponse handleApiAction(String name, JSONObject params) throws ApiExc
162168 case ACTION_SET_MAX_ALERTS_PER_RULE :
163169 getOptions ().setMaxAlertsPerRule (ApiUtils .getIntParam (params , PARAM_MAX_ALERTS ));
164170 break ;
171+ case ACTION_SET_MAX_BODY_SIZE_IN_BYTES :
172+ getOptions ()
173+ .setMaxBodySizeInBytesToScan (
174+ Math .max (0 , ApiUtils .getIntParam (params , PARAM_MAX_SIZE )));
175+ break ;
165176 case ACTION_DISABLE_ALL_TAGS :
166177 getOptions ()
167178 .getAutoTagScanners ()
@@ -325,6 +336,12 @@ public ApiResponse handleApiView(String name, JSONObject params) throws ApiExcep
325336 VIEW_MAX_ALERTS_PER_RULE ,
326337 Integer .toString (getOptions ().getMaxAlertsPerRule ()));
327338 break ;
339+ case VIEW_MAX_BODY_SIZE_IN_BYTES :
340+ result =
341+ new ApiResponseElement (
342+ VIEW_MAX_BODY_SIZE_IN_BYTES ,
343+ Integer .toString (getOptions ().getMaxBodySizeInBytesToScan ()));
344+ break ;
328345 default :
329346 throw new ApiException (ApiException .Type .BAD_VIEW );
330347 }
0 commit comments