feat(issues): link a finding's issue to the finding itself (#947) (#948)
CI / Check (push) Skipped
CI / Agent integration (push) Skipped
CI / Detect Changes (push) Successful in 4s
CI / Deploy Dashboard (push) Skipped
CI / Deploy Docs (push) Skipped
CI / Deploy MCP (push) Skipped
CI / Deploy Agent (push) Successful in 5m55s

The "Open in Prüfwerk" link in a finding's issue went to the target's
whole finding list. It now opens the finding's own page
(/findings/{id}), where its status is set; a group (#464) links to its
own page. The link stays https-only and is left out for a finding
without an id. CVE issues and the new-findings notification keep their
links.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit was merged in pull request #948.
This commit is contained in:
sharangandClaude Opus 5.5 committed 2026-11-10 13:48:43 +00:00
1 parent d274c68ecb
commit b9acabb6ba
1 file changed
+26 -17
+26 -17
View File
@@ -511,9 +511,14 @@ impl IssueSink<'_> {
finding: &Finding,
title: &str,
) -> Result<TrackerIssue, CoreError> {
let finding_id = finding
.id
.as_ref()
.map(|id| id.to_hex())
.unwrap_or_default();
let mut body = format_issue_body(finding);
if self.managed {
if let Some(link) = finding_link(&self.dashboard, self.repo_id) {
if let Some(link) = finding_link(&self.dashboard, &finding_id) {
body.push_str(&format!(
"\n[Open in Prüfwerk / In Prüfwerk öffnen]({link})"
));
@@ -540,11 +545,7 @@ impl IssueSink<'_> {
.await?
}
};
issue.finding_id = finding
.id
.as_ref()
.map(|id| id.to_hex())
.unwrap_or_default();
issue.finding_id = finding_id;
self.record(finding, &issue).await;
Ok(issue)
}
@@ -706,13 +707,18 @@ fn cra_requirements(control_refs: &[String]) -> Vec<String> {
.collect()
}
/// The finding list of a target in the Prüfwerk dashboard; `None` unless the
/// dashboard's public origin is an https URL.
fn finding_link(dashboard: &str, target_id: &str) -> Option<String> {
/// A finding's page in the Prüfwerk dashboard (#947), where its status is
/// set; a group (#464) has its own id and so its own page. `None` unless the
/// dashboard's public origin is an https URL and the finding has an id.
///
/// # Arguments
///
/// * `dashboard` - the dashboard's public origin (`DASHBOARD_PUBLIC_URL`)
/// * `finding_id` - the finding's id as hex, empty when it has none
fn finding_link(dashboard: &str, finding_id: &str) -> Option<String> {
let dashboard = dashboard.trim_end_matches('/');
dashboard
.starts_with("https://")
.then(|| format!("{dashboard}/findings?target={target_id}"))
(dashboard.starts_with("https://") && !finding_id.is_empty())
.then(|| format!("{dashboard}/findings/{finding_id}"))
}
/// The ids of `names` among the ensured labels; a name without an id is left
@@ -924,13 +930,16 @@ mod tests {
}
#[test]
fn links_only_to_an_https_dashboard() {
fn links_the_finding_page_of_an_https_dashboard() {
let id = "6560a1b2c3d4e5f601234567";
assert_eq!(
finding_link("https://pruefwerk.breakpilot.com/", "t1").as_deref(),
Some("https://pruefwerk.breakpilot.com/findings?target=t1")
finding_link("https://pruefwerk.breakpilot.com/", id).as_deref(),
Some("https://pruefwerk.breakpilot.com/findings/6560a1b2c3d4e5f601234567")
);
assert_eq!(finding_link("", "t1"), None);
assert_eq!(finding_link("http://x", "t1"), None);
assert_eq!(finding_link("", id), None);
assert_eq!(finding_link("http://x", id), None);
// a finding without an id has no page to link
assert_eq!(finding_link("https://pruefwerk.breakpilot.com", ""), None);
}
#[test]