Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/spark-inquisitor/blob/main/tests/constitutional_rules.rs # spark-inquisitor Ultra-fast compiled native Rust gatekeeper and automated code reviewer Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `spark-inquisitor / tests / constitutional_rules.rs` 332 lines ยท 10892 bytes Raw Blame History 1 use spark_inquisitor::audit::DiffAuditor; 2 3 #[test] 4 fn test_em_dash_detected_in_code_comments() { 5 let diff = "diff --git a/src/lib.rs b/src/lib.rs\n+// Important note \u{2014} do not delete this function\npub fn keep() {}"; 6 let report = DiffAuditor::audit_text(diff); 7 assert!(!report.clean); 8 assert!(report 9 .unslop_violations 10 .iter() 11 .any(|u| u.contains("Em/En dash detected"))); 12 } 13 14 #[test] 15 fn test_em_dash_detected_in_string_literals() { 16 let diff = 17 "diff --git a/src/lib.rs b/src/lib.rs\n+pub const SLOGAN: &str = \"speed \u{2014} power\";"; 18 let report = DiffAuditor::audit_text(diff); 19 assert!(!report.clean); 20 assert!(report 21 .unslop_violations 22 .iter() 23 .any(|u| u.contains("Em/En dash detected"))); 24 } 25 26 #[test] 27 fn test_em_dash_detected_in_markdown() { 28 let diff = 29 "diff --git a/README.md b/README.md\n+- Core Feature \u{2014} high throughput engine"; 30 let report = DiffAuditor::audit_text(diff); 31 assert!(!report.clean); 32 assert!(report 33 .unslop_violations 34 .iter() 35 .any(|u| u.contains("Em/En dash detected"))); 36 } 37 38 #[test] 39 fn test_en_dash_detected_in_code_comments() { 40 let diff = "diff --git a/src/lib.rs b/src/lib.rs\n+// Range 10\u{2013}20 items"; 41 let report = DiffAuditor::audit_text(diff); 42 assert!(!report.clean); 43 assert!(report 44 .unslop_violations 45 .iter() 46 .any(|u| u.contains("Em/En dash detected"))); 47 } 48 49 #[test] 50 fn test_en_dash_detected_in_string_literals() { 51 let diff = "diff --git a/src/lib.rs b/src/lib.rs\n+let header = \"Version 1.0\u{2013}beta\";"; 52 let report = DiffAuditor::audit_text(diff); 53 assert!(!report.clean); 54 assert!(report 55 .unslop_violations 56 .iter() 57 .any(|u| u.contains("Em/En dash detected"))); 58 } 59 60 #[test] 61 fn test_en_dash_detected_in_markdown() { 62 let diff = "diff --git a/DOCS.md b/DOCS.md\n+Pages 5\u{2013}10 contain benchmarks."; 63 let report = DiffAuditor::audit_text(diff); 64 assert!(!report.clean); 65 assert!(report 66 .unslop_violations 67 .iter() 68 .any(|u| u.contains("Em/En dash detected"))); 69 } 70 71 #[test] 72 fn test_banned_buzzword_delve() { 73 let diff = "diff --git a/src/main.rs b/src/main.rs\n+// Let us delve into the architecture"; 74 let report = DiffAuditor::audit_text(diff); 75 assert!(!report.clean); 76 assert!(report.unslop_violations.iter().any(|u| u.contains("delve"))); 77 } 78 79 #[test] 80 fn test_banned_buzzword_tapestry() { 81 let diff = "diff --git a/src/main.rs b/src/main.rs\n+// A rich tapestry of microservices"; 82 let report = DiffAuditor::audit_text(diff); 83 assert!(!report.clean); 84 assert!(report 85 .unslop_violations 86 .iter() 87 .any(|u| u.contains("tapestry"))); 88 } 89 90 #[test] 91 fn test_banned_buzzword_testament() { 92 let diff = 93 "diff --git a/src/main.rs b/src/main.rs\n+// This code is a testament to our engineering"; 94 let report = DiffAuditor::audit_text(diff); 95 assert!(!report.clean); 96 assert!(report 97 .unslop_violations 98 .iter() 99 .any(|u| u.contains("testament"))); 100 } 101 102 #[test] 103 fn test_banned_buzzword_beacon_trope() { 104 let diff = 105 "diff --git a/src/main.rs b/src/main.rs\n+// Standing as a beacon of hope for open source"; 106 let report = DiffAuditor::audit_text(diff); 107 assert!(!report.clean); 108 assert!(report 109 .unslop_violations 110 .iter() 111 .any(|u| u.contains("beacon"))); 112 } 113 114 #[test] 115 fn test_beacon_hardware_term_allowed() { 116 let diff = "diff --git a/src/net.rs b/src/net.rs\n+fn parse_ble_beacon_packet(frame: &[u8]) -> bool { true }"; 117 let report = DiffAuditor::audit_text(diff); 118 assert!(report.clean); 119 } 120 121 #[test] 122 fn test_banned_buzzword_crucial() { 123 let diff = 124 "diff --git a/src/main.rs b/src/main.rs\n+// It is crucial to preserve cache coherence"; 125 let report = DiffAuditor::audit_text(diff); 126 assert!(!report.clean); 127 assert!(report 128 .unslop_violations 129 .iter() 130 .any(|u| u.contains("crucial"))); 131 } 132 133 #[test] 134 fn test_banned_buzzword_pivotal() { 135 let diff = 136 "diff --git a/src/main.rs b/src/main.rs\n+// A pivotal refactor for the memory engine"; 137 let report = DiffAuditor::audit_text(diff); 138 assert!(!report.clean); 139 assert!(report 140 .unslop_violations 141 .iter() 142 .any(|u| u.contains("pivotal"))); 143 } 144 145 #[test] 146 fn test_banned_buzzword_elevate() { 147 let diff = 148 "diff --git a/src/main.rs b/src/main.rs\n+// Designed to elevate the computing experience"; 149 let report = DiffAuditor::audit_text(diff); 150 assert!(!report.clean); 151 assert!(report 152 .unslop_violations 153 .iter() 154 .any(|u| u.contains("elevate"))); 155 } 156 157 #[test] 158 fn test_elevate_flag_allowed() { 159 let diff = "diff --git a/src/cli.rs b/src/cli.rs\n+let flag = \"--elevate-privileges\";"; 160 let report = DiffAuditor::audit_text(diff); 161 assert!(report.clean); 162 } 163 164 #[test] 165 fn test_banned_buzzword_game_changer() { 166 let diff = "diff --git a/src/main.rs b/src/main.rs\n+// The new allocator is a game-changer"; 167 let report = DiffAuditor::audit_text(diff); 168 assert!(!report.clean); 169 assert!(report 170 .unslop_violations 171 .iter() 172 .any(|u| u.contains("game-changer"))); 173 } 174 175 #[test] 176 fn test_banned_buzzword_unleash() { 177 let diff = "diff --git a/src/main.rs b/src/main.rs\n+// Unleash the power of local silicon"; 178 let report = DiffAuditor::audit_text(diff); 179 assert!(!report.clean); 180 assert!(report 181 .unslop_violations 182 .iter() 183 .any(|u| u.contains("unleash"))); 184 } 185 186 #[test] 187 fn test_unleash_flag_allowed() { 188 let diff = "diff --git a/src/args.rs b/src/args.rs\n+if args.contains(&\"--unleash-features\".to_string()) {}"; 189 let report = DiffAuditor::audit_text(diff); 190 assert!(report.clean); 191 } 192 193 #[test] 194 fn test_banned_buzzword_harness_verb() { 195 let diff = "diff --git a/src/main.rs b/src/main.rs\n+// We can harness the full throughput of GPU nodes"; 196 let report = DiffAuditor::audit_text(diff); 197 assert!(!report.clean); 198 assert!(report 199 .unslop_violations 200 .iter() 201 .any(|u| u.contains("harness"))); 202 } 203 204 #[test] 205 fn test_harness_noun_and_test_harness_allowed() { 206 let diff = "diff --git a/src/harness.rs b/src/harness.rs\n+// Verification test harness runner\npub struct TestHarness;"; 207 let report = DiffAuditor::audit_text(diff); 208 assert!(report.clean); 209 } 210 211 #[test] 212 fn test_allowed_word_seamlessly() { 213 let diff = 214 "diff --git a/src/main.rs b/src/main.rs\n+// Coordinates seamlessly across all instances"; 215 let report = DiffAuditor::audit_text(diff); 216 assert!(report.clean); 217 } 218 219 #[test] 220 fn test_antithesis_trope_not_x_but_y() { 221 let diff = 222 "diff --git a/src/main.rs b/src/main.rs\n+// It is not speed, but correctness that matters"; 223 let report = DiffAuditor::audit_text(diff); 224 assert!(!report.clean); 225 assert!(report 226 .unslop_violations 227 .iter() 228 .any(|u| u.contains("antithesis trope"))); 229 } 230 231 #[test] 232 fn test_antithesis_trope_not_only_x_but_y() { 233 let diff = "diff --git a/src/main.rs b/src/main.rs\n+// Not only fast, but completely reliable across all tests"; 234 let report = DiffAuditor::audit_text(diff); 235 assert!(!report.clean); 236 assert!(report 237 .unslop_violations 238 .iter() 239 .any(|u| u.contains("antithesis trope"))); 240 } 241 242 #[test] 243 fn test_plaintext_secret_aws_access_key() { 244 let diff = "diff --git a/src/vault.rs b/src/vault.rs\n+let aws_key = \"AKIA1234567890ABCDEF\";"; 245 let report = DiffAuditor::audit_text(diff); 246 assert!(!report.clean); 247 assert!(report 248 .secret_violations 249 .iter() 250 .any(|s| s.contains("AWS Access Key"))); 251 } 252 253 #[test] 254 fn test_plaintext_secret_github_pat() { 255 let diff = "diff --git a/src/auth.rs b/src/auth.rs\n+let token = \"ghp_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\";"; 256 let report = DiffAuditor::audit_text(diff); 257 assert!(!report.clean); 258 assert!(report 259 .secret_violations 260 .iter() 261 .any(|s| s.contains("GitHub Personal Access Token"))); 262 } 263 264 #[test] 265 fn test_plaintext_secret_github_fine_grained_pat() { 266 let diff = "diff --git a/src/auth.rs b/src/auth.rs\n+let token = \"github_pat_11AAAAAAA01234567890abcdefghijklmnopqrstuvwxyz_`01234567890abcdef`\";"; 267 let report = DiffAuditor::audit_text(diff); 268 assert!(!report.clean); 269 assert!(report 270 .secret_violations 271 .iter() 272 .any(|s| s.contains("GitHub Personal Access Token"))); 273 } 274 275 #[test] 276 fn test_plaintext_secret_rsa_private_key() { 277 let diff = "diff --git a/src/crypto.rs b/src/crypto.rs\n+const KEY: &str = \"-----BEGIN RSA PRIVATE KEY-----\\nMIIEowIBAAKCAQEA...\";"; 278 let report = DiffAuditor::audit_text(diff); 279 assert!(!report.clean); 280 assert!(report 281 .secret_violations 282 .iter() 283 .any(|s| s.contains("Private Key header"))); 284 } 285 286 #[test] 287 fn test_plaintext_secret_generic_private_key() { 288 let diff = "diff --git a/src/crypto.rs b/src/crypto.rs\n+const KEY: &str = \"-----BEGIN PRIVATE KEY-----\\nMIIEowIBAAKCAQEA...\";"; 289 let report = DiffAuditor::audit_text(diff); 290 assert!(!report.clean); 291 assert!(report 292 .secret_violations 293 .iter() 294 .any(|s| s.contains("Private Key header"))); 295 } 296 297 #[test] 298 fn test_env_file_addition_root() { 299 let diff = "diff --git a/.env b/.env\nnew file mode 100644\n--- /dev/null\n+++ b/.env\n@@ -0,0 +1,2 @@\n+PORT=8080\n+HOST=127.0.0.1"; 300 let report = DiffAuditor::audit_text(diff); 301 assert!(!report.clean); 302 assert!(report.violations.iter().any(|v| v.contains(".env"))); 303 } 304 305 #[test] 306 fn test_env_file_addition_nested() { 307 let diff = "diff --git a/crates/backend/.env.production b/crates/backend/.env.production\nnew file mode 100644\n--- /dev/null\n+++ b/crates/backend/.env.production\n@@ -0,0 +1,1 @@\n+NODE_ENV=production"; 308 let report = DiffAuditor::audit_text(diff); 309 assert!(!report.clean); 310 assert!(report.violations.iter().any(|v| v.contains(".env"))); 311 } 312 313 #[test] 314 fn test_false_positive_markdown_lists() { 315 let diff = "diff --git a/docs/README.md b/docs/README.md\n+- First item in checklist\n+- Second item in checklist\n+* Third item in checklist"; 316 let report = DiffAuditor::audit_text(diff); 317 assert!(report.clean); 318 } 319 320 #[test] 321 fn test_false_positive_negative_numbers_and_subtraction() { 322 let diff = "diff --git a/src/calc.rs b/src/calc.rs\n+let delta = a - b;\n+let temp = -40;\n+let offset = x - y - z;"; 323 let report = DiffAuditor::audit_text(diff); 324 assert!(report.clean); 325 } 326 327 #[test] 328 fn test_false_positive_standard_hyphenated_words() { 329 let diff = "diff --git a/src/arch.rs b/src/arch.rs\n+// Zero-telemetry multi-threaded aarch64-unknown-linux-gnu runtime\npub const TARGET: &str = \"aarch64-unknown-linux-gnu\";"; 330 let report = DiffAuditor::audit_text(diff); 331 assert!(report.clean); 332 }