Skip to main content

hyperlane_plugin_audit/
const.rs

1/// Context attribute key storing request entry timestamp for audit latency measurement.
2pub const ATTR_AUDIT_START: &str = "hyperlane_plugin_audit.start";
3
4/// Context attribute key storing optional actor/subject identity attached by handlers or auth middleware.
5pub const ATTR_AUDIT_ACTOR: &str = "hyperlane_plugin_audit.actor";
6
7/// Context attribute key storing optional custom action label attached by handlers.
8pub const ATTR_AUDIT_ACTION: &str = "hyperlane_plugin_audit.action";
9
10/// Default maximum records retained by [`InMemoryAuditSink`].
11pub const DEFAULT_AUDIT_CAPACITY: usize = 4096;
12
13/// Genesis chain hash preceding the first audit event (64 zero hex digits).
14pub const AUDIT_GENESIS_HASH: &str =
15    "0000000000000000000000000000000000000000000000000000000000000000";
16
17/// Placeholder emitted when a sensitive header value is redacted.
18pub const REDACTED_VALUE: &str = "[REDACTED]";
19
20/// Fallback actor string when no actor attribute was set on `Context`.
21pub const ANONYMOUS_ACTOR: &str = "anonymous";
22
23/// Default header name checked for request correlation IDs.
24pub const DEFAULT_REQUEST_ID_HEADER: &str = "x-request-id";
25
26/// Lowercase hexadecimal encoding alphabet.
27pub(crate) const HEX_LOWER: &[u8; 16] = b"0123456789abcdef";
28
29/// Preformatted internal map key for zero-allocation lookup of request entry timestamp.
30pub(crate) const ATTR_AUDIT_START_MAP_KEY: &str = "External(\"hyperlane_plugin_audit.start\")";
31
32/// Initial SHA-256 hash values (FIPS 180-4).
33pub(crate) const SHA256_H0: [u32; 8] = [
34    0x6a09_e667,
35    0xbb67_ae85,
36    0x3c6e_f372,
37    0xa54f_f53a,
38    0x510e_527f,
39    0x9b05_688c,
40    0x1f83_d9ab,
41    0x5be0_cd19,
42];
43
44/// SHA-256 round constants (FIPS 180-4).
45pub(crate) const SHA256_K: [u32; 64] = [
46    0x428a_2f98,
47    0x7137_4491,
48    0xb5c0_fbcf,
49    0xe9b5_dba5,
50    0x3956_c25b,
51    0x59f1_11f1,
52    0x923f_82a4,
53    0xab1c_5ed5,
54    0xd807_aa98,
55    0x1283_5b01,
56    0x2431_85be,
57    0x550c_7dc3,
58    0x72be_5d74,
59    0x80de_b1fe,
60    0x9bdc_06a7,
61    0xc19b_f174,
62    0xe49b_69c1,
63    0xefbe_4786,
64    0x0fc1_9dc6,
65    0x240c_a1cc,
66    0x2de9_2c6f,
67    0x4a74_84aa,
68    0x5cb0_a9dc,
69    0x76f9_88da,
70    0x983e_5152,
71    0xa831_c66d,
72    0xb003_27c8,
73    0xbf59_7fc7,
74    0xc6e0_0bf3,
75    0xd5a7_9147,
76    0x06ca_6351,
77    0x1429_2967,
78    0x27b7_0a85,
79    0x2e1b_2138,
80    0x4d2c_6dfc,
81    0x5338_0d13,
82    0x650a_7354,
83    0x766a_0abb,
84    0x81c2_c92e,
85    0x9272_2c85,
86    0xa2bf_e8a1,
87    0xa81a_664b,
88    0xc24b_8b70,
89    0xc76c_51a3,
90    0xd192_e819,
91    0xd699_0624,
92    0xf40e_3585,
93    0x106a_a070,
94    0x19a4_c116,
95    0x1e37_6c08,
96    0x2748_774c,
97    0x34b0_bcb5,
98    0x391c_0cb3,
99    0x4ed8_aa4a,
100    0x5b9c_ca4f,
101    0x682e_6ff3,
102    0x748f_82ee,
103    0x78a5_636f,
104    0x84c8_7814,
105    0x8cc7_0208,
106    0x90be_fffa,
107    0xa450_6ceb,
108    0xbef9_a3f7,
109    0xc671_78f2,
110];
111
112/// Root slash path constant.
113pub(crate) const ROOT_SLASH: &str = "/";
114
115/// Empty string slice constant.
116pub(crate) const EMPTY_STR: &str = "";
117
118/// Genesis chain hash bytes (64 ASCII `'0'` digits).
119pub(crate) const AUDIT_GENESIS_BYTES: [u8; 64] = [b'0'; 64];
120
121/// Canonical field delimiter byte separating hashed audit record fields.
122pub(crate) const AUDIT_FIELD_SEP: u8 = b'|';
123
124/// Stack buffer capacity for base-10 formatting of 64-bit unsigned integers.
125pub(crate) const U64_STACK_BUF_LEN: usize = 20;
126
127/// ASCII `'0'` byte for fast decimal conversion.
128pub(crate) const ASCII_ZERO: u8 = b'0';