nvd_api/v2/
products.rs

1use chrono::NaiveDateTime;
2use derive_builder::Builder;
3use serde::{Deserialize, Serialize};
4
5use crate::v2::{Keyword, LastModDate, LimitOffset};
6
7///  # Products
8/// This documentation assumes that you already understand at least one common programming language and are generally familiar with JSON RESTful services. JSON specifies the format of the data returned by the REST service. REST refers to a style of services that allow computers to communicate via HTTP over the Internet. Click here for a list of best practices and additional information on where to start. The NVD is also documenting popular workflows to assist developers working with the APIs.
9///
10/// Please note, new users are discouraged from starting with the 1.0 API as it will be retired in 2023 but you may still view documentation for the 1.0 Vulnerability and 1.0 Product APIs.
11///
12#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Clone, Eq, Builder)]
13#[serde(rename_all = "camelCase")]
14#[builder(setter(into))]
15pub struct CpeParameters {
16  pub cpe_name_id: Option<String>,
17  pub cpe_match_string: Option<String>,
18  #[serde(flatten)]
19  pub keyword: Option<Keyword>,
20  #[serde(flatten)]
21  pub last_mod: Option<LastModDate>,
22  // UUID
23  pub match_criteria_id: Option<String>,
24  #[serde(flatten)]
25  pub limit_offset: Option<LimitOffset>,
26}
27
28#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Clone, Eq, Builder)]
29#[serde(rename_all = "camelCase")]
30#[builder(setter(into))]
31pub struct CpeMatchParameters {
32  pub cve_id: Option<String>,
33  #[serde(flatten)]
34  pub last_mod: Option<LastModDate>,
35  pub match_criteria_id: Option<String>,
36  #[serde(flatten)]
37  pub keyword: Option<Keyword>,
38  #[serde(flatten)]
39  pub limit_offset: Option<LimitOffset>,
40}
41
42#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Eq)]
43#[serde(rename_all = "camelCase")]
44pub struct Products {
45  pub cpe: Cpe,
46}
47
48#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Eq)]
49#[serde(rename_all = "camelCase")]
50pub struct Cpe {
51  pub deprecated: bool,
52  pub cpe_name: String,
53  pub cpe_name_id: String,
54  pub created: NaiveDateTime,
55  pub last_modified: NaiveDateTime,
56  #[serde(default)]
57  pub titles: Vec<Titles>,
58  #[serde(default)]
59  pub refs: Vec<Refs>,
60  #[serde(default)]
61  pub deprecated_by: Vec<DeprecatedBy>,
62  #[serde(default)]
63  pub deprecates: Vec<Deprecates>,
64}
65
66#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Eq)]
67#[serde(rename_all = "camelCase")]
68pub struct Titles {
69  pub title: String,
70  pub lang: String,
71}
72
73#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Eq)]
74#[serde(rename_all = "camelCase")]
75pub struct Refs {
76  pub r#ref: String,
77  #[serde(default)]
78  pub r#type: RefType,
79}
80
81#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Eq)]
82pub enum RefType {
83  Advisory,
84  #[serde(rename = "Change Log")]
85  ChangeLog,
86  Product,
87  Project,
88  Vendor,
89  Version,
90}
91
92impl Default for RefType {
93  fn default() -> Self {
94    Self::ChangeLog
95  }
96}
97
98#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Eq)]
99#[serde(rename_all = "camelCase")]
100pub struct DeprecatedBy {
101  pub cpe_name: String,
102  pub cpe_name_id: String,
103}
104
105#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Eq)]
106#[serde(rename_all = "camelCase")]
107pub struct Deprecates {
108  pub cpe_name: String,
109  pub cpe_name_id: String,
110}
111
112/// Match Criteria API
113#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Eq)]
114#[serde(rename_all = "camelCase")]
115pub struct MatchStrings {
116  pub match_string: nvd_cves::v4::configurations::Match,
117}