forked from PortSwigger/bambdas
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
19 additions
and
5 deletions.
There are no files selected for viewing
24 changes: 19 additions & 5 deletions
24
CustomColumn/Proxy/HTTP/SalesForce/SOQLErrorMessages.bambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,33 @@ | ||
/** | ||
* Detect specific SOQL error messages in response body | ||
* Detect specific SOQL and SOSL error messages in response body and add annotations | ||
* @author Aussan Saad-Ali | ||
**/ | ||
|
||
// Check if the response contains specific SOQL error messages | ||
// Check if the response is null | ||
if (requestResponse.response() == null) { | ||
return ""; | ||
} | ||
|
||
// Check if the response contains specific SOQL or SOSL error messages | ||
if (requestResponse.hasResponse()) { | ||
var responseBody = requestResponse.response().bodyToString().trim().toLowerCase(); | ||
|
||
// Check for specific SOQL error messages | ||
boolean isSOQLError = responseBody.contains("system.queryexception") || responseBody.contains("mismatched character '<eof>' expecting '''"); | ||
|
||
// Return specific messages if SOQL error detected | ||
// Check for specific SOSL error messages | ||
boolean isSOSLError = responseBody.contains("system.searchexception: search term must be longer than one character"); | ||
|
||
// Add notes and return specific messages if SOQL or SOSL error detected | ||
if (isSOQLError) { | ||
return "SOQL error found in response"; | ||
String note = "SOQL error found in response"; | ||
requestResponse.annotations().setNotes(note); | ||
return note; | ||
} else if (isSOSLError) { | ||
String note = "SOSL error found in response"; | ||
requestResponse.annotations().setNotes(note); | ||
return note; | ||
} | ||
} | ||
|
||
return ""; // Return empty if no relevant data is found | ||
return ""; // Return empty if no relevant data is found |