Skip to content

Commit 1dd0623

Browse files
authored
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.
1 parent 90c171f commit 1dd0623

File tree

4 files changed

+19
-28
lines changed

4 files changed

+19
-28
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1212

1313
- Use `suppression_reason` instead of deprecated `suppressed` field
1414

15+
### Fixed
16+
17+
- Package subcommand failing to parse API responses
18+
1519
## 7.1.0 - 2024-09-24
1620

1721
### Added

cli/src/types.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ pub struct RevokeTokenRequest<'a> {
132132
pub name: &'a str,
133133
}
134134

135+
#[derive(Serialize, Deserialize)]
136+
pub struct PackageSpecifier {
137+
#[serde(alias = "type")]
138+
pub registry: String,
139+
pub name: String,
140+
pub version: String,
141+
}
142+
135143
/// Response body for `/data/packages/submit`.
136144
#[derive(Serialize, Deserialize)]
137145
#[serde(tag = "status", content = "data")]
@@ -156,33 +164,19 @@ pub struct Package {
156164
pub versions: Vec<ScoredVersion>,
157165
pub description: Option<String>,
158166
pub license: Option<String>,
159-
pub dep_specs: Vec<PackageSpecifier>,
160167
pub dependencies: Option<Vec<Package>>,
161-
pub download_count: u32,
162168
pub risk_scores: RiskScores,
163-
pub total_risk_score_dynamics: Option<Vec<ScoreDynamicsPoint>>,
164169
pub issues: Vec<Issue>,
165-
pub authors: Vec<Author>,
166-
pub developer_responsiveness: Option<DeveloperResponsiveness>,
167170
pub complete: bool,
168171
pub release_data: Option<PackageReleaseData>,
169172
pub repo_url: Option<String>,
170-
pub maintainers_recently_changed: Option<bool>,
171-
pub is_abandonware: Option<bool>,
172-
}
173-
174-
#[derive(Serialize, Deserialize)]
175-
pub struct PackageSpecifier {
176-
#[serde(alias = "type")]
177-
pub registry: String,
178-
pub name: String,
179-
pub version: String,
180173
}
181174

182175
#[derive(Serialize, Deserialize)]
183176
pub struct ScoredVersion {
184177
pub version: String,
185178
pub total_risk_score: Option<f32>,
179+
pub published_date: Option<String>,
186180
}
187181

188182
/// Package risk scores, broken down by domain.
@@ -235,7 +229,7 @@ pub struct VulnDetails {
235229
/// The CVSS score assigned to this vuln.
236230
pub cvss: f32,
237231
/// The CVSS vector string assigned to this vuln.
238-
pub cvss_vector: String,
232+
pub cvss_vector: Option<String>,
239233
}
240234

241235
/// The user-specified reason for an issue to be ignored.
@@ -277,6 +271,7 @@ pub struct DeveloperResponsiveness {
277271
pub struct PackageReleaseData {
278272
pub first_release_date: String,
279273
pub last_release_date: String,
274+
pub total_releases: u32,
280275
}
281276

282277
#[derive(Serialize, Deserialize, PartialEq, Eq, Copy, Clone, Debug, Hash)]

extensions/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
88

99
## Unreleased
1010

11+
### Changed
12+
13+
- Return type fields of `PhylumApi::getPackageDetails`
14+
1115
## 7.0.0 - 2024-09-17
1216

1317
### Added

extensions/phylum.d.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,7 @@ declare namespace Phylum {
335335
* ],
336336
* description: "TypeScript is a language for application scale JavaScript development",
337337
* license: "Apache-2.0",
338-
* depSpecs: [],
339338
* dependencies: [],
340-
* downloadCount: 134637844,
341339
* riskScores: {
342340
* total: 1,
343341
* vulnerability: 1,
@@ -346,18 +344,8 @@ declare namespace Phylum {
346344
* engineering: 1,
347345
* license: 1
348346
* },
349-
* totalRiskScoreDynamics: null,
350347
* issuesDetails: [],
351348
* issues: [],
352-
* authors: [],
353-
* developerResponsiveness: {
354-
* open_issue_count: 0,
355-
* total_issue_count: 0,
356-
* open_issue_avg_duration: null,
357-
* open_pull_request_count: 0,
358-
* total_pull_request_count: 0,
359-
* open_pull_request_avg_duration: null
360-
* },
361349
* complete: true
362350
* }
363351
* ```

0 commit comments

Comments
 (0)