Skip to content

Plugin Directory: Restyle the Gandalf Slack alert for scannability - #781

Closed
obenland wants to merge 2 commits into
WordPress:trunkfrom
obenland:update/gandalf-slack-alert-formatting
Closed

Plugin Directory: Restyle the Gandalf Slack alert for scannability#781
obenland wants to merge 2 commits into
WordPress:trunkfrom
obenland:update/gandalf-slack-alert-formatting

Conversation

@obenland

@obenland obenland commented Aug 10, 2026

Copy link
Copy Markdown
Member

Follow-up to #779. The findings alert is functional but reads as a wall of label: value lines. This restyles it with Slack mrkdwn — structure, weight, and links rather than more text (and no emoji):

  • HeadlineSecurity scan found *2 findings* in *Create* 2.6.2, with the plugin name as a named link to its directory page. The release ref is only appended (as `code`) when it differs from the version, dropping the redundant 2.6.2 (2.6.2).
  • Install count — on its own line, bold at ≥10k instead of the :bangbang: wall. The previous Findings:, Severity:, and Max risk score: lines are gone entirely: the finding count moved into the headline, and each severity and score is visible in the list itself.
  • Findings — each led by a bold *6.5 warning*: badge, with the file reference moved to a continuation line and linked straight to the plugins Trac browser at the scanned ref and line — https://plugins.trac.wordpress.org/browser/{slug}/tags/{ref}/{path}#L{line}, using the same trunk/tags/ split as Plugin_Scan. An …and N more in the full report. line appears when the callback carries more findings than the five shown.
  • Footerwp-admin · Gandalf report as named links, replacing three raw URLs. The plugin page link now lives on the headline title.

Rendered with the same data as the current alert:

Security scan found *2 findings* in *Create* 2.6.2
6,000+ active installs

*6.5 warning*: Create Studio can remotely download the site's full WordPress debug log without per-request local approval.
↳ lib/settings/class-webhook-handler.php:428
*6.3 warning*: Legacy webhook signatures omit freshness and site audience, allowing captured events to be replayed against other installations.
↳ lib/settings/class-webhook-handler.php:108

wp-admin · Gandalf report

(where Create, the path:line references, and the footer are links)

Notes:

  • Everything still flows through slack_dm(), which is text-only — the message renders as mrkdwn (the current alert already relies on that for *bold*). Slack text messages offer no font-size or color control; attachments/Block Kit (severity color bars, fields, buttons) would require a webhook-based transport change in the private repository, so that's left as a possible follow-up.
  • handle_callback() still passes severity_counts and max_risk_score into the notify record even though they're no longer rendered — kept as plumbing for the risk-score suspension follow-up (Plugin Directory: Block a release when a security scan reports a high risk score #777).
  • Untrusted scanner/plugin strings keep the htmlspecialchars( …, ENT_NOQUOTES ) escaping from Plugin Directory: Include findings in security scan alerts #779, including link labels; the untrusted file path segments are additionally rawurlencode()d in the Trac URL, which also keeps | and > from breaking Slack's link syntax, and | is percent-encoded in the callback-supplied report URL for the same reason (verified in a rendering harness with hostile titles and paths).
  • Severity labels render as the scanner reports them (escaped), so a new severity key never breaks or suppresses an alert.

🤖 Generated with Claude Code

@obenland
obenland force-pushed the update/gandalf-slack-alert-formatting branch 3 times, most recently from 32a6826 to 4b458ff Compare August 10, 2026 22:23
Replaces the label: value line list with a Slack-native layout: a headline
linking the plugin name to its directory page, a one-line context row
(installs, severity counts, max risk), findings led by a bold risk score
and severity (severe tiers uppercased) with the file reference linked to
the plugins Trac browser at the scanned ref and line, and a named-link
footer instead of raw URLs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@obenland
obenland force-pushed the update/gandalf-slack-alert-formatting branch from 4b458ff to 0fa51be Compare August 10, 2026 22:25
@obenland
obenland marked this pull request as ready for review August 10, 2026 22:27
Copilot AI lite review requested due to automatic review settings August 10, 2026 22:27
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props obenland.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Plugin Directory’s Gandalf security-scan Slack DM to be more scannable by switching from a “label: value” block to structured Slack mrkdwn (headline with plugin link, install-count emphasis, per-finding badges, and a compact footer with named links).

Changes:

  • Reworked the Slack message header to include a finding-count headline with a named link to the plugin directory page and a cleaner version/release-ref display.
  • Reformatted findings into a readable list with severity/risk badges, optional investigation outcomes, and per-finding Trac file links.
  • Replaced the raw URL footer lines with named links to wp-admin and the Gandalf report.
Suppressed comments (1)

wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-plugin-scan-gandalf.php:369

  • In file_link(), the plugin slug is inserted into the Trac browser URL without URL-encoding. While plugin slugs are usually safe, encoding it as a path segment avoids malformed URLs and prevents characters like | from breaking Slack's <url|label> formatting.
		$url = sprintf(
			'https://plugins.trac.wordpress.org/browser/%s/%s/%s',
			$plugin->post_name,
			'trunk' === $release_ref ? 'trunk' : 'tags/' . rawurlencode( $release_ref ),
			implode( '/', array_map( 'rawurlencode', explode( '/', $file_path ) ) )

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Percent-encode | in the callback-supplied report URL so it cannot end
the URL portion of the Slack <url|label> link early, per Copilot review.
Severity labels now render exactly as the scanner reports them, and the
investigation outcome tag is dropped from the continuation line; the
risk score and linked file reference carry the finding on their own.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@obenland
obenland force-pushed the update/gandalf-slack-alert-formatting branch from def33f0 to 7ec9f1d Compare August 10, 2026 22:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (1)

wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-plugin-scan-gandalf.php:361

  • file_link() appends a Trac line fragment for any non-zero $line, including negative numbers (e.g. -1), which would produce an invalid #L-1 URL fragment and misleading label text. Treat line numbers as positive-only and omit the fragment otherwise.
	/**
	 * Return the highest-risk findings first, bounded for display.
	 *
	 * The callback orders findings by ID, not by severity.
	 *

@bazza bazza closed this in df4f26f Aug 10, 2026
obenland added a commit to obenland/wordpress.org that referenced this pull request Aug 11, 2026
- Group the findings list in a blockquote rail to set it off from the
  headline and footer.
- Pad risk scores to one decimal so 6.0 and 6.5 read as peers.
- Restore the investigation result dropped in the restyle: reproduced
  and conditional findings now carry the result in their badge.
- Link the "…and N more" overflow line to the full report.
- Decode entity-encoded post titles before escaping; they rendered as
  literal &amp; in Slack.

Follow-up to WordPress#779 and WordPress#781.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
obenland added a commit to obenland/wordpress.org that referenced this pull request Aug 11, 2026
Replaces the text-only alert with a structured message: a header block
with the plugin name and version, a findings/installs summary with a
View report button, wp-admin and Plugin page context links, and one
color-barred attachment per finding (red >=9, orange >=6, yellow >=4)
holding the risk score, title, and a File: link to the Trac browser.

The plain-text fallback keeps notifications readable, and the sender
displays as "Gandalf" instead of the dispatching web host.

Requires the notify_slack() array support in the private repository to
deploy first; until then the webhook would reject the array payload.

Follow-up to WordPress#779 and WordPress#781.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants