Files
pruefwerk/compliance-core/src/models/issue.rs
T
Sharang ParnerkarandClaude Opus 5.5 8c13fbaced
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 / Agent integration (pull_request) Successful in 4m27s
CI / Check (pull_request) Successful in 17m54s
feat(issues): closing or reopening a Prüfwerk issue in Gitea updates the finding (#953)
The managed Git source's org webhook now handles `issues` events. A
person closing an issue Prüfwerk opened resolves the undecided finding,
recorded as "closed in the ticket" with the Gitea login; reopening it
makes the finding open again. A decision already made in Prüfwerk is
kept. Events whose sender is the issue's author (Prüfwerk's bot user,
which opened it) are ignored, and the back-sync never calls Gitea, so
nothing loops; the issue record is updated first, so the outbound sync
has nothing left to comment or close.

CVE issues closed in Gitea only record the close and who did it, no VEX
status. The scan leaves such an issue closed while the CVE is still
found, and forgets the close once a complete scan no longer finds it, so
a CVE that comes back reopens the issue as before.

The platform API names the events the webhook needs (`webhook_events`);
Prüfwerk cannot change the webhook itself, so existing webhooks need
the Issues event added in Gitea. The finding history shows
"Im Ticket geschlossen von <login>".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 12:00:40 +01:00

87 lines
2.4 KiB
Rust

use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum TrackerType {
GitHub,
GitLab,
Gitea,
Jira,
}
impl std::fmt::Display for TrackerType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::GitHub => write!(f, "github"),
Self::GitLab => write!(f, "gitlab"),
Self::Gitea => write!(f, "gitea"),
Self::Jira => write!(f, "jira"),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum IssueStatus {
Open,
InProgress,
Closed,
Resolved,
}
impl std::fmt::Display for IssueStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Open => write!(f, "open"),
Self::InProgress => write!(f, "in_progress"),
Self::Closed => write!(f, "closed"),
Self::Resolved => write!(f, "resolved"),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TrackerIssue {
#[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
pub id: Option<bson::oid::ObjectId>,
pub finding_id: String,
pub tracker_type: TrackerType,
pub external_id: String,
pub external_url: String,
pub title: String,
pub status: IssueStatus,
/// The tracker user who closed the issue there (#953), while it stays
/// closed: a person's decision the scan does not undo on its own.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub closed_in_tracker: Option<String>,
#[serde(with = "super::serde_helpers::bson_datetime")]
pub created_at: DateTime<Utc>,
#[serde(with = "super::serde_helpers::bson_datetime")]
pub updated_at: DateTime<Utc>,
}
impl TrackerIssue {
pub fn new(
finding_id: String,
tracker_type: TrackerType,
external_id: String,
external_url: String,
title: String,
) -> Self {
let now = Utc::now();
Self {
id: None,
finding_id,
tracker_type,
external_id,
external_url,
title,
status: IssueStatus::Open,
closed_in_tracker: None,
created_at: now,
updated_at: now,
}
}
}