Skip to content

Commit

Permalink
feat: update report link to pypi form (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
miketheman authored Mar 6, 2024
1 parent 6f2a5e1 commit 5756f29
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions inspector/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .deob import decompile, disassemble
from .distribution import _get_dist
from .legacy import parse
from .utilities import mailto_report_link
from .utilities import pypi_report_form


def traces_sampler(sampling_context):
Expand Down Expand Up @@ -205,7 +205,7 @@ def file(project_name, version, first, second, rest, distname, filepath):
except FileNotFoundError:
return abort(404)
file_extension = filepath.split(".")[-1]
report_link = mailto_report_link(project_name, version, filepath, request.url)
report_link = pypi_report_form(project_name, version, filepath, request.url)

details = [detail.html() for detail in basic_details(dist, filepath)]
common_params = {
Expand Down
17 changes: 17 additions & 0 deletions inspector/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,20 @@ def mailto_report_link(project_name, version, file_path, request_url):
f"subject={urllib.parse.quote(subject)}"
f"&body={urllib.parse.quote(message_body)}"
)


def pypi_report_form(project_name, version, file_path, request_url):
"""
Generate a URL to PyPI malware report for malicious code.
"""
summary = (
f"Version: {version}\n"
f"File Path: {file_path}\n"
"Additional Information:\n\n"
)

return (
f"https://pypi.org/project/{project_name}/submit-malware-report/"
f"?inspector_link={request_url}"
f"&summary={urllib.parse.quote(summary)}"
)

0 comments on commit 5756f29

Please sign in to comment.