aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2024-07-08 11:21:47 +0200
committerHarald Eilertsen <haraldei@anduin.net>2024-07-08 11:21:47 +0200
commit6abf3e97a5552b0305eeb6a1b8748414f4df24ae (patch)
tree662d79ab973a47d93ceea8bdc26c36786d016f19 /src
parent8632549a8e14938db686396a12876de57da7d4d0 (diff)
downloadphisher-main.tar.gz
phisher-main.tar.bz2
phisher-main.zip
Update parsing of PhishTank data files.HEADmastermain
- Remove special handling of the `phish_id` field in the Phish struct. The source json files now represents the id as a number. - Remove `country` field from PhishDetails. No longer supplied in the json data set. - Rename `verified_time` to `verification_time` in the Phish struct, to match the names used in the data set.
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs16
1 files changed, 1 insertions, 15 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 8f56601..043f485 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -28,7 +28,6 @@ pub struct PhishTank {
#[derive(Deserialize)]
pub struct Phish {
- #[serde(deserialize_with = "deserialize_number")]
pub phish_id: u64,
pub url: String,
pub phish_detail_url: String,
@@ -36,7 +35,7 @@ pub struct Phish {
#[serde(deserialize_with = "deserialize_yesno")]
pub verified: bool,
- pub verified_time: Option<DateTime<Utc>>,
+ pub verification_time: Option<DateTime<Utc>>,
#[serde(deserialize_with = "deserialize_yesno")]
pub online: bool,
@@ -50,7 +49,6 @@ pub struct PhishDetails {
pub cidr_block: String,
pub announcing_network: String,
pub rir: String,
- pub country: String,
pub detail_time: DateTime<Utc>,
}
@@ -66,18 +64,6 @@ impl PhishTank {
}
}
-// Helper function to deserialize a number represented as a string.
-//
-// The PhishTank dataset represents numbers this way, so the default
-// json deserializer implementation will only deserialize to a string.
-//
-fn deserialize_number<'de, D>(d: D) -> Result<u64, D::Error>
- where D: Deserializer<'de>
-{
- let s = String::deserialize(d)?;
- u64::from_str(&s).map_err(serde::de::Error::custom)
-}
-
// Helper function to deserialize "yes/no" into a bool.
//
// The PhishTank dataset uses the strings "yes" and "no" to represent