Skip to content
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

feat: update report link to pypi form #158

Merged
merged 2 commits into from
Mar 6, 2024
Merged
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
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)}"
)
Loading