From 1dd0623dfdfb986b6151b4d415e2d39d7cb05dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20D=C3=BCrr?= <102963075+cd-work@users.noreply.github.com> Date: Tue, 8 Oct 2024 18:56:29 +0000 Subject: [PATCH] Fix failure in package subcommand (#1513) This fixes some compatibility issues between our current API and the CLI's own internal data structures. Closes #1514. Closes #1512. --- CHANGELOG.md | 4 ++++ cli/src/types.rs | 27 +++++++++++---------------- extensions/CHANGELOG.md | 4 ++++ extensions/phylum.d.ts | 12 ------------ 4 files changed, 19 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec1cbc72e..64fba6b4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Use `suppression_reason` instead of deprecated `suppressed` field +### Fixed + +- Package subcommand failing to parse API responses + ## 7.1.0 - 2024-09-24 ### Added diff --git a/cli/src/types.rs b/cli/src/types.rs index 64065da01..267c3ac5e 100644 --- a/cli/src/types.rs +++ b/cli/src/types.rs @@ -132,6 +132,14 @@ pub struct RevokeTokenRequest<'a> { pub name: &'a str, } +#[derive(Serialize, Deserialize)] +pub struct PackageSpecifier { + #[serde(alias = "type")] + pub registry: String, + pub name: String, + pub version: String, +} + /// Response body for `/data/packages/submit`. #[derive(Serialize, Deserialize)] #[serde(tag = "status", content = "data")] @@ -156,33 +164,19 @@ pub struct Package { pub versions: Vec, pub description: Option, pub license: Option, - pub dep_specs: Vec, pub dependencies: Option>, - pub download_count: u32, pub risk_scores: RiskScores, - pub total_risk_score_dynamics: Option>, pub issues: Vec, - pub authors: Vec, - pub developer_responsiveness: Option, pub complete: bool, pub release_data: Option, pub repo_url: Option, - pub maintainers_recently_changed: Option, - pub is_abandonware: Option, -} - -#[derive(Serialize, Deserialize)] -pub struct PackageSpecifier { - #[serde(alias = "type")] - pub registry: String, - pub name: String, - pub version: String, } #[derive(Serialize, Deserialize)] pub struct ScoredVersion { pub version: String, pub total_risk_score: Option, + pub published_date: Option, } /// Package risk scores, broken down by domain. @@ -235,7 +229,7 @@ pub struct VulnDetails { /// The CVSS score assigned to this vuln. pub cvss: f32, /// The CVSS vector string assigned to this vuln. - pub cvss_vector: String, + pub cvss_vector: Option, } /// The user-specified reason for an issue to be ignored. @@ -277,6 +271,7 @@ pub struct DeveloperResponsiveness { pub struct PackageReleaseData { pub first_release_date: String, pub last_release_date: String, + pub total_releases: u32, } #[derive(Serialize, Deserialize, PartialEq, Eq, Copy, Clone, Debug, Hash)] diff --git a/extensions/CHANGELOG.md b/extensions/CHANGELOG.md index 12d80cf20..3822f4b21 100644 --- a/extensions/CHANGELOG.md +++ b/extensions/CHANGELOG.md @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased +### Changed + +- Return type fields of `PhylumApi::getPackageDetails` + ## 7.0.0 - 2024-09-17 ### Added diff --git a/extensions/phylum.d.ts b/extensions/phylum.d.ts index 796c5a3c9..69f79fa50 100644 --- a/extensions/phylum.d.ts +++ b/extensions/phylum.d.ts @@ -335,9 +335,7 @@ declare namespace Phylum { * ], * description: "TypeScript is a language for application scale JavaScript development", * license: "Apache-2.0", - * depSpecs: [], * dependencies: [], - * downloadCount: 134637844, * riskScores: { * total: 1, * vulnerability: 1, @@ -346,18 +344,8 @@ declare namespace Phylum { * engineering: 1, * license: 1 * }, - * totalRiskScoreDynamics: null, * issuesDetails: [], * issues: [], - * authors: [], - * developerResponsiveness: { - * open_issue_count: 0, - * total_issue_count: 0, - * open_issue_avg_duration: null, - * open_pull_request_count: 0, - * total_pull_request_count: 0, - * open_pull_request_avg_duration: null - * }, * complete: true * } * ```