Skip to content

Commit

Permalink
fly:cnnvd_data_type
Browse files Browse the repository at this point in the history
  • Loading branch information
cn-kali-team committed Apr 3, 2024
1 parent 16ac08a commit 24d5943
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
10 changes: 9 additions & 1 deletion cnvd/src/cnnvd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,15 @@ pub struct VulListParameters {
pub vul_type: Option<String>,
pub vendor: Option<String>,
pub product: Option<String>,
pub date_type: Option<String>,
pub date_type: Option<DataType>,
}

#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum DataType {
#[default]
UpdateTime,
PublishTime,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down
5 changes: 3 additions & 2 deletions helper/src/cve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use nvd_api::pagination::Object;
use nvd_api::v2::vulnerabilities::CveParameters;
use nvd_api::ApiVersion;

use cnvd::cnnvd::{CNNVDData, VulListParameters, VulListParametersBuilder};
use cnvd::cnnvd::{CNNVDData, DataType, VulListParameters, VulListParametersBuilder};
use nvd_cves::v4::{CVEContainer, CVEItem};
use nvd_model::cve::{CreateCve, Cve, QueryCve};
use nvd_model::error::DBResult;
Expand Down Expand Up @@ -172,6 +172,7 @@ pub async fn cnnvd_api() -> HelperResult<()> {
.end_time(Some(Utc::now().date_naive()))
.begin_time(Some((Utc::now() - Duration::days(3)).date_naive()))
.page_size(Some(50))
.date_type(Some(DataType::UpdateTime))
.build()
.unwrap_or_default();
update_translated_from_cnnvd_api(connection_pool.get().unwrap().deref_mut(), q)
Expand All @@ -180,7 +181,7 @@ pub async fn cnnvd_api() -> HelperResult<()> {
// 更新还没翻译的漏洞
let args = QueryCve {
translated: Some(0),
page: Some(1),
page: Some(3),
..QueryCve::default()
};
if let Ok(list) = Cve::query(connection_pool.get().unwrap().deref_mut(), &args) {
Expand Down
11 changes: 7 additions & 4 deletions nvd-yew/src/component/cve_row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use crate::routes::Route;
use std::collections::HashSet;
use std::ops::Deref;

use crate::component::use_translation;
use nvd_model::cve::Cve;
use yew::prelude::*;
use yew_router::prelude::*;
use crate::component::use_translation;

// 单行的cve信息,和点击供应商,产品回调
#[derive(PartialEq, Clone, Properties)]
Expand All @@ -26,23 +26,26 @@ pub fn CVERow(props: &CveProps) -> Html {
} = props;
let i18n = use_translation();
let cve_id = props.id.clone();
let mut description = props.description
let mut description = props
.description
.iter()
.filter(|d| d.lang == i18n.current_lang)
.map(|d| d.value.clone())
.collect::<String>();
// 把第一行丢弃掉,第一行是组件描述
let lines: Vec<&str> = description.lines().collect();
if lines.len() >= 2 {
let desc: Vec<String> = lines.iter()
let desc: Vec<String> = lines
.iter()
.enumerate()
.filter(|(i, _d)| i != &0)
.map(|(_i, d)| d.to_string())
.collect();
description = desc.join("\r\n");
}
if description.is_empty() {
description = props.description
description = props
.description
.iter()
.filter(|d| d.lang == "en")
.map(|d| d.value.clone())
Expand Down

0 comments on commit 24d5943

Please sign in to comment.