Plugin Directory: Restyle the Gandalf Slack alert for scannability - #781
Plugin Directory: Restyle the Gandalf Slack alert for scannability#781obenland wants to merge 2 commits into
Conversation
32a6826 to
4b458ff
Compare
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>
4b458ff to
0fa51be
Compare
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
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>
def33f0 to
7ec9f1d
Compare
There was a problem hiding this comment.
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-1URL 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.
*
- 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 & in Slack. Follow-up to WordPress#779 and WordPress#781. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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>
Follow-up to #779. The findings alert is functional but reads as a wall of
label: valuelines. This restyles it with Slack mrkdwn — structure, weight, and links rather than more text (and no emoji):Security 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 redundant2.6.2 (2.6.2).:bangbang:wall. The previousFindings:,Severity:, andMax risk score:lines are gone entirely: the finding count moved into the headline, and each severity and score is visible in the list itself.*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 sametrunk/tags/split asPlugin_Scan. An…and N more in the full report.line appears when the callback carries more findings than the five shown.wp-admin · Gandalf reportas 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:
(where Create, the
path:linereferences, and the footer are links)Notes:
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 passesseverity_countsandmax_risk_scoreinto 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).htmlspecialchars( …, ENT_NOQUOTES )escaping from Plugin Directory: Include findings in security scan alerts #779, including link labels; the untrusted file path segments are additionallyrawurlencode()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).🤖 Generated with Claude Code