This commit is contained in:
parent
dc10052c16
commit
536f42a4e8
4 changed files with 164 additions and 18 deletions
|
@ -7,13 +7,37 @@ pub fn check_blacklist(domain: &str) -> bool {
|
|||
let conf = get_config();
|
||||
let conf = conf.websites.as_ref();
|
||||
|
||||
// TODO : Block IPs
|
||||
// Test SSRF
|
||||
|
||||
let blacklisted_domains = conf
|
||||
.map(|x| x.BLACKLIST_DOMAINS.as_ref())
|
||||
.unwrap_or_default();
|
||||
|
||||
for domain_regex in blacklisted_domains.unwrap_or(&Vec::new()) {
|
||||
let rgx = regex::Regex::new(domain_regex).unwrap();
|
||||
if rgx.is_match(domain) {
|
||||
check_regex(domain, blacklisted_domains.unwrap_or(&Vec::new()))
|
||||
}
|
||||
|
||||
pub fn check_blacklist_path(domain: &str, path: &str) -> bool {
|
||||
let conf = get_config();
|
||||
let conf = conf.websites.as_ref();
|
||||
|
||||
if let Some(website) = conf {
|
||||
let empty = Vec::new();
|
||||
let domain_conf = website.domains.as_ref().unwrap_or(&empty);
|
||||
if let Some(domain_conf) = domain_conf.iter().find(|x| x.domain == domain) {
|
||||
let empty = Vec::new();
|
||||
let blacklist = domain_conf.blacklist_paths.as_ref().unwrap_or(&empty);
|
||||
return check_regex(path, blacklist);
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
pub fn check_regex(input: &str, regexes: &Vec<String>) -> bool {
|
||||
for regex in regexes {
|
||||
let rgx = regex::Regex::new(regex).unwrap();
|
||||
if rgx.is_match(input) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue