From f32e0d1610b5e9a9689c376b7eca4a499291a88b Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Date: Tue, 10 Nov 2026 11:26:06 +0100 Subject: [PATCH] feat(issues): link a finding's issue to the finding itself (#947) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../src/pipeline/issue_creation.rs | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/compliance-agent/src/pipeline/issue_creation.rs b/compliance-agent/src/pipeline/issue_creation.rs index 0576229..2bd48cf 100644 --- a/compliance-agent/src/pipeline/issue_creation.rs +++ b/compliance-agent/src/pipeline/issue_creation.rs @@ -511,9 +511,14 @@ impl IssueSink<'_> { finding: &Finding, title: &str, ) -> Result { + 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 { .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 { +/// 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 { 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] -- 2.54.1