attackerkb_api_rs/v1/
mod.rs

1//! v1 version api
2pub mod assessment;
3pub mod contributor;
4pub mod query;
5pub mod topic;
6
7use chrono::NaiveDateTime;
8#[cfg(feature = "nvd-cves")]
9use nvd_cves::impact::ImpactMetrics;
10use serde::{Deserialize, Serialize};
11use uuid::Uuid;
12
13#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
14#[serde(untagged)]
15pub enum TagsOrReferences {
16  FoldedRecord(FoldedRecord),
17  References(References),
18  Tags(Tags),
19}
20
21#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
22#[serde(rename_all = "camelCase")]
23pub struct References {
24  /// example: c0f010fe-da9c-4aa6-b898-c57d483df51b
25  /// The UUID of the tag.
26  pub id: Uuid,
27  /// example: c28a806c-84c7-44bf-95d3-1241475de5bf
28  /// The UUID of the contributor who last edited the topic.
29  pub editor_id: Uuid,
30  /// example: 2019-07-02T16:22:15.879357Z
31  /// The date and time the reference was created.
32  pub created: NaiveDateTime,
33  /// example: CVE-2019-0708 - BlueKeep
34  /// The name of the reference.
35  pub name: String,
36  /// example: <https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-123-1342>
37  /// The url associated with the reference.
38  pub url: String,
39  /// example: canonical
40  /// The type of the reference.
41  pub ref_type: String,
42  /// example: system
43  pub ref_source: String,
44}
45
46#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
47#[serde(rename_all = "camelCase")]
48pub struct Tags {
49  /// example: 9d2d9df6-cd8e-4ad2-82e7-e12b0678c9d9
50  /// The UUID of the tag.
51  pub id: Uuid,
52  /// example: Common in enterprise
53  /// The name of the tag. This is what shows up in the UI.
54  pub name: String,
55  /// example: common
56  /// The type of the tag.
57  pub r#type: String,
58  /// example: common_enterprise
59  /// The code of the tag used to reference tags.
60  pub code: String,
61  /// A JSON value containing key/value pairs describing various attributes about this tag.
62  pub metadata: TagMetaData,
63}
64
65/// A JSON value containing key/value pairs describing various attributes about this tag.
66#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
67#[serde(rename_all = "camelCase")]
68pub struct TagMetaData {
69  /// example: high
70  /// The value of the tag
71  pub value: String,
72  /// example: system
73  /// The origination of where the tag was created
74  pub source: String,
75  /// example: TA0001
76  /// The Mitre tactic ID.
77  pub tactic_id: String,
78  /// example: Initial Access
79  /// The Mitre tactic name.
80  pub tactic_name: String,
81}
82
83#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
84#[serde(rename_all = "camelCase")]
85pub struct Score {
86  /// The attacker value score.
87  pub attacker_value: f32,
88  /// The exploitability score.
89  pub exploitability: f32,
90}
91
92#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Default)]
93#[serde(rename_all = "camelCase")]
94pub struct MetaData {
95  #[serde(default)]
96  pub configurations: Vec<String>,
97  #[serde(default)]
98  pub credits: Option<Credits>,
99  #[serde(default)]
100  pub cve_state: CveState,
101  #[cfg(feature = "nvd-cves")]
102  #[serde(flatten)]
103  pub cvss_metric_v31: ImpactMetrics,
104  #[serde(default)]
105  pub references: Vec<String>,
106  #[serde(default)]
107  pub vendor: Option<Vendor>,
108  #[serde(rename = "vulnerable-versions")]
109  pub vulnerable_versions: Option<Vec<String>>,
110}
111
112#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
113#[serde(rename_all = "camelCase")]
114pub struct Vendor {
115  #[serde(default)]
116  product_names: Vec<String>,
117  #[serde(default)]
118  vendor_names: Vec<String>,
119}
120
121#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
122pub enum CveState {
123  PUBLIC,
124  RESERVED,
125}
126
127impl Default for CveState {
128  fn default() -> Self {
129    Self::PUBLIC
130  }
131}
132
133#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Default)]
134#[serde(rename_all = "kebab-case")]
135pub struct Credits {
136  #[serde(default)]
137  pub discovered_by: Vec<String>,
138  #[serde(default)]
139  pub module: Vec<String>,
140  #[serde(default)]
141  pub reporter: Vec<String>,
142}
143
144/// Condensed version of a related object. The returned attributes are reduced as not to cause noise with the parent object. These full objects can be returned by specifying their type in the expand parameter.
145#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
146#[serde(rename_all = "camelCase")]
147pub struct FoldedRecord {
148  /// The primary UUID of the related object. This can be used in a subsequent request to the appropriate URL to retrieve the full object.
149  pub id: Uuid,
150}