use allow_core::{AllowEntry, Finding, FindingKind, LastSeen, Lifecycle, SimpleDate};
use crate::selector_from_finding;
pub(super) const BASELINE_DEBT_DEFAULT_DAYS: i64 = 67;
pub(super) fn default_baseline_expiry() -> String {
SimpleDate::today_utc_approx()
.add_days(BASELINE_DEBT_DEFAULT_DAYS)
.to_string()
}
pub(super) fn entry_from_finding(finding: &Finding, index: usize, expires: &str) -> AllowEntry {
AllowEntry {
id: format!("allow-{index:04}"),
kind: finding.kind,
family: finding.family.clone(),
path: Some(finding.path.clone()),
glob: None,
owner: "unowned".to_string(),
classification: "baseline_debt".to_string(),
reason: "Generated by cargo-allow propose; requires human review.".to_string(),
evidence: if finding.kind == FindingKind::Unsafe {
vec!["TODO: add unsafe-review or boundary-test evidence".to_string()]
} else {
Vec::new()
},
links: Vec::new(),
occurrence_limit: None,
lifecycle: Lifecycle {
created: Some(SimpleDate::today_utc_approx().to_string()),
review_after: None,
expires: Some(expires.to_string()),
},
selector: selector_from_finding(finding),
last_seen: finding.span.as_ref().map(|s| LastSeen {
line: s.line,
column: s.column,
}),
}
}