fix(semgrep): short finding titles, rule messages shown as Markdown #529

Merged
sharang merged 1 commits from fix/a1-semgrep-titles into main 2026-10-08 21:23:21 +00:00
Owner

What was wrong (stage tests 23/25, blocker): the vendored GitLab semgrep rules (#492) have long Markdown messages with paragraphs and Java/C#/Python code examples. semgrep.rs used extra.message as both title and description, so:

  • the finding title (list, detail page and tracker issue title) was a wall of text;
  • the description collapsed the code into one paragraph.

Changes:

  • Title:
    • metadata.shortDescription when present (all 148 bundled GitLab rules have one);
    • otherwise the message's first sentence on one line, without backticks, cut at a word after 120 characters;
    • our own CRA rules keep their first sentence;
    • the description keeps the whole message;
    • fingerprints are unchanged (rule, path, line), so there is no close/reopen churn.
  • Dashboard: a semgrep finding's description is rendered as Markdown with the existing safe renderer (components/markdown.rs: raw HTML shown as text, only http(s)/mailto/relative links). Other scanners' plain-text descriptions are shown as before.
  • Tracker issues: new issues get the short title. The body already carries the full message, which Gitea renders as Markdown.
  • Startup migration (finding_migrations.rs, logged as semgrep_titles in migrated stored findings): stored semgrep findings with a multi-line title or one over 160 characters get their bundled rule's short description, or the first sentence. It is idempotent.

Not covered: open tracker issues on stage keep their old long titles, because trackers only update an issue's status. Prod has none of these findings yet.

Tests:

  • unit tests: GitLab message plus metadata gives the short description; without metadata, the first sentence and the cut; every bundled GitLab rule has a short description; the existing semgrep tests;
  • tests/finding_migrations.rs against mongo:7, including a GitLab finding stored with its whole message;
  • clippy with CI flags for the agent and both dashboard builds; fmt.

Stage re-test:

  1. After the deploy, the agent log line migrated stored findings shows semgrep_titles > 0, once; the next start shows nothing.
  2. Befunde on a Java/C#/Python target (e.g. the kitchenasty or .NET one): GitLab-rule findings (gitlab-…) have one-line titles such as "Sensitive cookie without 'HttpOnly' flag".
  3. Open one: Beschreibung shows paragraphs, lists and code blocks rendered.
  4. Rescan the target: no new findings, and no finding closed and reopened. A new issue in Gitea has the short title.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

**What was wrong** (stage tests 23/25, blocker): the vendored GitLab semgrep rules (#492) have long Markdown messages with paragraphs and Java/C#/Python code examples. `semgrep.rs` used `extra.message` as both title and description, so: - the finding title (list, detail page and tracker issue title) was a wall of text; - the description collapsed the code into one paragraph. **Changes:** - **Title:** - `metadata.shortDescription` when present (all 148 bundled GitLab rules have one); - otherwise the message's first sentence on one line, without backticks, cut at a word after 120 characters; - our own CRA rules keep their first sentence; - the description keeps the whole message; - fingerprints are unchanged (rule, path, line), so there is no close/reopen churn. - **Dashboard:** a semgrep finding's description is rendered as Markdown with the existing safe renderer (`components/markdown.rs`: raw HTML shown as text, only http(s)/mailto/relative links). Other scanners' plain-text descriptions are shown as before. - **Tracker issues:** new issues get the short title. The body already carries the full message, which Gitea renders as Markdown. - **Startup migration** (`finding_migrations.rs`, logged as `semgrep_titles` in `migrated stored findings`): stored semgrep findings with a multi-line title or one over 160 characters get their bundled rule's short description, or the first sentence. It is idempotent. **Not covered:** open tracker issues on stage keep their old long titles, because trackers only update an issue's status. Prod has none of these findings yet. **Tests:** - unit tests: GitLab message plus metadata gives the short description; without metadata, the first sentence and the cut; every bundled GitLab rule has a short description; the existing semgrep tests; - `tests/finding_migrations.rs` against mongo:7, including a GitLab finding stored with its whole message; - clippy with CI flags for the agent and both dashboard builds; fmt. **Stage re-test:** 1. After the deploy, the agent log line `migrated stored findings` shows `semgrep_titles` > 0, once; the next start shows nothing. 2. **Befunde** on a Java/C#/Python target (e.g. the kitchenasty or .NET one): GitLab-rule findings (`gitlab-…`) have one-line titles such as "Sensitive cookie without 'HttpOnly' flag". 3. Open one: **Beschreibung** shows paragraphs, lists and code blocks rendered. 4. Rescan the target: no new findings, and no finding closed and reopened. A new issue in Gitea has the short title. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 1 commit 2026-10-08 21:13:07 +00:00
fix(semgrep): short finding titles, rule messages shown as Markdown
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 8m30s
78e6185822
The vendored GitLab rules (#492) carry pages of Markdown with code
examples as their message, and the scanner used the message as both the
title and the description: the finding title, the findings list and the
tracker issue title were a wall of text, and the description showed the
code collapsed into one paragraph.

- Title: the rule's metadata.shortDescription (every GitLab rule has
  one), else the message's first sentence on one line, without code
  marks, cut at a word after 120 characters. The description keeps the
  whole message. Fingerprints are unchanged (rule, path, line).
- Dashboard: a semgrep finding's description is rendered as Markdown
  through the existing safe renderer (raw HTML shown as text, only web
  and mail links); other scanners' plain text is shown as before.
- Startup migration: stored semgrep findings with a multi-line or longer
  title get the short description of their bundled rule, else the first
  sentence (logged as semgrep_titles in "migrated stored findings").
  Open tracker issues keep their old titles (trackers only change an
  issue's status); new issues get the short title.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang merged commit c8af053d9d into main 2026-10-08 21:23:21 +00:00
Sign in to join this conversation.