@@ -53,6 +53,7 @@ public class PassiveScanApi extends ApiImplementor {
53
53
private static final String VIEW_CURRENT_RULE = "currentRule" ;
54
54
private static final String VIEW_CURRENT_TASKS = "currentTasks" ;
55
55
private static final String VIEW_MAX_ALERTS_PER_RULE = "maxAlertsPerRule" ;
56
+ private static final String VIEW_MAX_BODY_SIZE_IN_BYTES = "maxBodySizeInBytes" ;
56
57
57
58
private static final String ACTION_SET_ENABLED = "setEnabled" ;
58
59
private static final String ACTION_SET_SCAN_ONLY_IN_SCOPE = "setScanOnlyInScope" ;
@@ -62,6 +63,7 @@ public class PassiveScanApi extends ApiImplementor {
62
63
private static final String ACTION_DISABLE_SCANNERS = "disableScanners" ;
63
64
private static final String ACTION_SET_SCANNER_ALERT_THRESHOLD = "setScannerAlertThreshold" ;
64
65
private static final String ACTION_SET_MAX_ALERTS_PER_RULE = "setMaxAlertsPerRule" ;
66
+ private static final String ACTION_SET_MAX_BODY_SIZE_IN_BYTES = "setMaxBodySizeInBytes" ;
65
67
private static final String ACTION_DISABLE_ALL_TAGS = "disableAllTags" ;
66
68
private static final String ACTION_ENABLE_ALL_TAGS = "enableAllTags" ;
67
69
private static final String ACTION_CLEAR_QUEUE = "clearQueue" ;
@@ -72,6 +74,7 @@ public class PassiveScanApi extends ApiImplementor {
72
74
private static final String PARAM_ID = "id" ;
73
75
private static final String PARAM_ALERT_THRESHOLD = "alertThreshold" ;
74
76
private static final String PARAM_MAX_ALERTS = "maxAlerts" ;
77
+ private static final String PARAM_MAX_SIZE = "maxSize" ;
75
78
76
79
private final ExtensionPassiveScan2 extension ;
77
80
private final PassiveScannersManager scannersManager ;
@@ -97,6 +100,8 @@ public PassiveScanApi(ExtensionPassiveScan2 extension, PassiveScannersManager sc
97
100
new String [] {PARAM_ID , PARAM_ALERT_THRESHOLD }));
98
101
this .addApiAction (
99
102
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 }));
100
105
this .addApiAction (new ApiAction (ACTION_DISABLE_ALL_TAGS ));
101
106
this .addApiAction (new ApiAction (ACTION_ENABLE_ALL_TAGS ));
102
107
this .addApiAction (new ApiAction (ACTION_CLEAR_QUEUE ));
@@ -113,6 +118,7 @@ public PassiveScanApi(ExtensionPassiveScan2 extension, PassiveScannersManager sc
113
118
this .addApiView (currentRule );
114
119
this .addApiView (new ApiView (VIEW_CURRENT_TASKS ));
115
120
this .addApiView (new ApiView (VIEW_MAX_ALERTS_PER_RULE ));
121
+ this .addApiView (new ApiView (VIEW_MAX_BODY_SIZE_IN_BYTES ));
116
122
}
117
123
118
124
@ Override
@@ -162,6 +168,11 @@ public ApiResponse handleApiAction(String name, JSONObject params) throws ApiExc
162
168
case ACTION_SET_MAX_ALERTS_PER_RULE :
163
169
getOptions ().setMaxAlertsPerRule (ApiUtils .getIntParam (params , PARAM_MAX_ALERTS ));
164
170
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 ;
165
176
case ACTION_DISABLE_ALL_TAGS :
166
177
getOptions ()
167
178
.getAutoTagScanners ()
@@ -325,6 +336,12 @@ public ApiResponse handleApiView(String name, JSONObject params) throws ApiExcep
325
336
VIEW_MAX_ALERTS_PER_RULE ,
326
337
Integer .toString (getOptions ().getMaxAlertsPerRule ()));
327
338
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 ;
328
345
default :
329
346
throw new ApiException (ApiException .Type .BAD_VIEW );
330
347
}
0 commit comments