├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── README.md ├── Rust-Security.pdf └── src └── bin ├── catch-unwind.rs ├── ctf.rs ├── default-values.rs ├── divide-before-multiply.rs ├── division-by-zero.rs ├── index-out-of-bounds.rs ├── oom.rs ├── overflow-prevention.rs ├── panicking-casting.rs ├── panicking-macros.rs ├── recoverable-errors-manual.rs ├── recoverable-errors-question.rs ├── round.rs ├── set-hook.rs ├── silent-casting.rs ├── stack-overflow.rs ├── underflow.rs └── unwrap-expect.rs /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "addr2line" 7 | version = "0.21.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" 10 | dependencies = [ 11 | "gimli", 12 | ] 13 | 14 | [[package]] 15 | name = "adler" 16 | version = "1.0.2" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 19 | 20 | [[package]] 21 | name = "aho-corasick" 22 | version = "1.1.2" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" 25 | dependencies = [ 26 | "memchr", 27 | ] 28 | 29 | [[package]] 30 | name = "arrayvec" 31 | version = "0.7.4" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" 34 | 35 | [[package]] 36 | name = "async-stream" 37 | version = "0.3.5" 38 | source = "registry+https://github.com/rust-lang/crates.io-index" 39 | checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" 40 | dependencies = [ 41 | "async-stream-impl", 42 | "futures-core", 43 | "pin-project-lite", 44 | ] 45 | 46 | [[package]] 47 | name = "async-stream-impl" 48 | version = "0.3.5" 49 | source = "registry+https://github.com/rust-lang/crates.io-index" 50 | checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" 51 | dependencies = [ 52 | "proc-macro2", 53 | "quote", 54 | "syn 2.0.41", 55 | ] 56 | 57 | [[package]] 58 | name = "async-trait" 59 | version = "0.1.76" 60 | source = "registry+https://github.com/rust-lang/crates.io-index" 61 | checksum = "531b97fb4cd3dfdce92c35dedbfdc1f0b9d8091c8ca943d6dae340ef5012d514" 62 | dependencies = [ 63 | "proc-macro2", 64 | "quote", 65 | "syn 2.0.41", 66 | ] 67 | 68 | [[package]] 69 | name = "atomic" 70 | version = "0.5.3" 71 | source = "registry+https://github.com/rust-lang/crates.io-index" 72 | checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" 73 | 74 | [[package]] 75 | name = "atomic" 76 | version = "0.6.0" 77 | source = "registry+https://github.com/rust-lang/crates.io-index" 78 | checksum = "8d818003e740b63afc82337e3160717f4f63078720a810b7b903e70a5d1d2994" 79 | dependencies = [ 80 | "bytemuck", 81 | ] 82 | 83 | [[package]] 84 | name = "autocfg" 85 | version = "1.1.0" 86 | source = "registry+https://github.com/rust-lang/crates.io-index" 87 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 88 | 89 | [[package]] 90 | name = "backtrace" 91 | version = "0.3.69" 92 | source = "registry+https://github.com/rust-lang/crates.io-index" 93 | checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" 94 | dependencies = [ 95 | "addr2line", 96 | "cc", 97 | "cfg-if", 98 | "libc", 99 | "miniz_oxide", 100 | "object", 101 | "rustc-demangle", 102 | ] 103 | 104 | [[package]] 105 | name = "binascii" 106 | version = "0.1.4" 107 | source = "registry+https://github.com/rust-lang/crates.io-index" 108 | checksum = "383d29d513d8764dcdc42ea295d979eb99c3c9f00607b3692cf68a431f7dca72" 109 | 110 | [[package]] 111 | name = "bitflags" 112 | version = "1.3.2" 113 | source = "registry+https://github.com/rust-lang/crates.io-index" 114 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 115 | 116 | [[package]] 117 | name = "bitflags" 118 | version = "2.4.2" 119 | source = "registry+https://github.com/rust-lang/crates.io-index" 120 | checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" 121 | 122 | [[package]] 123 | name = "bitvec" 124 | version = "1.0.1" 125 | source = "registry+https://github.com/rust-lang/crates.io-index" 126 | checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" 127 | dependencies = [ 128 | "funty", 129 | "radium", 130 | "tap", 131 | "wyz", 132 | ] 133 | 134 | [[package]] 135 | name = "byte-slice-cast" 136 | version = "1.2.2" 137 | source = "registry+https://github.com/rust-lang/crates.io-index" 138 | checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" 139 | 140 | [[package]] 141 | name = "bytemuck" 142 | version = "1.14.3" 143 | source = "registry+https://github.com/rust-lang/crates.io-index" 144 | checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" 145 | 146 | [[package]] 147 | name = "byteorder" 148 | version = "1.5.0" 149 | source = "registry+https://github.com/rust-lang/crates.io-index" 150 | checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" 151 | 152 | [[package]] 153 | name = "bytes" 154 | version = "1.5.0" 155 | source = "registry+https://github.com/rust-lang/crates.io-index" 156 | checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" 157 | 158 | [[package]] 159 | name = "cc" 160 | version = "1.0.88" 161 | source = "registry+https://github.com/rust-lang/crates.io-index" 162 | checksum = "02f341c093d19155a6e41631ce5971aac4e9a868262212153124c15fa22d1cdc" 163 | 164 | [[package]] 165 | name = "cfg-if" 166 | version = "1.0.0" 167 | source = "registry+https://github.com/rust-lang/crates.io-index" 168 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 169 | 170 | [[package]] 171 | name = "cookie" 172 | version = "0.18.0" 173 | source = "registry+https://github.com/rust-lang/crates.io-index" 174 | checksum = "3cd91cf61412820176e137621345ee43b3f4423e589e7ae4e50d601d93e35ef8" 175 | dependencies = [ 176 | "percent-encoding", 177 | "time", 178 | "version_check", 179 | ] 180 | 181 | [[package]] 182 | name = "crunchy" 183 | version = "0.2.2" 184 | source = "registry+https://github.com/rust-lang/crates.io-index" 185 | checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" 186 | 187 | [[package]] 188 | name = "deranged" 189 | version = "0.3.11" 190 | source = "registry+https://github.com/rust-lang/crates.io-index" 191 | checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" 192 | dependencies = [ 193 | "powerfmt", 194 | ] 195 | 196 | [[package]] 197 | name = "devise" 198 | version = "0.4.1" 199 | source = "registry+https://github.com/rust-lang/crates.io-index" 200 | checksum = "d6eacefd3f541c66fc61433d65e54e0e46e0a029a819a7dbbc7a7b489e8a85f8" 201 | dependencies = [ 202 | "devise_codegen", 203 | "devise_core", 204 | ] 205 | 206 | [[package]] 207 | name = "devise_codegen" 208 | version = "0.4.1" 209 | source = "registry+https://github.com/rust-lang/crates.io-index" 210 | checksum = "9c8cf4b8dd484ede80fd5c547592c46c3745a617c8af278e2b72bea86b2dfed6" 211 | dependencies = [ 212 | "devise_core", 213 | "quote", 214 | ] 215 | 216 | [[package]] 217 | name = "devise_core" 218 | version = "0.4.1" 219 | source = "registry+https://github.com/rust-lang/crates.io-index" 220 | checksum = "35b50dba0afdca80b187392b24f2499a88c336d5a8493e4b4ccfb608708be56a" 221 | dependencies = [ 222 | "bitflags 2.4.2", 223 | "proc-macro2", 224 | "proc-macro2-diagnostics", 225 | "quote", 226 | "syn 2.0.41", 227 | ] 228 | 229 | [[package]] 230 | name = "either" 231 | version = "1.10.0" 232 | source = "registry+https://github.com/rust-lang/crates.io-index" 233 | checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" 234 | 235 | [[package]] 236 | name = "encoding_rs" 237 | version = "0.8.33" 238 | source = "registry+https://github.com/rust-lang/crates.io-index" 239 | checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" 240 | dependencies = [ 241 | "cfg-if", 242 | ] 243 | 244 | [[package]] 245 | name = "equivalent" 246 | version = "1.0.1" 247 | source = "registry+https://github.com/rust-lang/crates.io-index" 248 | checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" 249 | 250 | [[package]] 251 | name = "errno" 252 | version = "0.3.8" 253 | source = "registry+https://github.com/rust-lang/crates.io-index" 254 | checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" 255 | dependencies = [ 256 | "libc", 257 | "windows-sys 0.52.0", 258 | ] 259 | 260 | [[package]] 261 | name = "fastrand" 262 | version = "2.0.1" 263 | source = "registry+https://github.com/rust-lang/crates.io-index" 264 | checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" 265 | 266 | [[package]] 267 | name = "figment" 268 | version = "0.10.14" 269 | source = "registry+https://github.com/rust-lang/crates.io-index" 270 | checksum = "2b6e5bc7bd59d60d0d45a6ccab6cf0f4ce28698fb4e81e750ddf229c9b824026" 271 | dependencies = [ 272 | "atomic 0.6.0", 273 | "pear", 274 | "serde", 275 | "toml", 276 | "uncased", 277 | "version_check", 278 | ] 279 | 280 | [[package]] 281 | name = "fixed-hash" 282 | version = "0.7.0" 283 | source = "registry+https://github.com/rust-lang/crates.io-index" 284 | checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" 285 | dependencies = [ 286 | "byteorder", 287 | "rand", 288 | "rustc-hex", 289 | "static_assertions", 290 | ] 291 | 292 | [[package]] 293 | name = "fnv" 294 | version = "1.0.7" 295 | source = "registry+https://github.com/rust-lang/crates.io-index" 296 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 297 | 298 | [[package]] 299 | name = "funty" 300 | version = "2.0.0" 301 | source = "registry+https://github.com/rust-lang/crates.io-index" 302 | checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" 303 | 304 | [[package]] 305 | name = "futures" 306 | version = "0.3.30" 307 | source = "registry+https://github.com/rust-lang/crates.io-index" 308 | checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" 309 | dependencies = [ 310 | "futures-channel", 311 | "futures-core", 312 | "futures-io", 313 | "futures-sink", 314 | "futures-task", 315 | "futures-util", 316 | ] 317 | 318 | [[package]] 319 | name = "futures-channel" 320 | version = "0.3.30" 321 | source = "registry+https://github.com/rust-lang/crates.io-index" 322 | checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" 323 | dependencies = [ 324 | "futures-core", 325 | "futures-sink", 326 | ] 327 | 328 | [[package]] 329 | name = "futures-core" 330 | version = "0.3.30" 331 | source = "registry+https://github.com/rust-lang/crates.io-index" 332 | checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" 333 | 334 | [[package]] 335 | name = "futures-io" 336 | version = "0.3.30" 337 | source = "registry+https://github.com/rust-lang/crates.io-index" 338 | checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" 339 | 340 | [[package]] 341 | name = "futures-sink" 342 | version = "0.3.30" 343 | source = "registry+https://github.com/rust-lang/crates.io-index" 344 | checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" 345 | 346 | [[package]] 347 | name = "futures-task" 348 | version = "0.3.30" 349 | source = "registry+https://github.com/rust-lang/crates.io-index" 350 | checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" 351 | 352 | [[package]] 353 | name = "futures-util" 354 | version = "0.3.30" 355 | source = "registry+https://github.com/rust-lang/crates.io-index" 356 | checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" 357 | dependencies = [ 358 | "futures-channel", 359 | "futures-core", 360 | "futures-io", 361 | "futures-sink", 362 | "futures-task", 363 | "memchr", 364 | "pin-project-lite", 365 | "pin-utils", 366 | "slab", 367 | ] 368 | 369 | [[package]] 370 | name = "generator" 371 | version = "0.7.5" 372 | source = "registry+https://github.com/rust-lang/crates.io-index" 373 | checksum = "5cc16584ff22b460a382b7feec54b23d2908d858152e5739a120b949293bd74e" 374 | dependencies = [ 375 | "cc", 376 | "libc", 377 | "log", 378 | "rustversion", 379 | "windows", 380 | ] 381 | 382 | [[package]] 383 | name = "getrandom" 384 | version = "0.2.11" 385 | source = "registry+https://github.com/rust-lang/crates.io-index" 386 | checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" 387 | dependencies = [ 388 | "cfg-if", 389 | "libc", 390 | "wasi", 391 | ] 392 | 393 | [[package]] 394 | name = "gimli" 395 | version = "0.28.1" 396 | source = "registry+https://github.com/rust-lang/crates.io-index" 397 | checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" 398 | 399 | [[package]] 400 | name = "glob" 401 | version = "0.3.1" 402 | source = "registry+https://github.com/rust-lang/crates.io-index" 403 | checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" 404 | 405 | [[package]] 406 | name = "h2" 407 | version = "0.3.24" 408 | source = "registry+https://github.com/rust-lang/crates.io-index" 409 | checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" 410 | dependencies = [ 411 | "bytes", 412 | "fnv", 413 | "futures-core", 414 | "futures-sink", 415 | "futures-util", 416 | "http", 417 | "indexmap", 418 | "slab", 419 | "tokio", 420 | "tokio-util", 421 | "tracing", 422 | ] 423 | 424 | [[package]] 425 | name = "hashbrown" 426 | version = "0.14.3" 427 | source = "registry+https://github.com/rust-lang/crates.io-index" 428 | checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" 429 | 430 | [[package]] 431 | name = "hermit-abi" 432 | version = "0.3.8" 433 | source = "registry+https://github.com/rust-lang/crates.io-index" 434 | checksum = "379dada1584ad501b383485dd706b8afb7a70fcbc7f4da7d780638a5a6124a60" 435 | 436 | [[package]] 437 | name = "hex" 438 | version = "0.4.3" 439 | source = "registry+https://github.com/rust-lang/crates.io-index" 440 | checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 441 | 442 | [[package]] 443 | name = "http" 444 | version = "0.2.11" 445 | source = "registry+https://github.com/rust-lang/crates.io-index" 446 | checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" 447 | dependencies = [ 448 | "bytes", 449 | "fnv", 450 | "itoa", 451 | ] 452 | 453 | [[package]] 454 | name = "http-body" 455 | version = "0.4.6" 456 | source = "registry+https://github.com/rust-lang/crates.io-index" 457 | checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" 458 | dependencies = [ 459 | "bytes", 460 | "http", 461 | "pin-project-lite", 462 | ] 463 | 464 | [[package]] 465 | name = "httparse" 466 | version = "1.8.0" 467 | source = "registry+https://github.com/rust-lang/crates.io-index" 468 | checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" 469 | 470 | [[package]] 471 | name = "httpdate" 472 | version = "1.0.3" 473 | source = "registry+https://github.com/rust-lang/crates.io-index" 474 | checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" 475 | 476 | [[package]] 477 | name = "hyper" 478 | version = "0.14.28" 479 | source = "registry+https://github.com/rust-lang/crates.io-index" 480 | checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" 481 | dependencies = [ 482 | "bytes", 483 | "futures-channel", 484 | "futures-core", 485 | "futures-util", 486 | "h2", 487 | "http", 488 | "http-body", 489 | "httparse", 490 | "httpdate", 491 | "itoa", 492 | "pin-project-lite", 493 | "socket2", 494 | "tokio", 495 | "tower-service", 496 | "tracing", 497 | "want", 498 | ] 499 | 500 | [[package]] 501 | name = "impl-codec" 502 | version = "0.6.0" 503 | source = "registry+https://github.com/rust-lang/crates.io-index" 504 | checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" 505 | dependencies = [ 506 | "parity-scale-codec", 507 | ] 508 | 509 | [[package]] 510 | name = "impl-trait-for-tuples" 511 | version = "0.2.2" 512 | source = "registry+https://github.com/rust-lang/crates.io-index" 513 | checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" 514 | dependencies = [ 515 | "proc-macro2", 516 | "quote", 517 | "syn 1.0.109", 518 | ] 519 | 520 | [[package]] 521 | name = "indexmap" 522 | version = "2.1.0" 523 | source = "registry+https://github.com/rust-lang/crates.io-index" 524 | checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" 525 | dependencies = [ 526 | "equivalent", 527 | "hashbrown", 528 | "serde", 529 | ] 530 | 531 | [[package]] 532 | name = "inlinable_string" 533 | version = "0.1.15" 534 | source = "registry+https://github.com/rust-lang/crates.io-index" 535 | checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb" 536 | 537 | [[package]] 538 | name = "is-terminal" 539 | version = "0.4.12" 540 | source = "registry+https://github.com/rust-lang/crates.io-index" 541 | checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" 542 | dependencies = [ 543 | "hermit-abi", 544 | "libc", 545 | "windows-sys 0.52.0", 546 | ] 547 | 548 | [[package]] 549 | name = "itoa" 550 | version = "1.0.10" 551 | source = "registry+https://github.com/rust-lang/crates.io-index" 552 | checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" 553 | 554 | [[package]] 555 | name = "lazy_static" 556 | version = "1.4.0" 557 | source = "registry+https://github.com/rust-lang/crates.io-index" 558 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 559 | 560 | [[package]] 561 | name = "libc" 562 | version = "0.2.151" 563 | source = "registry+https://github.com/rust-lang/crates.io-index" 564 | checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" 565 | 566 | [[package]] 567 | name = "linux-raw-sys" 568 | version = "0.4.13" 569 | source = "registry+https://github.com/rust-lang/crates.io-index" 570 | checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" 571 | 572 | [[package]] 573 | name = "lock_api" 574 | version = "0.4.11" 575 | source = "registry+https://github.com/rust-lang/crates.io-index" 576 | checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" 577 | dependencies = [ 578 | "autocfg", 579 | "scopeguard", 580 | ] 581 | 582 | [[package]] 583 | name = "log" 584 | version = "0.4.20" 585 | source = "registry+https://github.com/rust-lang/crates.io-index" 586 | checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" 587 | 588 | [[package]] 589 | name = "loom" 590 | version = "0.5.6" 591 | source = "registry+https://github.com/rust-lang/crates.io-index" 592 | checksum = "ff50ecb28bb86013e935fb6683ab1f6d3a20016f123c76fd4c27470076ac30f5" 593 | dependencies = [ 594 | "cfg-if", 595 | "generator", 596 | "scoped-tls", 597 | "serde", 598 | "serde_json", 599 | "tracing", 600 | "tracing-subscriber", 601 | ] 602 | 603 | [[package]] 604 | name = "matchers" 605 | version = "0.1.0" 606 | source = "registry+https://github.com/rust-lang/crates.io-index" 607 | checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" 608 | dependencies = [ 609 | "regex-automata 0.1.10", 610 | ] 611 | 612 | [[package]] 613 | name = "memchr" 614 | version = "2.6.4" 615 | source = "registry+https://github.com/rust-lang/crates.io-index" 616 | checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" 617 | 618 | [[package]] 619 | name = "mime" 620 | version = "0.3.17" 621 | source = "registry+https://github.com/rust-lang/crates.io-index" 622 | checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" 623 | 624 | [[package]] 625 | name = "miniz_oxide" 626 | version = "0.7.2" 627 | source = "registry+https://github.com/rust-lang/crates.io-index" 628 | checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" 629 | dependencies = [ 630 | "adler", 631 | ] 632 | 633 | [[package]] 634 | name = "mio" 635 | version = "0.8.10" 636 | source = "registry+https://github.com/rust-lang/crates.io-index" 637 | checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" 638 | dependencies = [ 639 | "libc", 640 | "wasi", 641 | "windows-sys 0.48.0", 642 | ] 643 | 644 | [[package]] 645 | name = "multer" 646 | version = "2.1.0" 647 | source = "registry+https://github.com/rust-lang/crates.io-index" 648 | checksum = "01acbdc23469fd8fe07ab135923371d5f5a422fbf9c522158677c8eb15bc51c2" 649 | dependencies = [ 650 | "bytes", 651 | "encoding_rs", 652 | "futures-util", 653 | "http", 654 | "httparse", 655 | "log", 656 | "memchr", 657 | "mime", 658 | "spin", 659 | "tokio", 660 | "tokio-util", 661 | "version_check", 662 | ] 663 | 664 | [[package]] 665 | name = "nu-ansi-term" 666 | version = "0.46.0" 667 | source = "registry+https://github.com/rust-lang/crates.io-index" 668 | checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" 669 | dependencies = [ 670 | "overload", 671 | "winapi", 672 | ] 673 | 674 | [[package]] 675 | name = "num-conv" 676 | version = "0.1.0" 677 | source = "registry+https://github.com/rust-lang/crates.io-index" 678 | checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" 679 | 680 | [[package]] 681 | name = "num_cpus" 682 | version = "1.16.0" 683 | source = "registry+https://github.com/rust-lang/crates.io-index" 684 | checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" 685 | dependencies = [ 686 | "hermit-abi", 687 | "libc", 688 | ] 689 | 690 | [[package]] 691 | name = "object" 692 | version = "0.32.2" 693 | source = "registry+https://github.com/rust-lang/crates.io-index" 694 | checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" 695 | dependencies = [ 696 | "memchr", 697 | ] 698 | 699 | [[package]] 700 | name = "once_cell" 701 | version = "1.19.0" 702 | source = "registry+https://github.com/rust-lang/crates.io-index" 703 | checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" 704 | 705 | [[package]] 706 | name = "overload" 707 | version = "0.1.1" 708 | source = "registry+https://github.com/rust-lang/crates.io-index" 709 | checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" 710 | 711 | [[package]] 712 | name = "parity-scale-codec" 713 | version = "3.6.9" 714 | source = "registry+https://github.com/rust-lang/crates.io-index" 715 | checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" 716 | dependencies = [ 717 | "arrayvec", 718 | "bitvec", 719 | "byte-slice-cast", 720 | "impl-trait-for-tuples", 721 | "parity-scale-codec-derive", 722 | "serde", 723 | ] 724 | 725 | [[package]] 726 | name = "parity-scale-codec-derive" 727 | version = "3.6.9" 728 | source = "registry+https://github.com/rust-lang/crates.io-index" 729 | checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" 730 | dependencies = [ 731 | "proc-macro-crate", 732 | "proc-macro2", 733 | "quote", 734 | "syn 1.0.109", 735 | ] 736 | 737 | [[package]] 738 | name = "parking_lot" 739 | version = "0.12.1" 740 | source = "registry+https://github.com/rust-lang/crates.io-index" 741 | checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" 742 | dependencies = [ 743 | "lock_api", 744 | "parking_lot_core", 745 | ] 746 | 747 | [[package]] 748 | name = "parking_lot_core" 749 | version = "0.9.9" 750 | source = "registry+https://github.com/rust-lang/crates.io-index" 751 | checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" 752 | dependencies = [ 753 | "cfg-if", 754 | "libc", 755 | "redox_syscall", 756 | "smallvec", 757 | "windows-targets 0.48.5", 758 | ] 759 | 760 | [[package]] 761 | name = "pear" 762 | version = "0.2.8" 763 | source = "registry+https://github.com/rust-lang/crates.io-index" 764 | checksum = "4ccca0f6c17acc81df8e242ed473ec144cbf5c98037e69aa6d144780aad103c8" 765 | dependencies = [ 766 | "inlinable_string", 767 | "pear_codegen", 768 | "yansi", 769 | ] 770 | 771 | [[package]] 772 | name = "pear_codegen" 773 | version = "0.2.8" 774 | source = "registry+https://github.com/rust-lang/crates.io-index" 775 | checksum = "2e22670e8eb757cff11d6c199ca7b987f352f0346e0be4dd23869ec72cb53c77" 776 | dependencies = [ 777 | "proc-macro2", 778 | "proc-macro2-diagnostics", 779 | "quote", 780 | "syn 2.0.41", 781 | ] 782 | 783 | [[package]] 784 | name = "percent-encoding" 785 | version = "2.3.1" 786 | source = "registry+https://github.com/rust-lang/crates.io-index" 787 | checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" 788 | 789 | [[package]] 790 | name = "pin-project-lite" 791 | version = "0.2.13" 792 | source = "registry+https://github.com/rust-lang/crates.io-index" 793 | checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" 794 | 795 | [[package]] 796 | name = "pin-utils" 797 | version = "0.1.0" 798 | source = "registry+https://github.com/rust-lang/crates.io-index" 799 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 800 | 801 | [[package]] 802 | name = "powerfmt" 803 | version = "0.2.0" 804 | source = "registry+https://github.com/rust-lang/crates.io-index" 805 | checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" 806 | 807 | [[package]] 808 | name = "ppv-lite86" 809 | version = "0.2.17" 810 | source = "registry+https://github.com/rust-lang/crates.io-index" 811 | checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" 812 | 813 | [[package]] 814 | name = "primitive-types" 815 | version = "0.11.1" 816 | source = "registry+https://github.com/rust-lang/crates.io-index" 817 | checksum = "e28720988bff275df1f51b171e1b2a18c30d194c4d2b61defdacecd625a5d94a" 818 | dependencies = [ 819 | "fixed-hash", 820 | "impl-codec", 821 | "uint", 822 | ] 823 | 824 | [[package]] 825 | name = "proc-macro-crate" 826 | version = "2.0.0" 827 | source = "registry+https://github.com/rust-lang/crates.io-index" 828 | checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" 829 | dependencies = [ 830 | "toml_edit 0.20.2", 831 | ] 832 | 833 | [[package]] 834 | name = "proc-macro2" 835 | version = "1.0.70" 836 | source = "registry+https://github.com/rust-lang/crates.io-index" 837 | checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" 838 | dependencies = [ 839 | "unicode-ident", 840 | ] 841 | 842 | [[package]] 843 | name = "proc-macro2-diagnostics" 844 | version = "0.10.1" 845 | source = "registry+https://github.com/rust-lang/crates.io-index" 846 | checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" 847 | dependencies = [ 848 | "proc-macro2", 849 | "quote", 850 | "syn 2.0.41", 851 | "version_check", 852 | "yansi", 853 | ] 854 | 855 | [[package]] 856 | name = "quote" 857 | version = "1.0.33" 858 | source = "registry+https://github.com/rust-lang/crates.io-index" 859 | checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" 860 | dependencies = [ 861 | "proc-macro2", 862 | ] 863 | 864 | [[package]] 865 | name = "radium" 866 | version = "0.7.0" 867 | source = "registry+https://github.com/rust-lang/crates.io-index" 868 | checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" 869 | 870 | [[package]] 871 | name = "rand" 872 | version = "0.8.5" 873 | source = "registry+https://github.com/rust-lang/crates.io-index" 874 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 875 | dependencies = [ 876 | "libc", 877 | "rand_chacha", 878 | "rand_core", 879 | ] 880 | 881 | [[package]] 882 | name = "rand_chacha" 883 | version = "0.3.1" 884 | source = "registry+https://github.com/rust-lang/crates.io-index" 885 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 886 | dependencies = [ 887 | "ppv-lite86", 888 | "rand_core", 889 | ] 890 | 891 | [[package]] 892 | name = "rand_core" 893 | version = "0.6.4" 894 | source = "registry+https://github.com/rust-lang/crates.io-index" 895 | checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 896 | dependencies = [ 897 | "getrandom", 898 | ] 899 | 900 | [[package]] 901 | name = "redox_syscall" 902 | version = "0.4.1" 903 | source = "registry+https://github.com/rust-lang/crates.io-index" 904 | checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" 905 | dependencies = [ 906 | "bitflags 1.3.2", 907 | ] 908 | 909 | [[package]] 910 | name = "ref-cast" 911 | version = "1.0.21" 912 | source = "registry+https://github.com/rust-lang/crates.io-index" 913 | checksum = "53313ec9f12686aeeffb43462c3ac77aa25f590a5f630eb2cde0de59417b29c7" 914 | dependencies = [ 915 | "ref-cast-impl", 916 | ] 917 | 918 | [[package]] 919 | name = "ref-cast-impl" 920 | version = "1.0.21" 921 | source = "registry+https://github.com/rust-lang/crates.io-index" 922 | checksum = "2566c4bf6845f2c2e83b27043c3f5dfcd5ba8f2937d6c00dc009bfb51a079dc4" 923 | dependencies = [ 924 | "proc-macro2", 925 | "quote", 926 | "syn 2.0.41", 927 | ] 928 | 929 | [[package]] 930 | name = "regex" 931 | version = "1.10.3" 932 | source = "registry+https://github.com/rust-lang/crates.io-index" 933 | checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" 934 | dependencies = [ 935 | "aho-corasick", 936 | "memchr", 937 | "regex-automata 0.4.5", 938 | "regex-syntax 0.8.2", 939 | ] 940 | 941 | [[package]] 942 | name = "regex-automata" 943 | version = "0.1.10" 944 | source = "registry+https://github.com/rust-lang/crates.io-index" 945 | checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" 946 | dependencies = [ 947 | "regex-syntax 0.6.29", 948 | ] 949 | 950 | [[package]] 951 | name = "regex-automata" 952 | version = "0.4.5" 953 | source = "registry+https://github.com/rust-lang/crates.io-index" 954 | checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" 955 | dependencies = [ 956 | "aho-corasick", 957 | "memchr", 958 | "regex-syntax 0.8.2", 959 | ] 960 | 961 | [[package]] 962 | name = "regex-syntax" 963 | version = "0.6.29" 964 | source = "registry+https://github.com/rust-lang/crates.io-index" 965 | checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" 966 | 967 | [[package]] 968 | name = "regex-syntax" 969 | version = "0.8.2" 970 | source = "registry+https://github.com/rust-lang/crates.io-index" 971 | checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" 972 | 973 | [[package]] 974 | name = "rocket" 975 | version = "0.5.0" 976 | source = "registry+https://github.com/rust-lang/crates.io-index" 977 | checksum = "9e7bb57ccb26670d73b6a47396c83139447b9e7878cab627fdfe9ea8da489150" 978 | dependencies = [ 979 | "async-stream", 980 | "async-trait", 981 | "atomic 0.5.3", 982 | "binascii", 983 | "bytes", 984 | "either", 985 | "figment", 986 | "futures", 987 | "indexmap", 988 | "log", 989 | "memchr", 990 | "multer", 991 | "num_cpus", 992 | "parking_lot", 993 | "pin-project-lite", 994 | "rand", 995 | "ref-cast", 996 | "rocket_codegen", 997 | "rocket_http", 998 | "serde", 999 | "state", 1000 | "tempfile", 1001 | "time", 1002 | "tokio", 1003 | "tokio-stream", 1004 | "tokio-util", 1005 | "ubyte", 1006 | "version_check", 1007 | "yansi", 1008 | ] 1009 | 1010 | [[package]] 1011 | name = "rocket_codegen" 1012 | version = "0.5.0" 1013 | source = "registry+https://github.com/rust-lang/crates.io-index" 1014 | checksum = "a2238066abf75f21be6cd7dc1a09d5414a671f4246e384e49fe3f8a4936bd04c" 1015 | dependencies = [ 1016 | "devise", 1017 | "glob", 1018 | "indexmap", 1019 | "proc-macro2", 1020 | "quote", 1021 | "rocket_http", 1022 | "syn 2.0.41", 1023 | "unicode-xid", 1024 | "version_check", 1025 | ] 1026 | 1027 | [[package]] 1028 | name = "rocket_http" 1029 | version = "0.5.0" 1030 | source = "registry+https://github.com/rust-lang/crates.io-index" 1031 | checksum = "37a1663694d059fe5f943ea5481363e48050acedd241d46deb2e27f71110389e" 1032 | dependencies = [ 1033 | "cookie", 1034 | "either", 1035 | "futures", 1036 | "http", 1037 | "hyper", 1038 | "indexmap", 1039 | "log", 1040 | "memchr", 1041 | "pear", 1042 | "percent-encoding", 1043 | "pin-project-lite", 1044 | "ref-cast", 1045 | "serde", 1046 | "smallvec", 1047 | "stable-pattern", 1048 | "state", 1049 | "time", 1050 | "tokio", 1051 | "uncased", 1052 | ] 1053 | 1054 | [[package]] 1055 | name = "rust-pocs" 1056 | version = "1.0.0" 1057 | dependencies = [ 1058 | "primitive-types", 1059 | "rocket", 1060 | ] 1061 | 1062 | [[package]] 1063 | name = "rustc-demangle" 1064 | version = "0.1.23" 1065 | source = "registry+https://github.com/rust-lang/crates.io-index" 1066 | checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" 1067 | 1068 | [[package]] 1069 | name = "rustc-hex" 1070 | version = "2.1.0" 1071 | source = "registry+https://github.com/rust-lang/crates.io-index" 1072 | checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" 1073 | 1074 | [[package]] 1075 | name = "rustix" 1076 | version = "0.38.28" 1077 | source = "registry+https://github.com/rust-lang/crates.io-index" 1078 | checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" 1079 | dependencies = [ 1080 | "bitflags 2.4.2", 1081 | "errno", 1082 | "libc", 1083 | "linux-raw-sys", 1084 | "windows-sys 0.52.0", 1085 | ] 1086 | 1087 | [[package]] 1088 | name = "rustversion" 1089 | version = "1.0.14" 1090 | source = "registry+https://github.com/rust-lang/crates.io-index" 1091 | checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" 1092 | 1093 | [[package]] 1094 | name = "ryu" 1095 | version = "1.0.17" 1096 | source = "registry+https://github.com/rust-lang/crates.io-index" 1097 | checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" 1098 | 1099 | [[package]] 1100 | name = "scoped-tls" 1101 | version = "1.0.1" 1102 | source = "registry+https://github.com/rust-lang/crates.io-index" 1103 | checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" 1104 | 1105 | [[package]] 1106 | name = "scopeguard" 1107 | version = "1.2.0" 1108 | source = "registry+https://github.com/rust-lang/crates.io-index" 1109 | checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" 1110 | 1111 | [[package]] 1112 | name = "serde" 1113 | version = "1.0.193" 1114 | source = "registry+https://github.com/rust-lang/crates.io-index" 1115 | checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" 1116 | dependencies = [ 1117 | "serde_derive", 1118 | ] 1119 | 1120 | [[package]] 1121 | name = "serde_derive" 1122 | version = "1.0.193" 1123 | source = "registry+https://github.com/rust-lang/crates.io-index" 1124 | checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" 1125 | dependencies = [ 1126 | "proc-macro2", 1127 | "quote", 1128 | "syn 2.0.41", 1129 | ] 1130 | 1131 | [[package]] 1132 | name = "serde_json" 1133 | version = "1.0.109" 1134 | source = "registry+https://github.com/rust-lang/crates.io-index" 1135 | checksum = "cb0652c533506ad7a2e353cce269330d6afd8bdfb6d75e0ace5b35aacbd7b9e9" 1136 | dependencies = [ 1137 | "itoa", 1138 | "ryu", 1139 | "serde", 1140 | ] 1141 | 1142 | [[package]] 1143 | name = "serde_spanned" 1144 | version = "0.6.5" 1145 | source = "registry+https://github.com/rust-lang/crates.io-index" 1146 | checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" 1147 | dependencies = [ 1148 | "serde", 1149 | ] 1150 | 1151 | [[package]] 1152 | name = "sharded-slab" 1153 | version = "0.1.7" 1154 | source = "registry+https://github.com/rust-lang/crates.io-index" 1155 | checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" 1156 | dependencies = [ 1157 | "lazy_static", 1158 | ] 1159 | 1160 | [[package]] 1161 | name = "signal-hook-registry" 1162 | version = "1.4.1" 1163 | source = "registry+https://github.com/rust-lang/crates.io-index" 1164 | checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" 1165 | dependencies = [ 1166 | "libc", 1167 | ] 1168 | 1169 | [[package]] 1170 | name = "slab" 1171 | version = "0.4.9" 1172 | source = "registry+https://github.com/rust-lang/crates.io-index" 1173 | checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" 1174 | dependencies = [ 1175 | "autocfg", 1176 | ] 1177 | 1178 | [[package]] 1179 | name = "smallvec" 1180 | version = "1.13.1" 1181 | source = "registry+https://github.com/rust-lang/crates.io-index" 1182 | checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" 1183 | 1184 | [[package]] 1185 | name = "socket2" 1186 | version = "0.5.6" 1187 | source = "registry+https://github.com/rust-lang/crates.io-index" 1188 | checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" 1189 | dependencies = [ 1190 | "libc", 1191 | "windows-sys 0.52.0", 1192 | ] 1193 | 1194 | [[package]] 1195 | name = "spin" 1196 | version = "0.9.8" 1197 | source = "registry+https://github.com/rust-lang/crates.io-index" 1198 | checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" 1199 | 1200 | [[package]] 1201 | name = "stable-pattern" 1202 | version = "0.1.0" 1203 | source = "registry+https://github.com/rust-lang/crates.io-index" 1204 | checksum = "4564168c00635f88eaed410d5efa8131afa8d8699a612c80c455a0ba05c21045" 1205 | dependencies = [ 1206 | "memchr", 1207 | ] 1208 | 1209 | [[package]] 1210 | name = "state" 1211 | version = "0.6.0" 1212 | source = "registry+https://github.com/rust-lang/crates.io-index" 1213 | checksum = "2b8c4a4445d81357df8b1a650d0d0d6fbbbfe99d064aa5e02f3e4022061476d8" 1214 | dependencies = [ 1215 | "loom", 1216 | ] 1217 | 1218 | [[package]] 1219 | name = "static_assertions" 1220 | version = "1.1.0" 1221 | source = "registry+https://github.com/rust-lang/crates.io-index" 1222 | checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" 1223 | 1224 | [[package]] 1225 | name = "syn" 1226 | version = "1.0.109" 1227 | source = "registry+https://github.com/rust-lang/crates.io-index" 1228 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 1229 | dependencies = [ 1230 | "proc-macro2", 1231 | "quote", 1232 | "unicode-ident", 1233 | ] 1234 | 1235 | [[package]] 1236 | name = "syn" 1237 | version = "2.0.41" 1238 | source = "registry+https://github.com/rust-lang/crates.io-index" 1239 | checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" 1240 | dependencies = [ 1241 | "proc-macro2", 1242 | "quote", 1243 | "unicode-ident", 1244 | ] 1245 | 1246 | [[package]] 1247 | name = "tap" 1248 | version = "1.0.1" 1249 | source = "registry+https://github.com/rust-lang/crates.io-index" 1250 | checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" 1251 | 1252 | [[package]] 1253 | name = "tempfile" 1254 | version = "3.9.0" 1255 | source = "registry+https://github.com/rust-lang/crates.io-index" 1256 | checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" 1257 | dependencies = [ 1258 | "cfg-if", 1259 | "fastrand", 1260 | "redox_syscall", 1261 | "rustix", 1262 | "windows-sys 0.52.0", 1263 | ] 1264 | 1265 | [[package]] 1266 | name = "thread_local" 1267 | version = "1.1.8" 1268 | source = "registry+https://github.com/rust-lang/crates.io-index" 1269 | checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" 1270 | dependencies = [ 1271 | "cfg-if", 1272 | "once_cell", 1273 | ] 1274 | 1275 | [[package]] 1276 | name = "time" 1277 | version = "0.3.34" 1278 | source = "registry+https://github.com/rust-lang/crates.io-index" 1279 | checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" 1280 | dependencies = [ 1281 | "deranged", 1282 | "itoa", 1283 | "num-conv", 1284 | "powerfmt", 1285 | "serde", 1286 | "time-core", 1287 | "time-macros", 1288 | ] 1289 | 1290 | [[package]] 1291 | name = "time-core" 1292 | version = "0.1.2" 1293 | source = "registry+https://github.com/rust-lang/crates.io-index" 1294 | checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" 1295 | 1296 | [[package]] 1297 | name = "time-macros" 1298 | version = "0.2.17" 1299 | source = "registry+https://github.com/rust-lang/crates.io-index" 1300 | checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" 1301 | dependencies = [ 1302 | "num-conv", 1303 | "time-core", 1304 | ] 1305 | 1306 | [[package]] 1307 | name = "tokio" 1308 | version = "1.36.0" 1309 | source = "registry+https://github.com/rust-lang/crates.io-index" 1310 | checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" 1311 | dependencies = [ 1312 | "backtrace", 1313 | "bytes", 1314 | "libc", 1315 | "mio", 1316 | "num_cpus", 1317 | "pin-project-lite", 1318 | "signal-hook-registry", 1319 | "socket2", 1320 | "tokio-macros", 1321 | "windows-sys 0.48.0", 1322 | ] 1323 | 1324 | [[package]] 1325 | name = "tokio-macros" 1326 | version = "2.2.0" 1327 | source = "registry+https://github.com/rust-lang/crates.io-index" 1328 | checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" 1329 | dependencies = [ 1330 | "proc-macro2", 1331 | "quote", 1332 | "syn 2.0.41", 1333 | ] 1334 | 1335 | [[package]] 1336 | name = "tokio-stream" 1337 | version = "0.1.14" 1338 | source = "registry+https://github.com/rust-lang/crates.io-index" 1339 | checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" 1340 | dependencies = [ 1341 | "futures-core", 1342 | "pin-project-lite", 1343 | "tokio", 1344 | ] 1345 | 1346 | [[package]] 1347 | name = "tokio-util" 1348 | version = "0.7.10" 1349 | source = "registry+https://github.com/rust-lang/crates.io-index" 1350 | checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" 1351 | dependencies = [ 1352 | "bytes", 1353 | "futures-core", 1354 | "futures-sink", 1355 | "pin-project-lite", 1356 | "tokio", 1357 | "tracing", 1358 | ] 1359 | 1360 | [[package]] 1361 | name = "toml" 1362 | version = "0.8.10" 1363 | source = "registry+https://github.com/rust-lang/crates.io-index" 1364 | checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" 1365 | dependencies = [ 1366 | "serde", 1367 | "serde_spanned", 1368 | "toml_datetime", 1369 | "toml_edit 0.22.6", 1370 | ] 1371 | 1372 | [[package]] 1373 | name = "toml_datetime" 1374 | version = "0.6.5" 1375 | source = "registry+https://github.com/rust-lang/crates.io-index" 1376 | checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" 1377 | dependencies = [ 1378 | "serde", 1379 | ] 1380 | 1381 | [[package]] 1382 | name = "toml_edit" 1383 | version = "0.20.2" 1384 | source = "registry+https://github.com/rust-lang/crates.io-index" 1385 | checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" 1386 | dependencies = [ 1387 | "indexmap", 1388 | "toml_datetime", 1389 | "winnow 0.5.30", 1390 | ] 1391 | 1392 | [[package]] 1393 | name = "toml_edit" 1394 | version = "0.22.6" 1395 | source = "registry+https://github.com/rust-lang/crates.io-index" 1396 | checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" 1397 | dependencies = [ 1398 | "indexmap", 1399 | "serde", 1400 | "serde_spanned", 1401 | "toml_datetime", 1402 | "winnow 0.6.2", 1403 | ] 1404 | 1405 | [[package]] 1406 | name = "tower-service" 1407 | version = "0.3.2" 1408 | source = "registry+https://github.com/rust-lang/crates.io-index" 1409 | checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" 1410 | 1411 | [[package]] 1412 | name = "tracing" 1413 | version = "0.1.40" 1414 | source = "registry+https://github.com/rust-lang/crates.io-index" 1415 | checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" 1416 | dependencies = [ 1417 | "pin-project-lite", 1418 | "tracing-attributes", 1419 | "tracing-core", 1420 | ] 1421 | 1422 | [[package]] 1423 | name = "tracing-attributes" 1424 | version = "0.1.27" 1425 | source = "registry+https://github.com/rust-lang/crates.io-index" 1426 | checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" 1427 | dependencies = [ 1428 | "proc-macro2", 1429 | "quote", 1430 | "syn 2.0.41", 1431 | ] 1432 | 1433 | [[package]] 1434 | name = "tracing-core" 1435 | version = "0.1.32" 1436 | source = "registry+https://github.com/rust-lang/crates.io-index" 1437 | checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" 1438 | dependencies = [ 1439 | "once_cell", 1440 | "valuable", 1441 | ] 1442 | 1443 | [[package]] 1444 | name = "tracing-log" 1445 | version = "0.2.0" 1446 | source = "registry+https://github.com/rust-lang/crates.io-index" 1447 | checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" 1448 | dependencies = [ 1449 | "log", 1450 | "once_cell", 1451 | "tracing-core", 1452 | ] 1453 | 1454 | [[package]] 1455 | name = "tracing-subscriber" 1456 | version = "0.3.18" 1457 | source = "registry+https://github.com/rust-lang/crates.io-index" 1458 | checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" 1459 | dependencies = [ 1460 | "matchers", 1461 | "nu-ansi-term", 1462 | "once_cell", 1463 | "regex", 1464 | "sharded-slab", 1465 | "smallvec", 1466 | "thread_local", 1467 | "tracing", 1468 | "tracing-core", 1469 | "tracing-log", 1470 | ] 1471 | 1472 | [[package]] 1473 | name = "try-lock" 1474 | version = "0.2.5" 1475 | source = "registry+https://github.com/rust-lang/crates.io-index" 1476 | checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" 1477 | 1478 | [[package]] 1479 | name = "ubyte" 1480 | version = "0.10.4" 1481 | source = "registry+https://github.com/rust-lang/crates.io-index" 1482 | checksum = "f720def6ce1ee2fc44d40ac9ed6d3a59c361c80a75a7aa8e75bb9baed31cf2ea" 1483 | dependencies = [ 1484 | "serde", 1485 | ] 1486 | 1487 | [[package]] 1488 | name = "uint" 1489 | version = "0.9.5" 1490 | source = "registry+https://github.com/rust-lang/crates.io-index" 1491 | checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" 1492 | dependencies = [ 1493 | "byteorder", 1494 | "crunchy", 1495 | "hex", 1496 | "static_assertions", 1497 | ] 1498 | 1499 | [[package]] 1500 | name = "uncased" 1501 | version = "0.9.10" 1502 | source = "registry+https://github.com/rust-lang/crates.io-index" 1503 | checksum = "e1b88fcfe09e89d3866a5c11019378088af2d24c3fbd4f0543f96b479ec90697" 1504 | dependencies = [ 1505 | "serde", 1506 | "version_check", 1507 | ] 1508 | 1509 | [[package]] 1510 | name = "unicode-ident" 1511 | version = "1.0.12" 1512 | source = "registry+https://github.com/rust-lang/crates.io-index" 1513 | checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" 1514 | 1515 | [[package]] 1516 | name = "unicode-xid" 1517 | version = "0.2.4" 1518 | source = "registry+https://github.com/rust-lang/crates.io-index" 1519 | checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" 1520 | 1521 | [[package]] 1522 | name = "valuable" 1523 | version = "0.1.0" 1524 | source = "registry+https://github.com/rust-lang/crates.io-index" 1525 | checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" 1526 | 1527 | [[package]] 1528 | name = "version_check" 1529 | version = "0.9.4" 1530 | source = "registry+https://github.com/rust-lang/crates.io-index" 1531 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 1532 | 1533 | [[package]] 1534 | name = "want" 1535 | version = "0.3.1" 1536 | source = "registry+https://github.com/rust-lang/crates.io-index" 1537 | checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" 1538 | dependencies = [ 1539 | "try-lock", 1540 | ] 1541 | 1542 | [[package]] 1543 | name = "wasi" 1544 | version = "0.11.0+wasi-snapshot-preview1" 1545 | source = "registry+https://github.com/rust-lang/crates.io-index" 1546 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1547 | 1548 | [[package]] 1549 | name = "winapi" 1550 | version = "0.3.9" 1551 | source = "registry+https://github.com/rust-lang/crates.io-index" 1552 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1553 | dependencies = [ 1554 | "winapi-i686-pc-windows-gnu", 1555 | "winapi-x86_64-pc-windows-gnu", 1556 | ] 1557 | 1558 | [[package]] 1559 | name = "winapi-i686-pc-windows-gnu" 1560 | version = "0.4.0" 1561 | source = "registry+https://github.com/rust-lang/crates.io-index" 1562 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1563 | 1564 | [[package]] 1565 | name = "winapi-x86_64-pc-windows-gnu" 1566 | version = "0.4.0" 1567 | source = "registry+https://github.com/rust-lang/crates.io-index" 1568 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1569 | 1570 | [[package]] 1571 | name = "windows" 1572 | version = "0.48.0" 1573 | source = "registry+https://github.com/rust-lang/crates.io-index" 1574 | checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" 1575 | dependencies = [ 1576 | "windows-targets 0.48.5", 1577 | ] 1578 | 1579 | [[package]] 1580 | name = "windows-sys" 1581 | version = "0.48.0" 1582 | source = "registry+https://github.com/rust-lang/crates.io-index" 1583 | checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 1584 | dependencies = [ 1585 | "windows-targets 0.48.5", 1586 | ] 1587 | 1588 | [[package]] 1589 | name = "windows-sys" 1590 | version = "0.52.0" 1591 | source = "registry+https://github.com/rust-lang/crates.io-index" 1592 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 1593 | dependencies = [ 1594 | "windows-targets 0.52.3", 1595 | ] 1596 | 1597 | [[package]] 1598 | name = "windows-targets" 1599 | version = "0.48.5" 1600 | source = "registry+https://github.com/rust-lang/crates.io-index" 1601 | checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" 1602 | dependencies = [ 1603 | "windows_aarch64_gnullvm 0.48.5", 1604 | "windows_aarch64_msvc 0.48.5", 1605 | "windows_i686_gnu 0.48.5", 1606 | "windows_i686_msvc 0.48.5", 1607 | "windows_x86_64_gnu 0.48.5", 1608 | "windows_x86_64_gnullvm 0.48.5", 1609 | "windows_x86_64_msvc 0.48.5", 1610 | ] 1611 | 1612 | [[package]] 1613 | name = "windows-targets" 1614 | version = "0.52.3" 1615 | source = "registry+https://github.com/rust-lang/crates.io-index" 1616 | checksum = "d380ba1dc7187569a8a9e91ed34b8ccfc33123bbacb8c0aed2d1ad7f3ef2dc5f" 1617 | dependencies = [ 1618 | "windows_aarch64_gnullvm 0.52.3", 1619 | "windows_aarch64_msvc 0.52.3", 1620 | "windows_i686_gnu 0.52.3", 1621 | "windows_i686_msvc 0.52.3", 1622 | "windows_x86_64_gnu 0.52.3", 1623 | "windows_x86_64_gnullvm 0.52.3", 1624 | "windows_x86_64_msvc 0.52.3", 1625 | ] 1626 | 1627 | [[package]] 1628 | name = "windows_aarch64_gnullvm" 1629 | version = "0.48.5" 1630 | source = "registry+https://github.com/rust-lang/crates.io-index" 1631 | checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" 1632 | 1633 | [[package]] 1634 | name = "windows_aarch64_gnullvm" 1635 | version = "0.52.3" 1636 | source = "registry+https://github.com/rust-lang/crates.io-index" 1637 | checksum = "68e5dcfb9413f53afd9c8f86e56a7b4d86d9a2fa26090ea2dc9e40fba56c6ec6" 1638 | 1639 | [[package]] 1640 | name = "windows_aarch64_msvc" 1641 | version = "0.48.5" 1642 | source = "registry+https://github.com/rust-lang/crates.io-index" 1643 | checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" 1644 | 1645 | [[package]] 1646 | name = "windows_aarch64_msvc" 1647 | version = "0.52.3" 1648 | source = "registry+https://github.com/rust-lang/crates.io-index" 1649 | checksum = "8dab469ebbc45798319e69eebf92308e541ce46760b49b18c6b3fe5e8965b30f" 1650 | 1651 | [[package]] 1652 | name = "windows_i686_gnu" 1653 | version = "0.48.5" 1654 | source = "registry+https://github.com/rust-lang/crates.io-index" 1655 | checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" 1656 | 1657 | [[package]] 1658 | name = "windows_i686_gnu" 1659 | version = "0.52.3" 1660 | source = "registry+https://github.com/rust-lang/crates.io-index" 1661 | checksum = "2a4e9b6a7cac734a8b4138a4e1044eac3404d8326b6c0f939276560687a033fb" 1662 | 1663 | [[package]] 1664 | name = "windows_i686_msvc" 1665 | version = "0.48.5" 1666 | source = "registry+https://github.com/rust-lang/crates.io-index" 1667 | checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" 1668 | 1669 | [[package]] 1670 | name = "windows_i686_msvc" 1671 | version = "0.52.3" 1672 | source = "registry+https://github.com/rust-lang/crates.io-index" 1673 | checksum = "28b0ec9c422ca95ff34a78755cfa6ad4a51371da2a5ace67500cf7ca5f232c58" 1674 | 1675 | [[package]] 1676 | name = "windows_x86_64_gnu" 1677 | version = "0.48.5" 1678 | source = "registry+https://github.com/rust-lang/crates.io-index" 1679 | checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" 1680 | 1681 | [[package]] 1682 | name = "windows_x86_64_gnu" 1683 | version = "0.52.3" 1684 | source = "registry+https://github.com/rust-lang/crates.io-index" 1685 | checksum = "704131571ba93e89d7cd43482277d6632589b18ecf4468f591fbae0a8b101614" 1686 | 1687 | [[package]] 1688 | name = "windows_x86_64_gnullvm" 1689 | version = "0.48.5" 1690 | source = "registry+https://github.com/rust-lang/crates.io-index" 1691 | checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" 1692 | 1693 | [[package]] 1694 | name = "windows_x86_64_gnullvm" 1695 | version = "0.52.3" 1696 | source = "registry+https://github.com/rust-lang/crates.io-index" 1697 | checksum = "42079295511643151e98d61c38c0acc444e52dd42ab456f7ccfd5152e8ecf21c" 1698 | 1699 | [[package]] 1700 | name = "windows_x86_64_msvc" 1701 | version = "0.48.5" 1702 | source = "registry+https://github.com/rust-lang/crates.io-index" 1703 | checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" 1704 | 1705 | [[package]] 1706 | name = "windows_x86_64_msvc" 1707 | version = "0.52.3" 1708 | source = "registry+https://github.com/rust-lang/crates.io-index" 1709 | checksum = "0770833d60a970638e989b3fa9fd2bb1aaadcf88963d1659fd7d9990196ed2d6" 1710 | 1711 | [[package]] 1712 | name = "winnow" 1713 | version = "0.5.30" 1714 | source = "registry+https://github.com/rust-lang/crates.io-index" 1715 | checksum = "9b5c3db89721d50d0e2a673f5043fc4722f76dcc352d7b1ab8b8288bed4ed2c5" 1716 | dependencies = [ 1717 | "memchr", 1718 | ] 1719 | 1720 | [[package]] 1721 | name = "winnow" 1722 | version = "0.6.2" 1723 | source = "registry+https://github.com/rust-lang/crates.io-index" 1724 | checksum = "7a4191c47f15cc3ec71fcb4913cb83d58def65dd3787610213c649283b5ce178" 1725 | dependencies = [ 1726 | "memchr", 1727 | ] 1728 | 1729 | [[package]] 1730 | name = "wyz" 1731 | version = "0.5.1" 1732 | source = "registry+https://github.com/rust-lang/crates.io-index" 1733 | checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" 1734 | dependencies = [ 1735 | "tap", 1736 | ] 1737 | 1738 | [[package]] 1739 | name = "yansi" 1740 | version = "1.0.0-rc.1" 1741 | source = "registry+https://github.com/rust-lang/crates.io-index" 1742 | checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" 1743 | dependencies = [ 1744 | "is-terminal", 1745 | ] 1746 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust-pocs" 3 | version = "1.0.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | primitive-types = "0.11.1" 8 | rocket = "0.5.0" 9 | 10 | [profile.release] 11 | # overflow-checks = true 12 | # panic = "abort" 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rust-security-workshop 2 | -------------------------------------------------------------------------------- /Rust-Security.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Guvenkaya/rust-security-workshop/df1ca9c0040bb6307843d8474748f8a968f08098/Rust-Security.pdf -------------------------------------------------------------------------------- /src/bin/catch-unwind.rs: -------------------------------------------------------------------------------- 1 | fn divide_by_zero(a: u8, b: u8) -> u8 { 2 | a / b 3 | } 4 | 5 | fn main() { 6 | let result = std::panic::catch_unwind(|| { 7 | let _ = divide_by_zero(100, 0); 8 | }); 9 | 10 | match result { 11 | Ok(_) => println!("No panic occurred"), 12 | Err(_) => println!("Panic occurred"), 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/bin/ctf.rs: -------------------------------------------------------------------------------- 1 | use primitive_types::U256; 2 | 3 | #[macro_use] 4 | extern crate rocket; 5 | 6 | struct User { 7 | name: String, 8 | balance: u128, 9 | } 10 | 11 | struct Item { 12 | name: String, 13 | price: u128, 14 | } 15 | 16 | impl Default for User { 17 | fn default() -> Self { 18 | Self { 19 | name: String::from("Jake"), 20 | balance: 321, 21 | } 22 | } 23 | } 24 | 25 | impl Default for Item { 26 | fn default() -> Self { 27 | Self { 28 | name: String::from("Bored Ape"), 29 | price: 23, 30 | } 31 | } 32 | } 33 | 34 | fn fibonacci_calc(n: u128) -> u128 { 35 | match n { 36 | 1 | 2 => 1, 37 | 3 => 2, 38 | _ => fibonacci_calc(n - 1) + fibonacci_calc(n - 2), 39 | } 40 | } 41 | 42 | fn cast(num1: u128, num2: u128) -> u128 { 43 | let result = U256::from(num1).pow(U256::from(num2)); 44 | 45 | result.as_u128() 46 | } 47 | 48 | // Try to spot issues without running the code first. 49 | #[get("/fibonacci?")] 50 | fn fibonacci(num: Option) -> String { 51 | match num { 52 | Some(0) => String::from("Please enter a number bigger than 0"), 53 | Some(n) => { 54 | let res = fibonacci_calc(n); 55 | 56 | format!("Number {} is {}", n, res.to_string()) 57 | } 58 | None => String::from("Please enter a number"), 59 | } 60 | } 61 | 62 | // Try to spot issues without running the code first. 63 | #[get("/power?&")] 64 | fn power(num: Option, num2: Option) -> String { 65 | if num.is_some() && num2.is_some() { 66 | let res = cast(num.unwrap(), num2.unwrap()); 67 | 68 | format!( 69 | "Result of the {} to power {} is {}", 70 | num.unwrap(), 71 | num2.unwrap(), 72 | res.to_string() 73 | ) 74 | } else { 75 | String::from("Please enter all numbers") 76 | } 77 | } 78 | 79 | // Try to spot issues without running the code first. 80 | #[get("/strings?&")] 81 | fn split(str: Option, element: Option) -> String { 82 | if str.is_some() { 83 | let str = str.unwrap(); 84 | let element = element.unwrap(); 85 | 86 | if str.len() < element { 87 | return String::from("Index is too high"); 88 | } 89 | 90 | let slice = &str[..element]; 91 | 92 | format!("The {} element of {} is {}", element, str, slice) 93 | } else { 94 | String::from("Please enter a string & element") 95 | } 96 | } 97 | 98 | // Try to spot issues without running the code first. 99 | #[get("/auction?")] 100 | fn auction(bid: Option) -> String { 101 | let mut user = User::default(); //every time you call this route, user resets 102 | let item = Item::default(); 103 | 104 | match bid { 105 | Some(0) => String::from("Please enter a number larger than 0"), 106 | Some(n) => { 107 | if n <= user.balance && n >= item.price { 108 | let new_balance = user.balance - (n as u8) as u128; 109 | 110 | user.balance = new_balance; 111 | 112 | format!( 113 | "You have purchased {} for {}. Your remaining balance is: {}", 114 | item.name, n, user.balance 115 | ) 116 | } else { 117 | format!( 118 | "{}, not enough balance. Current Balance: {}. {} price: {}", 119 | &user.name, &user.balance, &item.name, &item.price 120 | ) 121 | } 122 | } 123 | None => String::from("Please enter a number"), 124 | } 125 | } 126 | 127 | #[get("/")] 128 | fn greet() -> &'static str { 129 | "Can you spot all vulns?" 130 | } 131 | 132 | #[launch] 133 | fn rocket() -> _ { 134 | rocket::build().mount("/", routes![greet, power, auction, split, fibonacci]) 135 | } 136 | -------------------------------------------------------------------------------- /src/bin/default-values.rs: -------------------------------------------------------------------------------- 1 | use std::io::Error; 2 | 3 | #[derive(Debug)] 4 | struct User { 5 | name: String, 6 | age: u8, 7 | } 8 | 9 | impl Default for User { 10 | fn default() -> Self { 11 | Self { 12 | name: String::from("Jake"), 13 | age: 34, 14 | } 15 | } 16 | } 17 | 18 | fn main() { 19 | let a: Option = Some(2); 20 | let b: Option = None; 21 | let c: Option> = Some(None); 22 | let d: Option> = None; 23 | let e: Result = Ok(2); 24 | let f: Result = Err(Error::from_raw_os_error(2)); 25 | let g: Result, Error> = Ok(Some(2)); 26 | let h: Result, Error> = Ok(None); 27 | let i: Option = Some(User { 28 | name: String::from("Jane"), 29 | age: 22, 30 | }); 31 | let j: Option = None; 32 | let k: Result = Ok(User { 33 | name: String::from("Jane"), 34 | age: 22, 35 | }); 36 | let l: Result = Err(Error::from_raw_os_error(2)); 37 | 38 | println!("a: {:?}", a.unwrap_or_default()); 39 | println!("b: {:?}", b.unwrap_or_default()); 40 | println!("c: {:?}", c.unwrap_or_default()); 41 | println!("d: {:?}", d.unwrap_or_default()); 42 | println!("e: {:?}", e.unwrap_or_default()); 43 | println!("f: {:?}", f.unwrap_or_default()); 44 | println!("g: {:?}", g.unwrap_or_default()); 45 | println!("h: {:?}", h.unwrap_or_default()); 46 | println!("i: {:?}", i.unwrap_or_default()); 47 | println!("j: {:?}", j.unwrap_or_default()); 48 | println!("k: {:?}", k.unwrap_or_default()); 49 | println!("l: {:?}", l.unwrap_or_default()); 50 | } 51 | -------------------------------------------------------------------------------- /src/bin/divide-before-multiply.rs: -------------------------------------------------------------------------------- 1 | const PER_DAY: u128 = 100; 2 | 3 | const FEE: u128 = 13; 4 | 5 | pub fn get_rewards_right(amount: u128, start_date: u128, end_date: u128) -> u128 { 6 | (amount * PER_DAY * FEE) / (end_date - start_date) 7 | } 8 | 9 | pub fn get_rewards_wrong(amount: u128, start_date: u128, end_date: u128) -> u128 { 10 | (amount / (end_date - start_date)) * PER_DAY * FEE 11 | } 12 | 13 | pub fn get_rewards_wrong_float(amount: f64, start_date: f64, end_date: f64) -> f64 { 14 | (amount / (end_date - start_date)) * (PER_DAY as f64) * (FEE as f64) 15 | } 16 | 17 | pub fn get_rewards_wrong_float_convert(amount: f64, start_date: f64, end_date: f64) -> u128 { 18 | ((amount / (end_date - start_date)) * (PER_DAY as f64) * (FEE as f64)) as u128 19 | } 20 | 21 | fn main() { 22 | // 30 * 100 * 13 = 39000 23 | // 39000 / 13 = 3000 24 | let my_rewards_correct = get_rewards_right(30, 12, 25); 25 | 26 | // 30 / 13 => ~2.3076 is floored to 2 27 | // 2 * 100 * 13 = 2600 28 | let my_rewards_wrong = get_rewards_wrong(30, 12, 25); 29 | 30 | //(30.0/13.0) *100.0*13.0 = 2999.9999999999995 31 | let my_rewards_wrong_float = get_rewards_wrong_float(30.0, 12.0, 25.0); 32 | 33 | //(30.0/13.0) *100.0*13.0 = 2999.9999999999995 => 2999 34 | let my_rewards_wrong_float_convert = get_rewards_wrong_float_convert(30.0, 12.0, 25.0); 35 | 36 | println!("Correct: {my_rewards_correct}"); 37 | println!("Wrong: {my_rewards_wrong}"); 38 | println!("Wrong Float: {my_rewards_wrong_float}"); 39 | println!("Wrong Float Convert: {my_rewards_wrong_float_convert}") 40 | } -------------------------------------------------------------------------------- /src/bin/division-by-zero.rs: -------------------------------------------------------------------------------- 1 | fn divide_by_zero(a: u8, b: u8) -> u8 { 2 | a / b 3 | } 4 | 5 | fn main() { 6 | println!("{}", divide_by_zero(20, 0)) 7 | } 8 | -------------------------------------------------------------------------------- /src/bin/index-out-of-bounds.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let vec = vec![1, 2, 3, 4, 5, 6, 7, 8, 9]; 3 | 4 | // Last element 5 | println!("{}", vec[vec.len() - 1]); 6 | 7 | //Index out of bounds 8 | //println!("{}", vec[vec.len()]); 9 | 10 | // .get() method 11 | let val = vec.get(vec.len()); 12 | 13 | match val { 14 | Some(val) => println!("{val}"), 15 | None => println!("Index out of bounds. Please try again."), 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/bin/oom.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut size: usize = 1024; // Start with 1KB 3 | while let Some(double_size) = size.checked_mul(2) { 4 | let _ = Vec::::with_capacity(double_size); 5 | 6 | println!("Successfully allocated {} bytes", size); 7 | 8 | size = double_size; // Double the allocation size on each iteration 9 | } 10 | 11 | println!("Failed to allocate memory or reached maximum allocation size."); 12 | } 13 | -------------------------------------------------------------------------------- /src/bin/overflow-prevention.rs: -------------------------------------------------------------------------------- 1 | use std::process; 2 | 3 | fn underflow_checked(a: u8, b: u8) -> Option { 4 | a.checked_sub(b) 5 | } 6 | 7 | fn overflow_saturating(a: u8, b: u8) -> u8 { 8 | a.saturating_add(b) 9 | } 10 | 11 | fn main() { 12 | // Checked maths used. If None returned -> Underflow 13 | let val = underflow_checked(5, 6); 14 | 15 | // Saturating maths used. In case of addition/multiplication 16 | // -> u8::MAX is returned 17 | let val2 = overflow_saturating(250, 10); 18 | 19 | println!("{val2}"); 20 | 21 | //Handling None case of checked maths without panicking. 22 | if val.is_none() { 23 | print!("Underflow occurred. Please try again"); 24 | process::exit(1); 25 | } 26 | // We already handled underflow case -> unwrap is safe 27 | println!("{}", val.unwrap()) 28 | } 29 | -------------------------------------------------------------------------------- /src/bin/panicking-casting.rs: -------------------------------------------------------------------------------- 1 | use primitive_types::U256; 2 | 3 | fn main() { 4 | // Using custom U256 type from primitive-types library 5 | let a = U256::MAX; 6 | 7 | // Panics on casting overflow 8 | println!("{}", a.as_u128()); 9 | } 10 | -------------------------------------------------------------------------------- /src/bin/panicking-macros.rs: -------------------------------------------------------------------------------- 1 | use std::io::stdin; 2 | 3 | // No num || Not integer -> Panic unwrap 4 | // Odd Number -> Panic on panic! 5 | // Num > 10000 -> Panic on unimplemented! 6 | // Num != secret_num -> Panic on assert! 7 | 8 | fn main() { 9 | println!("Enter any number"); 10 | 11 | let secret_number = 28; 12 | 13 | let mut number = String::new(); 14 | stdin().read_line(&mut number).expect("Failed to read input"); 15 | 16 | let number = number.split_whitespace().collect::().parse::().unwrap(); 17 | 18 | if number % 2 != 0 { 19 | panic!("Only even numbers are accepted"); 20 | } 21 | 22 | if number > 10000 { 23 | unimplemented!(); 24 | } 25 | 26 | assert!(number == secret_number, "You picked wrong number"); 27 | 28 | println!("Entered number is {number}"); 29 | } -------------------------------------------------------------------------------- /src/bin/recoverable-errors-manual.rs: -------------------------------------------------------------------------------- 1 | use std::fs::File; 2 | use std::path::Path; 3 | use std::process; 4 | 5 | fn main() { 6 | let name = "test.txt"; 7 | 8 | let path = Path::new(name); 9 | let display = path.display(); 10 | 11 | //File::open returns Result 12 | 13 | let file = match File::open(path) { 14 | Ok(file) => file, 15 | Err(e) => { 16 | println!("File: {display} cannot be opened. Error: {e}"); 17 | process::exit(1); 18 | } 19 | }; 20 | 21 | println!("{:?}", file.metadata()); 22 | } -------------------------------------------------------------------------------- /src/bin/recoverable-errors-question.rs: -------------------------------------------------------------------------------- 1 | use std::fs::File; 2 | use std::io::Error; 3 | use std::path::Path; 4 | 5 | //Main function now returns either Okay or throws an error. 6 | fn main() -> Result<(), Error> { 7 | let name = "test.txt"; 8 | 9 | let path = Path::new(name); 10 | 11 | //File::open returns Result, 12 | //so we can utilize ? to propagate the error 13 | let file = File::open(path)?; 14 | 15 | println!("{:?}", file.metadata()); 16 | 17 | // We have to return Okay variant 18 | Ok(()) 19 | } 20 | -------------------------------------------------------------------------------- /src/bin/round.rs: -------------------------------------------------------------------------------- 1 | const FEE: f32 = 0.075; 2 | const PER_DAY: u16 = 2; 3 | pub fn get_rewards(days: u16) -> f32 { 4 | (days * PER_DAY) as f32 * FEE 5 | } 6 | 7 | fn main() { 8 | // 1.5 rounded to 2 9 | let my_rewards_round = get_rewards(10).round(); 10 | 11 | // 1.5 rounded to 2 12 | let my_rewards_ceil = get_rewards(10).ceil(); 13 | 14 | // 1.5 rounded to 1 15 | let my_rewards_floor = get_rewards(10).floor(); 16 | 17 | println!("Rewards rounded {my_rewards_round}"); 18 | println!("Rewards ceiled {my_rewards_ceil}"); 19 | println!("Rewards floored {my_rewards_floor}") 20 | } 21 | -------------------------------------------------------------------------------- /src/bin/set-hook.rs: -------------------------------------------------------------------------------- 1 | fn divide_by_zero(a: u8, b: u8) -> u8 { 2 | a / b 3 | } 4 | 5 | fn main() { 6 | std::panic::set_hook(Box::new(|_| { 7 | println!("Some error"); 8 | })); 9 | 10 | let _ = std::panic::catch_unwind(|| { 11 | let _ = divide_by_zero(100, 0); 12 | }); 13 | 14 | let _ = std::panic::take_hook(); 15 | 16 | panic!("This is a panic"); 17 | } 18 | -------------------------------------------------------------------------------- /src/bin/silent-casting.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let a: u16 = 300; 3 | 4 | // Returns 44 while silently overflowing. 5 | println!("{}", a as u8) 6 | } 7 | -------------------------------------------------------------------------------- /src/bin/stack-overflow.rs: -------------------------------------------------------------------------------- 1 | fn factorial_calc(num: u128) -> u128 { 2 | if num > 0 { 3 | if num <= 1 { 4 | return 1; 5 | } 6 | num.saturating_mul(factorial_calc(num - 1)) 7 | } else { 8 | 0 9 | } 10 | } 11 | 12 | fn main() { 13 | println!("{}", factorial_calc(100000)) 14 | } -------------------------------------------------------------------------------- /src/bin/underflow.rs: -------------------------------------------------------------------------------- 1 | use std::io::stdin; 2 | 3 | fn underflow(a: u8, b: u8) -> u8 { 4 | a - b 5 | } 6 | 7 | fn main() { 8 | println!("Enter any number"); 9 | 10 | let mut number = String::new(); 11 | stdin() 12 | .read_line(&mut number) 13 | .expect("Failed to read input"); 14 | 15 | let number = number 16 | .split_whitespace() 17 | .collect::() 18 | .parse::() 19 | .unwrap(); 20 | 21 | let result = underflow(number, 6); 22 | 23 | println!("{result}") 24 | } 25 | -------------------------------------------------------------------------------- /src/bin/unwrap-expect.rs: -------------------------------------------------------------------------------- 1 | use std::fs::File; 2 | use std::path::Path; 3 | 4 | fn main() { 5 | let name = "test.txt"; 6 | 7 | let path = Path::new(name); 8 | 9 | //File::open returns Result, 10 | //Upon unwrap(), if there is an error 11 | //-> thread will panic 12 | //let file = File::open(path).unwrap(); 13 | 14 | //File::open returns Result, 15 | //Upon expect(), if there is an error 16 | //-> thread will panic with custom message 17 | let file2 = File::open(path).expect("Error opening file"); 18 | 19 | println!("{:?}", file2.metadata()); 20 | } 21 | --------------------------------------------------------------------------------