@@ -122,7 +122,7 @@ public void setScannerAttackStrength(String scannerId, String strength) throws P
122
122
clientApi .ascan .setScannerAttackStrength (scannerId , strength , null );
123
123
} catch (ClientApiException e ) {
124
124
e .printStackTrace ();
125
- throw new ProxyException ("Error occurred for setScannerAttackStrength" , e );
125
+ throw new ProxyException ("Error occurred for setScannerAttackStrength for scannerId: " + scannerId + " and strength: " + strength , e );
126
126
}
127
127
}
128
128
@@ -350,7 +350,9 @@ public List<HarEntry> makeRequest(HarRequest request, boolean followRedirect)
350
350
throws ProxyException {
351
351
try {
352
352
String harRequestStr = ClientApiUtils .convertHarRequestToString (request );
353
- return ClientApiUtils .getHarEntries (clientApi .core .sendHarRequest (harRequestStr , Boolean .toString (followRedirect )));
353
+ byte [] response = clientApi .core .sendHarRequest (harRequestStr , Boolean .toString (followRedirect ));
354
+ String responseAsString = new String (response );
355
+ return ClientApiUtils .getHarEntries (response );
354
356
} catch (ClientApiException e ) {
355
357
e .printStackTrace ();
356
358
@@ -450,6 +452,16 @@ public void excludeFromScanner(String regex) {
450
452
}
451
453
}
452
454
455
+ @ Override
456
+ public void setAttackMode () throws ProxyException {
457
+ try {
458
+ clientApi .core .setMode ("attack" );
459
+ } catch (ClientApiException e ) {
460
+ e .printStackTrace ();
461
+ throw new ProxyException (e );
462
+ }
463
+ }
464
+
453
465
@ Override
454
466
public void setMaxDepth (int depth ) {
455
467
try {
@@ -1610,6 +1622,20 @@ public void runStandAloneScript(String scriptName) throws ProxyException {
1610
1622
public void setIncludeInContext (String contextName , String regex ) {
1611
1623
try {
1612
1624
clientApi .context .includeInContext (contextName , regex );
1625
+ } catch (ClientApiException e ) {
1626
+ if ("does_not_exist" .equalsIgnoreCase (e .getCode ())) {
1627
+ createContext (contextName );
1628
+ setIncludeInContext (contextName , regex );
1629
+ } else {
1630
+ e .printStackTrace ();
1631
+ throw new ProxyException (e );
1632
+ }
1633
+ }
1634
+ }
1635
+
1636
+ private void createContext (String contextName ) {
1637
+ try {
1638
+ clientApi .context .newContext (contextName );
1613
1639
} catch (ClientApiException e ) {
1614
1640
e .printStackTrace ();
1615
1641
throw new ProxyException (e );
0 commit comments