Skip to content

Commit 799b35e

Browse files
committed
chore: python compat
1 parent 7dca26c commit 799b35e

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

socketsecurity/core/messages.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,12 @@ def security_comment_template(diff: Diff, config=None) -> str:
826826
# Generate proper manifest URL
827827
manifest_url = Messages.get_manifest_file_url(diff, alert.manifests, config)
828828
# Generate a table row for each alert
829+
ignore_html = (
830+
f"<p><em>Mark as acceptable risk:</em> To ignore this alert only in this pull request, reply with:<br/>"
831+
f"<code>@SocketSecurity ignore {alert.pkg_name}@{alert.pkg_version}</code><br/>"
832+
f"Or ignore all future alerts with:<br/>"
833+
f"<code>@SocketSecurity ignore-all</code></p>"
834+
) if show_ignore else ""
829835
comment += f"""
830836
<!-- start-socket-alert-{alert.pkg_name}@{alert.pkg_version} -->
831837
<tr>
@@ -838,16 +844,13 @@ def security_comment_template(diff: Diff, config=None) -> str:
838844
<summary>{alert.pkg_name}@{alert.pkg_version} - {alert.title}</summary>
839845
<p><strong>Note:</strong> {alert.description}</p>
840846
<p><strong>Source:</strong> <a href="{manifest_url}">Manifest File</a></p>
841-
<p>ℹ️ Read more on:
842-
<a href="{alert.purl}">This package</a> |
843-
<a href="{alert.url}">This alert</a> |
847+
<p>ℹ️ Read more on:
848+
<a href="{alert.purl}">This package</a> |
849+
<a href="{alert.url}">This alert</a> |
844850
<a href="https://socket.dev/alerts/malware">What is known malware?</a></p>
845851
<blockquote>
846852
<p><em>Suggestion:</em> {alert.suggestion}</p>
847-
{f"""<p><em>Mark as acceptable risk:</em> To ignore this alert only in this pull request, reply with:<br/>
848-
<code>@SocketSecurity ignore {alert.pkg_name}@{alert.pkg_version}</code><br/>
849-
Or ignore all future alerts with:<br/>
850-
<code>@SocketSecurity ignore-all</code></p>""" if show_ignore else ""}
853+
{ignore_html}
851854
</blockquote>
852855
</details>
853856
</td>
@@ -885,14 +888,20 @@ def security_comment_template(diff: Diff, config=None) -> str:
885888

886889
# Generate proper manifest URL for license violations
887890
license_manifest_url = Messages.get_manifest_file_url(diff, first_alert.manifests, config)
888-
891+
892+
license_ignore_html = (
893+
f"<p><em>Mark the package as acceptable risk:</em> To ignore this alert only in this pull request, reply with the comment "
894+
f"<code>@SocketSecurity ignore {first_alert.pkg_name}@{first_alert.pkg_version}</code>. "
895+
f"You can also ignore all packages with <code>@SocketSecurity ignore-all</code>. "
896+
f"To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.</p>"
897+
) if show_ignore else ""
889898
comment += f""" </ul>
890899
<p><strong>From:</strong> <a href="{license_manifest_url}">Manifest File</a></p>
891900
<p>ℹ️ Read more on: <a href="{first_alert.purl}">This package</a> | <a href="https://socket.dev/alerts/license">What is a license policy violation?</a></p>
892901
<blockquote>
893902
<p><em>Next steps:</em> Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at <strong>support@socket.dev</strong>.</p>
894903
<p><em>Suggestion:</em> Find a package that does not violate your license policy or adjust your policy to allow this package's license.</p>
895-
{f'<p><em>Mark the package as acceptable risk:</em> To ignore this alert only in this pull request, reply with the comment <code>@SocketSecurity ignore {first_alert.pkg_name}@{first_alert.pkg_version}</code>. You can also ignore all packages with <code>@SocketSecurity ignore-all</code>. To ignore an alert for all future pull requests, use Socket\'s Dashboard to change the triage state of this alert.</p>' if show_ignore else ""}
904+
{license_ignore_html}
896905
</blockquote>
897906
</details>
898907
</td>

0 commit comments

Comments
 (0)