Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sha2 crate to 0.9.0 #1463

Merged
merged 2 commits into from
Aug 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 116 additions & 13 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion components/builder-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ reqwest = "*"
serde = "*"
serde_derive = "*"
serde_json = "*"
sha2 = "= 0.8.2"
sha2 = "*"
toml = { version = "*", default-features = false }
futures = "*"
rand = "*"
Expand Down
22 changes: 20 additions & 2 deletions components/builder-api/src/server/services/memcache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,24 @@ fn member_role_ns_key(origin: &str, account_id: u64) -> String {

fn hash_key(key: &str) -> String {
let mut hasher = Sha512::new();
hasher.input(key);
format!("{:02x}", hasher.result())
hasher.update(key);
format!("{:02x}", hasher.finalize())
}

#[cfg(test)]
mod test {
use super::*;
#[test]
fn hash_key_with_empty_input() {
let expected = "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e".to_string();
assert_eq!(hash_key(""), expected);
}

#[test]
fn hash_key_with_session_token() {
let token =
"CIyAhviVt/aAChIFMYz4NYETACIoZDM2NDg9ZjEzOWY0MTQ5YzZiNmNjDMBkYTA4NTAzODkaMzdiNGZlNQ==";
let expected = "33a8f10726b1ada86d9f60e4abbb1cb8726798a2303395cecace82225236cfc3d5a82815d1017a1dd6f8d34e8b77a51c30d972ba2031e1207679fb2a4db925ea".to_string();
assert_eq!(hash_key(token), expected)
}
}
2 changes: 1 addition & 1 deletion components/builder-jobsrv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ rand = "*"
r2d2 = "*"
serde = "*"
serde_derive = "*"
sha2 = "= 0.8.2"
sha2 = "*"
toml = { version = "*", default-features = false }

[dependencies.actix-web]
Expand Down
4 changes: 2 additions & 2 deletions components/builder-jobsrv/src/server/log_archiver/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ impl LocalArchiver {
/// as not to run afoul of directory limits.
pub fn archive_path(&self, job_id: u64) -> PathBuf {
let mut hasher = Sha256::default();
hasher.input(job_id.to_string().as_bytes());
let checksum = hasher.result();
hasher.update(job_id.to_string().as_bytes());
let checksum = hasher.finalize();

let mut new_path = self.0.clone();
for byte in checksum.iter().take(4) {
Expand Down