Skip to content

Commit

Permalink
feat: support crawling github for poc
Browse files Browse the repository at this point in the history
  • Loading branch information
fan-tastic-z committed Jun 5, 2024
1 parent ff4b6f8 commit fcaaac4
Show file tree
Hide file tree
Showing 19 changed files with 343 additions and 2 deletions.
185 changes: 185 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ sha2 = "0.10.8"
hmac = "0.12.1"
base64 = "0.22.1"
chrono-tz = "0.9.0"
octocrab = "0.38.0"
2 changes: 2 additions & 0 deletions config/development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ ding_bot:
lark_bot:
access_token: {{ get_env(name="LARK_ACCESS_TOKEN", default="") }}
secret_token: {{ get_env(name="LARK_SECRET_TOKEN", default="") }}

github_search: true
16 changes: 16 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::{
msg_template::{reader_vulninfo, render_init},
BotManager,
},
search::search_github_poc,
};

lazy_static! {
Expand Down Expand Up @@ -130,8 +131,23 @@ impl WatchVulnApp {
info!("{} has been pushed, skipped", vuln.key);
continue;
}

let key = vuln.key.clone();
let title = vuln.title.clone();
if !vuln.cve.is_empty() && self.app_context.config.github_search {
let links = search_github_poc(&vuln.cve).await;
info!("{} found {} links from github", &vuln.cve, links.len());
if let Err(err) = vuln_informations::Model::update_github_search_by_key(
&self.app_context.db,
&key,
links,
)
.await
{
warn!("update vuln {} github_search error: {}", &vuln.cve, err);
}
todo!()
}
let msg = match reader_vulninfo(vuln.into()) {
Ok(msg) => msg,
Err(err) => {
Expand Down
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct Config {
pub tg_bot: TgBot,
pub ding_bot: DingBot,
pub lark_bot: LarkBot,
pub github_search: bool,
}

impl Config {
Expand Down
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ pub enum Error {
#[error(transparent)]
SystemTime(#[from] SystemTimeError),

#[error(transparent)]
Octocrab(#[from] octocrab::Error),

#[error(transparent)]
Any(#[from] Box<dyn std::error::Error + Send + Sync>),

Expand Down
1 change: 1 addition & 0 deletions src/grab/anti.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl Grab for AntiCrawler {
from,
tags: vec![],
reasons: vec![],
github_search: vec![],
is_valuable: true,
};
res.push(vuln);
Expand Down
1 change: 1 addition & 0 deletions src/grab/avd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ impl AVDCrawler {
from: self.link.clone(),
tags,
reasons: vec![],
github_search: vec![],
is_valuable,
};
Ok(data)
Expand Down
1 change: 1 addition & 0 deletions src/grab/kev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl Grab for KevCrawler {
vuln.product.to_string(),
"在野利用".to_string(),
],
github_search: vec![],
reasons: vec![],
is_valuable,
};
Expand Down
Loading

0 comments on commit fcaaac4

Please sign in to comment.