aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src/api_entity_crud.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-12-21 17:09:10 -0800
committerBryan Newbold <bnewbold@robocracy.org>2018-12-21 17:09:10 -0800
commitc1c01caf6b40343bd876e10961829e2b15a9c37c (patch)
treecb26627fe194cbd878ad9c5912dce2feef2c1c8d /rust/src/api_entity_crud.rs
parent86f37a5df6f94d7736be736d0a440ae65425d6c9 (diff)
downloadfatcat-c1c01caf6b40343bd876e10961829e2b15a9c37c.tar.gz
fatcat-c1c01caf6b40343bd876e10961829e2b15a9c37c.zip
verify checksum against regexes
Diffstat (limited to 'rust/src/api_entity_crud.rs')
-rw-r--r--rust/src/api_entity_crud.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/rust/src/api_entity_crud.rs b/rust/src/api_entity_crud.rs
index 2f28e858..792e6f9a 100644
--- a/rust/src/api_entity_crud.rs
+++ b/rust/src/api_entity_crud.rs
@@ -885,6 +885,19 @@ impl EntityCrud for FileEntity {
}
fn db_insert_revs(conn: &DbConn, models: &[&Self]) -> Result<Vec<Uuid>> {
+ // first verify hash syntax
+ for entity in models {
+ if let Some(ref hash) = entity.md5 {
+ check_md5(hash)?;
+ }
+ if let Some(ref hash) = entity.sha1 {
+ check_sha1(hash)?;
+ }
+ if let Some(ref hash) = entity.sha256 {
+ check_sha256(hash)?;
+ }
+ }
+
let rev_ids: Vec<Uuid> = insert_into(file_rev::table)
.values(
models