-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from eredotpkfr/integrations
feat: generic api integration module
- Loading branch information
Showing
72 changed files
with
1,807 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SUBSCAN_BEVIGIL_APIKEY=foo | ||
SUBSCAN_BINARYEDGE_APIKEY=bar | ||
SUBSCAN_BUFFEROVER_APIKEY=baz | ||
SUBSCAN_BUILTWITH_APIKEY=foo | ||
SUBSCAN_CENSYS_APIKEY=bar |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,7 @@ Cargo.lock | |
|
||
|
||
# Added by cargo | ||
|
||
/target | ||
|
||
# Ignore local .env file | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub const SUBSCAN_ENV_NAMESPACE: &str = "SUBSCAN"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use crate::interfaces::extractor::SubdomainExtractorInterface; | ||
use crate::types::core::{InnerExtractMethod, Subdomain}; | ||
use async_trait::async_trait; | ||
use serde_json; | ||
use std::collections::BTreeSet; | ||
|
||
/// JSON content parser wrapper struct. This object compatible | ||
/// with [`SubdomainExtractorInterface`] and it uses `extract` | ||
/// method to extract subdomain addresses from JSON content. | ||
/// JSON parsing function must be given for this extractor. Please | ||
/// follow up examples to learn usage techniques | ||
pub struct JSONExtractor { | ||
inner: InnerExtractMethod, | ||
} | ||
|
||
impl JSONExtractor { | ||
/// Creates a new [`JSONExtractor`] instance | ||
/// | ||
/// # Examples | ||
/// | ||
/// ```no_run | ||
/// use subscan::extractors::json::JSONExtractor; | ||
/// use std::collections::BTreeSet; | ||
/// use serde_json::Value; | ||
/// | ||
/// let inner = |_content: Value, _domain: String| { | ||
/// BTreeSet::new() | ||
/// }; | ||
/// | ||
/// let extractor = JSONExtractor::new(Box::new(inner)); | ||
/// | ||
/// // do something with extractor instance | ||
/// ``` | ||
pub fn new(inner: InnerExtractMethod) -> Self { | ||
Self { inner } | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl SubdomainExtractorInterface for JSONExtractor { | ||
/// Main extraction method to extract subdomains from | ||
/// given JSON content | ||
/// | ||
/// # Examples | ||
/// | ||
/// ``` | ||
/// use subscan::extractors::json::JSONExtractor; | ||
/// use subscan::interfaces::extractor::SubdomainExtractorInterface; | ||
/// use subscan::types::core::Subdomain; | ||
/// use std::collections::BTreeSet; | ||
/// use serde_json::Value; | ||
/// | ||
/// #[tokio::main] | ||
/// async fn main() { | ||
/// let json = "{\"foo\": \"bar\"}".to_string(); | ||
/// let domain = "foo.com".to_string(); | ||
/// | ||
/// let func = |item: Value, _domain: String| { | ||
/// [ | ||
/// Subdomain::from(item["foo"].as_str().unwrap()) | ||
/// ].into() | ||
/// }; | ||
/// let extractor = JSONExtractor::new(Box::new(func)); | ||
/// | ||
/// let result = extractor.extract(json, domain).await; | ||
/// | ||
/// assert_eq!(result, [Subdomain::from("bar")].into()); | ||
/// } | ||
/// ``` | ||
async fn extract(&self, content: String, domain: String) -> BTreeSet<Subdomain> { | ||
(self.inner)(serde_json::from_str(&content).unwrap_or_default(), domain) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
/// Subdomain extractor for HTML documents | ||
pub mod html; | ||
/// JSON extractor to extract subdomains from JSON content | ||
pub mod json; | ||
/// Extract subdomains with regex statement | ||
pub mod regex; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.