Skip to content

Commit cb50d2c

Browse files
committed
chore: python compat
1 parent ae6132f commit cb50d2c

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
@@ -860,6 +860,12 @@ def security_comment_template(diff: Diff, config=None) -> str:
860860
# Generate proper manifest URL
861861
manifest_url = Messages.get_manifest_file_url(diff, alert.manifests, config)
862862
# Generate a table row for each alert
863+
ignore_html = (
864+
f"<p><em>Mark as acceptable risk:</em> To ignore this alert only in this pull request, reply with:<br/>"
865+
f"<code>@SocketSecurity ignore {alert.pkg_name}@{alert.pkg_version}</code><br/>"
866+
f"Or ignore all future alerts with:<br/>"
867+
f"<code>@SocketSecurity ignore-all</code></p>"
868+
) if show_ignore else ""
863869
comment += f"""
864870
<!-- start-socket-alert-{alert.pkg_name}@{alert.pkg_version} -->
865871
<tr>
@@ -872,16 +878,13 @@ def security_comment_template(diff: Diff, config=None) -> str:
872878
<summary>{alert.pkg_name}@{alert.pkg_version} - {alert.title}</summary>
873879
<p><strong>Note:</strong> {alert.description}</p>
874880
<p><strong>Source:</strong> <a href="{manifest_url}">Manifest File</a></p>
875-
<p>ℹ️ Read more on:
876-
<a href="{alert.purl}">This package</a> |
877-
<a href="{alert.url}">This alert</a> |
881+
<p>ℹ️ Read more on:
882+
<a href="{alert.purl}">This package</a> |
883+
<a href="{alert.url}">This alert</a> |
878884
<a href="https://socket.dev/alerts/malware">What is known malware?</a></p>
879885
<blockquote>
880886
<p><em>Suggestion:</em> {alert.suggestion}</p>
881-
{f"""<p><em>Mark as acceptable risk:</em> To ignore this alert only in this pull request, reply with:<br/>
882-
<code>@SocketSecurity ignore {alert.pkg_name}@{alert.pkg_version}</code><br/>
883-
Or ignore all future alerts with:<br/>
884-
<code>@SocketSecurity ignore-all</code></p>""" if show_ignore else ""}
887+
{ignore_html}
885888
</blockquote>
886889
</details>
887890
</td>
@@ -919,14 +922,20 @@ def security_comment_template(diff: Diff, config=None) -> str:
919922

920923
# Generate proper manifest URL for license violations
921924
license_manifest_url = Messages.get_manifest_file_url(diff, first_alert.manifests, config)
922-
925+
926+
license_ignore_html = (
927+
f"<p><em>Mark the package as acceptable risk:</em> To ignore this alert only in this pull request, reply with the comment "
928+
f"<code>@SocketSecurity ignore {first_alert.pkg_name}@{first_alert.pkg_version}</code>. "
929+
f"You can also ignore all packages with <code>@SocketSecurity ignore-all</code>. "
930+
f"To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.</p>"
931+
) if show_ignore else ""
923932
comment += f""" </ul>
924933
<p><strong>From:</strong> <a href="{license_manifest_url}">Manifest File</a></p>
925934
<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>
926935
<blockquote>
927936
<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>
928937
<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>
929-
{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 ""}
938+
{license_ignore_html}
930939
</blockquote>
931940
</details>
932941
</td>

0 commit comments

Comments
 (0)