Skip to content

Commit

Permalink
fixing unicode bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ajinabraham committed Mar 7, 2017
1 parent d209684 commit df858f0
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions core/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ def general_code_analysis(paths):
for filename in files:
full_file_path = os.path.join(root, filename)
relative_path = full_file_path.replace(path, "")
all_files.append({relative_path.replace("/", "", 1): full_file_path.replace(settings.UPLOAD_FOLDER, "", 1)})
all_files.append({relative_path.replace(
"/", "", 1): full_file_path.replace(settings.UPLOAD_FOLDER, "", 1)})
data = is_valid_node(filename, full_file_path)
if data is not None:
# print relative_path
Expand Down Expand Up @@ -210,9 +211,10 @@ def general_code_analysis(paths):
finding["lines"] = get_lines(
line_no, lines)
finding["filename"] = filename
finding["path"] = full_file_path.replace(settings.UPLOAD_FOLDER,"",1)
finding["path"] = full_file_path.replace(
settings.UPLOAD_FOLDER, "", 1)
finding["sha2"] = utils.gen_sha256_hash(
str(finding["lines"]))
finding["lines"].encode(encoding="utf-8", errors="replace"))
security_issues.append(finding)
# Vulnerability Regex Match
for regex in scan_rules["vuln_regex"].iterkeys():
Expand All @@ -227,9 +229,10 @@ def general_code_analysis(paths):
finding["lines"] = get_lines(
line_no, lines)
finding["filename"] = filename
finding["path"] = full_file_path.replace(settings.UPLOAD_FOLDER,"",1)
finding["path"] = full_file_path.replace(
settings.UPLOAD_FOLDER, "", 1)
finding["sha2"] = utils.gen_sha256_hash(
str(finding["lines"]))
finding["lines"].encode(encoding="utf-8", errors="replace"))
security_issues.append(finding)
# Vulnerability Multi Regex Match
for mulregex in scan_rules["vuln_mul_regex"].iterkeys():
Expand All @@ -249,9 +252,10 @@ def general_code_analysis(paths):
finding["lines"] = get_lines(
line_no, lines)
finding["filename"] = filename
finding["path"] = full_file_path.replace(settings.UPLOAD_FOLDER,"",1)
finding["path"] = full_file_path.replace(
settings.UPLOAD_FOLDER, "", 1)
finding["sha2"] = utils.gen_sha256_hash(
str(finding["lines"]))
finding["lines"].encode(encoding="utf-8", errors="replace"))
security_issues.append(finding)
# Dynamic Regex
for dynregex in scan_rules["vuln_dyn_regex"].iterkeys():
Expand Down Expand Up @@ -282,9 +286,9 @@ def general_code_analysis(paths):
finding[
"filename"] = filename
finding[
"path"] = full_file_path.replace(settings.UPLOAD_FOLDER,"",1)
"path"] = full_file_path.replace(settings.UPLOAD_FOLDER, "", 1)
finding["sha2"] = utils.gen_sha256_hash(
str(finding["lines"]))
finding["lines"].encode(encoding="utf-8", errors="replace"))
security_issues.append(
finding)
# Good Finding String Match
Expand All @@ -300,9 +304,10 @@ def general_code_analysis(paths):
finding["lines"] = get_lines(
line_no, lines)
finding["filename"] = filename
finding["path"] = full_file_path.replace(settings.UPLOAD_FOLDER,"",1)
finding["path"] = full_file_path.replace(
settings.UPLOAD_FOLDER, "", 1)
finding["sha2"] = utils.gen_sha256_hash(
str(finding["lines"]))
finding["lines"].encode(encoding="utf-8", errors="replace"))
good_finding.append(finding)
# Missing Security Headers String Match
for header in scan_rules["missing_sec_header"].iterkeys():
Expand Down

0 comments on commit df858f0

Please sign in to comment.