Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const OPERATIONS: &[(&str, &str, &[&str])] = &[
("get", "export_reviews", &["dataset"]),
("get", "get_agent_session", &["session_id"]),
("get", "get_agent_session_prompt", &["finding_id"]),
("get", "get_finding", &["finding_id"]),
("get", "get_finding_fix_prompt", &["finding_id"]),
(
"get",
Expand Down
18 changes: 15 additions & 3 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use uuid::Uuid;

use crate::model::{
CommitReviewRequest, CommitReviewResponse, CoverageUploadRequest, CoverageUploadResponse,
FileReviewRequest, FileReviewResponse, PatchReviewRequest, PatchReviewResponse,
RepositoryNames, ReviewDetail, ReviewPage, RunNowMode, RunNowRequest, RunNowResponse,
ScanRequest, ScanResponse, StopResponse,
CustomerFinding, FileReviewRequest, FileReviewResponse, PatchReviewRequest,
PatchReviewResponse, RepositoryNames, ReviewDetail, ReviewPage, RunNowMode, RunNowRequest,
RunNowResponse, ScanRequest, ScanResponse, StopResponse,
};
use crate::origin::Origin;
use crate::text::terminal_safe;
Expand Down Expand Up @@ -502,6 +502,18 @@ impl Api {
Ok((raw, typed))
}

/// Fetches one finding as the raw document and its typed reading.
pub async fn finding(
&self,
finding_id: Uuid,
) -> Result<(serde_json::Value, CustomerFinding), ApiError> {
let id = finding_id.to_string();
let raw = self.get(self.url_get_finding(&id)).await?;
let typed = serde_json::from_value(raw.clone())
.map_err(|error| self.http.protocol(error.to_string()))?;
Ok((raw, typed))
}

/// One page of the review collection, newest first.
pub async fn reviews(
&self,
Expand Down
24 changes: 24 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ enum Command {
Stop(StopArgs),
/// Show the findings of the latest review of a commit or pull request.
Findings(FindingsArgs),
/// Read one finding with its evidence references, validation state, and causal graph.
Finding(FindingArgs),
/// Forward a coding agent's stdio messages to this console's MCP server.
Mcp,
/// Commands for a CI job.
Expand Down Expand Up @@ -216,6 +218,15 @@ struct CiReviewArgs {
repository: RepositoryArgs,
}

#[derive(Debug, Args)]
struct FindingArgs {
/// Finding UUID.
finding_id: Uuid,
/// Print JSON instead of text.
#[arg(long)]
json: bool,
}

#[derive(Debug, Args)]
struct LoginArgs {
/// Review API scope to ask for; repeat for several. The approval page can
Expand Down Expand Up @@ -554,6 +565,19 @@ pub async fn run(cli: Cli, token: Option<SecretString>) -> anyhow::Result<Verdic
let api = connect(Http::new(origin)?, token, cli.org).await?;
findings(&api, &args).await
}
Command::Finding(args) => {
let api = connect(Http::new(origin)?, token, cli.org).await?;
let (raw, typed) = api.finding(args.finding_id).await?;
if args.json {
return tools::json(&raw);
}
write!(
std::io::stdout().lock(),
"{}",
render::finding_detail(&typed)
)?;
Ok(Verdict::Done)
}
Command::Mcp => {
let http = Http::new(origin)?;
let credential = credentials::load(http.origin(), token, cli.org).await?;
Expand Down
97 changes: 97 additions & 0 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,103 @@ pub struct EvidenceRef {
pub companion_repository: Option<String>,
}

/// Full finding detail returned by `GET /findings/{finding_id}`.
#[derive(Debug, Deserialize, Serialize)]
pub struct CustomerFinding {
pub id: Uuid,
pub finding_fingerprint: Option<String>,
pub severity: String,
pub risk_domain: String,
pub claim: String,
pub impact: String,
pub symbols: Vec<String>,
pub lifecycle_state: String,
pub remediation: Option<String>,
pub evidence_class: Option<String>,
pub evidence_refs: Vec<CustomerEvidenceRef>,
pub causal_graph: Option<FindingCausalGraphView>,
pub supporting_evidence: Option<FindingSupport>,
pub latest_validation: Option<CustomerFindingValidation>,
pub validation: Option<String>,
pub github_comment_url: Option<String>,
pub rule_refs: Vec<FindingRuleRefView>,
pub comment_reactions: Vec<serde_json::Value>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub local_findings: Vec<serde_json::Value>,
pub placement: Option<serde_json::Value>,
pub comment_evaluation: Option<serde_json::Value>,
pub thread_observation: Option<serde_json::Value>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct CustomerEvidenceRef {
pub kind: String,
pub label: String,
pub provenance_status: String,
pub repository_path: Option<String>,
pub start_line: Option<u32>,
pub end_line: Option<u32>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub file_sha256: Option<String>,
pub commit_sha: Option<String>,
pub companion_repository: Option<String>,
pub url: Option<String>,
pub workflow_run_id: Option<i64>,
pub workflow_attempt: Option<i64>,
pub legacy_text: Option<String>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct CustomerFindingValidation {
pub validation: String,
pub source: String,
pub recorded_at: String,
pub actor_github_user_id: Option<i64>,
pub actor_login: Option<String>,
pub actor_name: Option<String>,
pub covering_author_kind: Option<String>,
pub covering_author_login: Option<String>,
pub covering_comment_created_at: Option<String>,
pub github_comment_url: Option<String>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct FindingCausalGraphView {
pub nodes: Vec<FindingCausalNodeView>,
pub edges: Vec<FindingCausalEdgeView>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct FindingCausalNodeView {
pub id: String,
pub label: String,
pub role: String,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct FindingCausalEdgeView {
pub from: String,
pub to: String,
pub label: Option<String>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct FindingRuleRefView {
pub key: String,
pub revisions: Vec<serde_json::Value>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct FindingSupport {
pub explanation: Option<UntrustedText>,
pub evidence_refs: Vec<CustomerEvidenceRef>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct UntrustedText {
pub untrusted_text: String,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct RunNowResponse {
pub review_id: Uuid,
Expand Down
Loading