-
Notifications
You must be signed in to change notification settings - Fork 19
Changes to check for response other than 200 OK #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| from array import array | ||
| from time import sleep | ||
| import difflib | ||
| import re | ||
| except ImportError: | ||
| print "Failed to load dependencies. This issue maybe caused by using an unstable Jython version." | ||
|
|
||
|
|
@@ -71,28 +72,46 @@ def doPassiveScan(self, baseRequestResponse): | |
| # This is, because the insertionPoint idea doesn't work well | ||
| # for this test. | ||
| scan_issues = [] | ||
|
|
||
| if not self.isGet(baseRequestResponse.getRequest()): | ||
| baseRequestResponse = self.switchMethod(baseRequestResponse) | ||
| if (not self.isScannableRequest(baseRequestResponse) or | ||
| not self.isScript(baseRequestResponse) or | ||
| self.isProtected(baseRequestResponse)): | ||
| return None | ||
| newRequestResponse = self.sendUnauthenticatedRequest(baseRequestResponse) | ||
| issue = self.compareResponses(newRequestResponse, baseRequestResponse) | ||
| if not issue: | ||
| return None | ||
| # If response is script, check if script is dynamic | ||
| if self.isScript(newRequestResponse): | ||
| # sleep, in case this is a generically time stamped script | ||
| sleep(1) | ||
| secondRequestResponse = self.sendUnauthenticatedRequest(baseRequestResponse) | ||
| isDynamic = self.compareResponses(secondRequestResponse, newRequestResponse) | ||
| if isDynamic: | ||
| issue = self.reportDynamicOnly(newRequestResponse, baseRequestResponse, | ||
| secondRequestResponse) | ||
| scan_issues.append(issue) | ||
| return scan_issues | ||
| if(self.isScannableRequest(newRequestResponse)): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this could be flattened out by an early return as well.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is modified by changing the if conditions, the code is more flattened out in recent pull commit. |
||
| issue = self.compareResponses(newRequestResponse, baseRequestResponse) | ||
| if not issue: | ||
| return None | ||
| # If response is script, check if script is dynamic | ||
| if self.isScript(newRequestResponse): | ||
| # sleep, in case this is a generically time stamped script | ||
| sleep(1) | ||
| secondRequestResponse = self.sendUnauthenticatedRequest(baseRequestResponse) | ||
| isDynamic = self.compareResponses(secondRequestResponse, newRequestResponse) | ||
| if isDynamic: | ||
| issue = self.reportDynamicOnly(newRequestResponse, baseRequestResponse, | ||
| secondRequestResponse) | ||
| scan_issues.append(issue) | ||
| return scan_issues | ||
| else: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks to me like this else is not necessary. safe an indent. safe a little cats life. Makes the code more readable.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is fixed as per comments. |
||
| if(self.hasScriptContent(newRequestResponse)): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. small change - please check if it does not have script content - return None -> less indentation for the rest. :) |
||
| issue = self.compareResponses(newRequestResponse, baseRequestResponse) | ||
| if not issue: | ||
| return None | ||
|
|
||
| if self.isScript(newRequestResponse): | ||
| # sleep, in case this is a generically time stamped script | ||
| sleep(1) | ||
| secondRequestResponse = self.sendUnauthenticatedRequest(baseRequestResponse) | ||
| isDynamic = self.compareResponses(secondRequestResponse, newRequestResponse) | ||
| if isDynamic: | ||
| issue = self.reportDynamicOnly(newRequestResponse, baseRequestResponse, | ||
| secondRequestResponse) | ||
| scan_issues.append(issue) | ||
| return scan_issues | ||
| else: | ||
| return None | ||
|
|
||
| def sendUnauthenticatedRequest(self, requestResponse): | ||
| """ | ||
|
|
@@ -341,6 +360,35 @@ def consolidateDuplicateIssues(self, existingIssue, newIssue): | |
| else: | ||
| return 0 | ||
|
|
||
| def has401StatusCode(self, requestResponse): | ||
| """ | ||
| Checks if the status code of the request is 401 | ||
| """ | ||
| response = requestResponse.getResponse() | ||
| responseInfo = self._helpers.analyzeResponse(response) | ||
| statusCode = responseInfo.getStatusCode() | ||
| return statusCode == 401 | ||
|
|
||
| def hasScriptContent(self,requestResponse): | ||
| """ | ||
| Checks if the response of the request contains the scipt content | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo "script"
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo is fixed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. somehow this did not make it all the way to your commit
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo is fixed in recent commit. |
||
| """ | ||
| nResponse = requestResponse.getResponse() | ||
| nResponseInfo = self._helpers.analyzeResponse(nResponse) | ||
| nBodyOffset = nResponseInfo.getBodyOffset() | ||
| nBody = nResponse.tostring()[nBodyOffset:] | ||
| first_char = nBody[0:1] | ||
| if(first_char in "[" or first_char in "{"): | ||
| return "first_char" | ||
| matchvar = re.match( r'(.*)\s*(var|let|const) ([a-zA-Z])+\s*=(.*)|(.*)\s*(window.) ([a-zA-Z])+\s*=(.*)', nBody,re.M|re.I) | ||
| matchfunction=re.match( r'(.*)\s*function\((.*)\)(.*)', nBody,re.M|re.I) | ||
|
|
||
| if matchvar: | ||
| return matchvar | ||
| if matchfunction: | ||
| return matchfunction | ||
| else: | ||
| return None | ||
|
|
||
| class ScanIssue(IScanIssue): | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.