refactor: rip out the legacy TrackedRepository / repositories path
CI / Check (pull_request) Successful in 5m29s
CI / Detect Changes (pull_request) Has been skipped
CI / Deploy Agent (pull_request) Has been skipped
CI / Deploy Dashboard (pull_request) Has been skipped
CI / Deploy Docs (pull_request) Has been skipped
CI / Deploy MCP (pull_request) Has been skipped
CI / Check (pull_request) Successful in 5m29s
CI / Detect Changes (pull_request) Has been skipped
CI / Deploy Agent (pull_request) Has been skipped
CI / Deploy Dashboard (pull_request) Has been skipped
CI / Deploy Docs (pull_request) Has been skipped
CI / Deploy MCP (pull_request) Has been skipped
Onboarded targets are now the sole persisted entity. The legacy `TrackedRepository` model, the `repositories` collection, the `/repositories` API, the Repositories dashboard page, the one-shot migration, and the `UNIFIED_PIPELINE` transition flag are all removed. Net −1.7k LOC. Agent - New internal `pipeline::repo_view::RepoView` (non-persisted) replaces the `TrackedRepository` model; it's projected from an `OnboardedTarget` + its code artifact by `RepoView::from_target` (the old `repo_view_from_target`), so the scan/PR-review pipeline is byte-for-byte the same behaviour it already ran on the unified path — only the type's origin changed. - `run_scan` always runs the unified `run_target`; the legacy `orchestrator::run` and the `unified_pipeline` flag are gone. `run_pr_review` resolves the target from `onboarded_targets`. - Webhooks (github/gitea/gitlab), the CVE monitor, graph build, chat embeddings, health stats, and the pentest repo lookup all read `onboarded_targets`. - `delete_target` now cascades the full downstream set (findings, sbom, scans, cve, tracker issues, graph, embeddings, DAST targets + pentest sessions and their children) — matching the old repository delete. - `get_ssh_public_key` moved to the health handler; `repositories()` accessor, `repos.rs`, and `migrate/` deleted. Core - `TrackedRepository` removed; `ScanTrigger` stays. `unified_pipeline` config field removed. Dashboard - Repositories page + route deleted; overview / graph / chat / pentest-wizard read onboarded targets; `infrastructure/repositories.rs` trimmed to just the SSH-key fetch. Tests - Legacy repositories-API and migration integration tests removed; tenant isolation, cascade-delete, and stats tests repointed to `/targets` / `onboarded_targets`. `git.rs` gains a `sanitize_repo_dir` unit test. Local: fmt clean; agent/mcp clippy clean; dashboard server+web compile; core + agent lib tests (32) pass; integration tests compile. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
87f240b26f
commit
dadccb9264
@@ -49,11 +49,6 @@ pub struct AgentConfig {
|
||||
/// of tenants to iterate. When `None` or unreachable, scheduler
|
||||
/// falls back to `SCHEDULER_TENANT_IDS` env (M7.2-C).
|
||||
pub tenant_registry_url: Option<String>,
|
||||
/// When true, `run_scan` dispatches to the unified `run_target` pipeline
|
||||
/// (reads `onboarded_targets`) instead of the legacy repository pipeline.
|
||||
/// Env `UNIFIED_PIPELINE`. Defaults on; set `UNIFIED_PIPELINE=0` to use the
|
||||
/// legacy repository pipeline.
|
||||
pub unified_pipeline: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
|
||||
@@ -44,6 +44,6 @@ pub use pentest::{
|
||||
PentestStatus, PentestStrategy, SeverityDistribution, TestUserRecord, TesterInfo,
|
||||
ToolCallRecord,
|
||||
};
|
||||
pub use repository::{ScanTrigger, TrackedRepository};
|
||||
pub use repository::ScanTrigger;
|
||||
pub use sbom::{SbomEntry, VulnRef};
|
||||
pub use scan::{ScanPhase, ScanRun, ScanRunStatus, ScanType};
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
|
||||
use super::issue::TrackerType;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// What initiated a scan.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ScanTrigger {
|
||||
@@ -10,92 +8,3 @@ pub enum ScanTrigger {
|
||||
Webhook,
|
||||
Manual,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct TrackedRepository {
|
||||
#[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<bson::oid::ObjectId>,
|
||||
#[serde(default)]
|
||||
pub name: String,
|
||||
#[serde(default)]
|
||||
pub git_url: String,
|
||||
#[serde(default = "default_branch")]
|
||||
pub default_branch: String,
|
||||
pub local_path: Option<String>,
|
||||
pub scan_schedule: Option<String>,
|
||||
#[serde(default)]
|
||||
pub webhook_enabled: bool,
|
||||
/// Auto-generated HMAC secret for verifying incoming webhooks
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub webhook_secret: Option<String>,
|
||||
pub tracker_type: Option<TrackerType>,
|
||||
pub tracker_owner: Option<String>,
|
||||
pub tracker_repo: Option<String>,
|
||||
/// Optional per-repo PAT for the issue tracker (GitHub/GitLab/Jira)
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub tracker_token: Option<String>,
|
||||
/// Optional auth token for HTTPS private repos (PAT or password)
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub auth_token: Option<String>,
|
||||
/// Optional username for HTTPS auth (defaults to "x-access-token" for PATs)
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub auth_username: Option<String>,
|
||||
pub last_scanned_commit: Option<String>,
|
||||
#[serde(default, deserialize_with = "deserialize_findings_count")]
|
||||
pub findings_count: u32,
|
||||
#[serde(
|
||||
default = "chrono::Utc::now",
|
||||
with = "super::serde_helpers::bson_datetime"
|
||||
)]
|
||||
pub created_at: DateTime<Utc>,
|
||||
#[serde(
|
||||
default = "chrono::Utc::now",
|
||||
with = "super::serde_helpers::bson_datetime"
|
||||
)]
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
fn default_branch() -> String {
|
||||
"main".to_string()
|
||||
}
|
||||
|
||||
fn deserialize_findings_count<'de, D>(deserializer: D) -> Result<u32, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let bson = bson::Bson::deserialize(deserializer)?;
|
||||
match &bson {
|
||||
bson::Bson::Int32(n) => Ok(*n as u32),
|
||||
bson::Bson::Int64(n) => Ok(*n as u32),
|
||||
bson::Bson::Double(n) => Ok(*n as u32),
|
||||
_ => Ok(0),
|
||||
}
|
||||
}
|
||||
|
||||
impl TrackedRepository {
|
||||
pub fn new(name: String, git_url: String) -> Self {
|
||||
let now = Utc::now();
|
||||
// Generate a random webhook secret (hex-encoded UUID v4, no dashes)
|
||||
let webhook_secret = uuid::Uuid::new_v4().to_string().replace('-', "");
|
||||
Self {
|
||||
id: None,
|
||||
name,
|
||||
git_url,
|
||||
default_branch: "main".to_string(),
|
||||
local_path: None,
|
||||
scan_schedule: None,
|
||||
auth_token: None,
|
||||
auth_username: None,
|
||||
webhook_enabled: false,
|
||||
webhook_secret: Some(webhook_secret),
|
||||
tracker_type: None,
|
||||
tracker_owner: None,
|
||||
tracker_repo: None,
|
||||
tracker_token: None,
|
||||
last_scanned_commit: None,
|
||||
findings_count: 0,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user