Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions docker_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import csv
import pandas as pd
import logging
import html
from typing import List, Tuple, Dict, Optional
from datetime import datetime
from fpdf import FPDF
Expand Down Expand Up @@ -1240,15 +1241,10 @@ def _escape_html(self, text: str) -> str:
if not text:
return ""

html_escape_table = {
"&": "&",
'"': """,
"'": "'",
">": ">",
"<": "&lt;",
}
if not isinstance(text, str):
text = str(text)

return "".join(html_escape_table.get(c, c) for c in str(text))
return html.escape(text, quote=True)

def main():
"""Main function to run the security scanner."""
Expand Down
12 changes: 4 additions & 8 deletions report_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import csv
import re
import logging
import html
from typing import Dict, List, Optional
from datetime import datetime
from fpdf import FPDF
Expand Down Expand Up @@ -467,15 +468,10 @@ def _escape_html(self, text: str) -> str:
if not text:
return ""

html_escape_table = {
"&": "&amp;",
'"': "&quot;",
"'": "&#x27;",
">": "&gt;",
"<": "&lt;",
}
if not isinstance(text, str):
text = str(text)

return "".join(html_escape_table.get(c, c) for c in str(text))
return html.escape(text, quote=True)

def _count_by_severity(self, vulnerabilities: List[Dict]) -> Dict[str, int]:
"""
Expand Down