Skip to content

Commit

Permalink
Merge pull request #698 from CybercentreCanada/bugfix/dividing-comment
Browse files Browse the repository at this point in the history
Adding further protections for dividing comment splitting
  • Loading branch information
cccs-kevin authored Feb 21, 2024
2 parents 964fe83 + 35b8385 commit 7f1fbba
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion jsjaws.py
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,15 @@ def _run_the_gauntlet(self, request, file_path, file_content, subsequent_run: bo
# If we are attempting to determine if there is any JavaScript that was not generated by JsJaws, and if so,
# then we want to run that. If not, then get outta here!
if f"{DIVIDING_COMMENT}\n".encode() in file_content:
_, script_we_did_not_generate = file_content.split(f"{DIVIDING_COMMENT}\n".encode())
split_content = file_content.split(f"{DIVIDING_COMMENT}\n".encode())
if len(split_content) == 2:
_, script_we_did_not_generate = split_content
# Looks like a file generated by JsJaws and attached as supplementary was resubmitted for analysis.
# Therefore we have to massage the file contents
elif len(split_content) > 2:
_, script_we_did_not_generate = split_content[-2:]
else:
script_we_did_not_generate = file_content
if script_we_did_not_generate == b"" and not self.sus_form_actions:
self.log.debug("No JavaScript file to analyze...")
return
Expand Down

0 comments on commit 7f1fbba

Please sign in to comment.