mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-14 12:46:49 +00:00
feat: Add Prometheus metrics endpoint
This commit is contained in:
1 parent
ea96858c4a
commit
f14c401f39
25 files changed
+652
-46
No files matched your search
@@ -49,6 +49,17 @@ where
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// Compare two strings without short-circuiting on the first mismatch, for
|
||||
/// checking secrets.
|
||||
#[must_use]
|
||||
pub fn constant_time_eq(a: &str, b: &str) -> bool {
|
||||
a.len() == b.len()
|
||||
&& a.bytes()
|
||||
.zip(b.bytes())
|
||||
.fold(0_u8, |acc, (x, y)| acc | (x ^ y))
|
||||
== 0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn camel_to_snake_string(s: &str) -> String {
|
||||
|
||||
@@ -68,3 +68,10 @@ fn between_infallible() {
|
||||
assert_eq!("\"foo".between_infallible(("\"", "\"")), "\"foo");
|
||||
assert_eq!("foo".between_infallible(("\"", "\"")), "foo");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn constant_time_eq() {
|
||||
assert!(super::constant_time_eq("abc", "abc"));
|
||||
assert!(!super::constant_time_eq("abc", "abz"));
|
||||
assert!(!super::constant_time_eq("abc", "abcd"));
|
||||
}
|
||||
Reference in new issue
Block a user