Skip to content

Commit

Permalink
Fix: various clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Kraemii authored Sep 1, 2023
1 parent bbab9cf commit 4b332b4
Show file tree
Hide file tree
Showing 19 changed files with 224 additions and 218 deletions.
1 change: 1 addition & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

[workspace]
resolver = "2"
members = [
"nasl-builtin-knowledge-base",
"nasl-builtin-raw-ip",
Expand Down
10 changes: 5 additions & 5 deletions rust/feed-verifier/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ fn get(con: &mut redis::Connection) -> RedisResult<HashMap<String, Vec<String>>>
fn normalize_values(v: &str) -> String {
let mut v = v.to_owned();

v = v.replace(r#"\n"#, "\n");
v = v.replace(r#"\\"#, "\\");
v = v.replace(r"\n", "\n");
v = v.replace(r"\\", "\\");
v = v.replace(r#"\""#, "\"");
v = v.replace(r#"\'"#, "'");
v = v.replace(r#"\r"#, "\r");
v = v.replace(r#"\t"#, "\t");
v = v.replace(r"\'", "'");
v = v.replace(r"\r", "\r");
v = v.replace(r"\t", "\t");
v = v.replace('\\', "");
v
}
Expand Down
16 changes: 8 additions & 8 deletions rust/nasl-builtin-cryptographic/tests/aes_cbc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ mod tests {

#[test]
fn aes128_cbc_crypt() {
let code = r###"
let code = r#"
key = hexstr_to_data("00000000000000000000000000000000");
data = hexstr_to_data("80000000000000000000000000000000");
iv = hexstr_to_data("00000000000000000000000000000000");
crypt = aes128_cbc_encrypt(key: key, data: data, iv: iv);
aes128_cbc_decrypt(key: key, data: crypt, iv: iv);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand All @@ -43,13 +43,13 @@ mod tests {

#[test]
fn aes192_cbc_crypt() {
let code = r###"
let code = r#"
key = hexstr_to_data("000000000000000000000000000000000000000000000000");
data = hexstr_to_data("1b077a6af4b7f98229de786d7516b639");
iv = hexstr_to_data("00000000000000000000000000000000");
crypt = aes192_cbc_encrypt(key: key, data: data, iv: iv);
aes192_cbc_decrypt(key: key, data: crypt, iv: iv);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand All @@ -75,13 +75,13 @@ mod tests {

#[test]
fn aes256_cbc_crypt() {
let code = r###"
let code = r#"
key = hexstr_to_data("0000000000000000000000000000000000000000000000000000000000000000");
data = hexstr_to_data("014730f80ac625fe84f026c60bfd547d");
iv = hexstr_to_data("00000000000000000000000000000000");
crypt = aes256_cbc_encrypt(key: key, data: data, iv: iv);
aes256_cbc_decrypt(key: key, data: crypt, iv: iv);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand All @@ -107,14 +107,14 @@ mod tests {

#[test]
fn padding() {
let code = r###"
let code = r#"
key = hexstr_to_data("00000000000000000000000000000000");
data1 = hexstr_to_data("f34481ec3cc627bacd5dc3fb08f2");
data2 = hexstr_to_data("f34481ec3cc627bacd5dc3fb08f20000");
iv = hexstr_to_data("00000000000000000000000000000000");
aes128_cbc_encrypt(key: key, data: data1, iv: iv);
aes128_cbc_encrypt(key: key, data: data2, iv: iv);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand Down
24 changes: 12 additions & 12 deletions rust/nasl-builtin-cryptographic/tests/aes_ccm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ mod tests {

#[test]
fn aes128_ccm_crypt() {
let code = r###"
let code = r#"
key = hexstr_to_data("d24a3d3dde8c84830280cb87abad0bb3");
data = hexstr_to_data("7c86135ed9c2a515aaae0e9a208133897269220f30870006");
iv = hexstr_to_data("f1100035bb24a8d26004e0e24b");
crypt = aes128_ccm_encrypt(key: key, data: data, iv: iv);
aes128_ccm_decrypt(key: key, data: crypt, iv: iv);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand All @@ -43,14 +43,14 @@ mod tests {

#[test]
fn aes128_ccm_crypt_auth() {
let code = r###"
let code = r#"
key = hexstr_to_data("5a33980e71e7d67fd6cf171454dc96e5");
data = hexstr_to_data("a34dfa24847c365291ce1b54bcf8d9a75d861e5133cc3a74");
iv = hexstr_to_data("33ae68ebb8010c6b3da6b9cb29");
aad = hexstr_to_data("eca622a37570df619e10ebb18bebadb2f2b49c4d2b2ff715873bb672e30fc0ff");
crypt = aes128_ccm_encrypt_auth(key: key, data: data, iv: iv, aad: aad);
aes128_ccm_decrypt_auth(key: key, data: crypt, iv: iv, aad: aad);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand All @@ -77,13 +77,13 @@ mod tests {

#[test]
fn aes192_ccm_crypt() {
let code = r###"
let code = r#"
key = hexstr_to_data("26511fb51fcfa75cb4b44da75a6e5a0eb8d9c8f3b906f886");
data = hexstr_to_data("39f08a2af1d8da6212550639b91fb2573e39a8eb5d801de8");
iv = hexstr_to_data("15b369889699b6de1fa3ee73e5");
crypt = aes192_ccm_encrypt(key: key, data: data, iv: iv);
aes192_ccm_decrypt(key: key, data: crypt, iv: iv);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand All @@ -109,14 +109,14 @@ mod tests {

#[test]
fn aes192_ccm_crypt_auth() {
let code = r###"
let code = r#"
key = hexstr_to_data("50925853a84a33ff392154e4e737efc18dcfc98f4d5235a9");
data = hexstr_to_data("718f061e8b972a3adcf465d66c5b28e8661f080127f6722f");
iv = hexstr_to_data("809343e986f6ff47f54d4cac22");
aad = hexstr_to_data("d70aef3532bdc5293a3ebb11589ac1f801c9f93ea0d656e1d04068facf9f768b");
crypt = aes192_ccm_encrypt_auth(key: key, data: data, iv: iv, aad: aad);
aes192_ccm_decrypt_auth(key: key, data: crypt, iv: iv, aad: aad);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand All @@ -143,13 +143,13 @@ mod tests {

#[test]
fn aes256_ccm_crypt() {
let code = r###"
let code = r#"
key = hexstr_to_data("26511fb51fcfa75cb4b44da75a6e5a0eb8d9c8f3b906f886df3ba3e6da3a1389");
data = hexstr_to_data("30d56ff2a25b83fee791110fcaea48e41db7c7f098a81000");
iv = hexstr_to_data("72a60f345a1978fb40f28a2fa4");
crypt = aes256_ccm_encrypt(key: key, data: data, iv: iv);
aes256_ccm_decrypt(key: key, data: crypt, iv: iv);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand All @@ -175,14 +175,14 @@ mod tests {

#[test]
fn aes256_ccm_crypt_auth() {
let code = r###"
let code = r#"
key = hexstr_to_data("2e6e34070caf1b8820ed39edfa83459abe1c15a1827f1c39f7ac316c4c27910f");
data = hexstr_to_data("771a7baa9cf83aa253349f6475d5e74dba4525307b022ba7");
iv = hexstr_to_data("c49ccef869bb86d21932cb443b");
aad = hexstr_to_data("d37e35d7cdccd9824a1ae4c787819735e4af798a3beb49d4705336d6496853ad");
crypt = aes256_ccm_encrypt_auth(key: key, data: data, iv: iv, aad: aad);
aes256_ccm_decrypt_auth(key: key, data: crypt, iv: iv, aad: aad);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand Down
4 changes: 2 additions & 2 deletions rust/nasl-builtin-cryptographic/tests/aes_cmac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ mod tests {

#[test]
fn aes_mac_cbc() {
let code = r###"
let code = r#"
key = hexstr_to_data("e3ceb929b52a6eec02b99b13bf30721b");
data = hexstr_to_data("d2e8a3e86ae0b9edc7cc3116d929a16f13ee3643");
crypt = aes_mac_cbc(key: key, data: data);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand Down
12 changes: 6 additions & 6 deletions rust/nasl-builtin-cryptographic/tests/aes_ctr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ mod tests {

#[test]
fn aes128_ctr_crypt() {
let code = r###"
let code = r#"
key = hexstr_to_data("2b7e151628aed2a6abf7158809cf4f3c");
data = hexstr_to_data("6bc1bee22e409f96e93d7e117393172a");
iv = hexstr_to_data("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff");
crypt = aes128_ctr_encrypt(key: key, data: data, iv: iv);
aes128_ctr_decrypt(key: key, data: crypt, iv: iv);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand All @@ -44,13 +44,13 @@ mod tests {

#[test]
fn aes192_ctr_crypt() {
let code = r###"
let code = r#"
key = hexstr_to_data("8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b");
data = hexstr_to_data("6bc1bee22e409f96e93d7e117393172a");
iv = hexstr_to_data("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff");
crypt = aes192_ctr_encrypt(key: key, data: data, iv: iv);
aes192_ctr_decrypt(key: key, data: crypt, iv: iv);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand All @@ -76,13 +76,13 @@ mod tests {

#[test]
fn aes256_ctr_crypt() {
let code = r###"
let code = r#"
key = hexstr_to_data("603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4");
data = hexstr_to_data("6bc1bee22e409f96e93d7e117393172a");
iv = hexstr_to_data("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff");
crypt = aes256_ctr_encrypt(key: key, data: data, iv: iv);
aes256_ctr_decrypt(key: key, data: crypt, iv: iv);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand Down
28 changes: 14 additions & 14 deletions rust/nasl-builtin-cryptographic/tests/aes_gcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ mod tests {
use nasl_interpreter::*;
#[test]
fn aes128_gcm_crypt() {
let code = r###"
let code = r#"
key = hexstr_to_data("7fddb57453c241d03efbed3ac44e371c");
data = hexstr_to_data("d5de42b461646c255c87bd2962d3b9a2");
iv = hexstr_to_data("ee283a3fc75575e33efd4887");
crypt = aes128_gcm_encrypt(key: key, data: data, iv: iv);
aes128_gcm_decrypt(key: key, data: crypt, iv: iv);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand All @@ -44,14 +44,14 @@ mod tests {

#[test]
fn aes128_gcm_crypt_auth() {
let code = r###"
let code = r#"
key = hexstr_to_data("c939cc13397c1d37de6ae0e1cb7c423c");
data = hexstr_to_data("c3b3c41f113a31b73d9a5cd432103069");
iv = hexstr_to_data("b3d8cc017cbb89b39e0f67e2");
aad = hexstr_to_data("24825602bd12a984e0092d3e448eda5f");
crypt = aes128_gcm_encrypt_auth(key: key, data: data, iv: iv, aad: aad);
aes128_gcm_decrypt_auth(key: key, data: crypt, iv: iv, aad: aad);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand Down Expand Up @@ -79,13 +79,13 @@ mod tests {

#[test]
fn aes192_gcm_crypt() {
let code = r###"
let code = r#"
key = hexstr_to_data("fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f");
data = hexstr_to_data("d2ae38c4375954835d75b8e4c2f9bbb4");
iv = hexstr_to_data("5f4b43e811da9c470d6a9b01");
crypt = aes192_gcm_encrypt(key: key, data: data, iv: iv);
aes192_gcm_decrypt(key: key, data: crypt, iv: iv);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand All @@ -112,14 +112,14 @@ mod tests {

#[test]
fn aes192_gcm_crypt_auth() {
let code = r###"
let code = r#"
key = hexstr_to_data("6f44f52c2f62dae4e8684bd2bc7d16ee7c557330305a790d");
data = hexstr_to_data("37222d30895eb95884bbbbaee4d9cae1");
iv = hexstr_to_data("9ae35825d7c7edc9a39a0732");
aad = hexstr_to_data("1b4236b846fc2a0f782881ba48a067e9");
crypt = aes192_gcm_encrypt_auth(key: key, data: data, iv: iv, aad: aad);
aes192_gcm_decrypt_auth(key: key, data: crypt, iv: iv, aad: aad);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand Down Expand Up @@ -147,13 +147,13 @@ mod tests {

#[test]
fn aes256_gcm_crypt() {
let code = r###"
let code = r#"
key = hexstr_to_data("31bdadd96698c204aa9ce1448ea94ae1fb4a9a0b3c9d773b51bb1822666b8f22");
data = hexstr_to_data("2db5168e932556f8089a0622981d017d");
iv = hexstr_to_data("0d18e06c7c725ac9e362e1ce");
crypt = aes256_gcm_encrypt(key: key, data: data, iv: iv);
aes256_gcm_decrypt(key: key, data: crypt, iv: iv);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand All @@ -180,14 +180,14 @@ mod tests {

#[test]
fn aes256_gcm_crypt_auth() {
let code = r###"
let code = r#"
key = hexstr_to_data("92e11dcdaa866f5ce790fd24501f92509aacf4cb8b1339d50c9c1240935dd08b");
data = hexstr_to_data("2d71bcfa914e4ac045b2aa60955fad24");
iv = hexstr_to_data("ac93a1a6145299bde902f21a");
aad = hexstr_to_data("1e0889016f67601c8ebea4943bc23ad6");
crypt = aes256_gcm_encrypt_auth(key: key, data: data, iv: iv, aad: aad);
aes256_gcm_decrypt_auth(key: key, data: crypt, iv: iv, aad: aad);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand Down Expand Up @@ -215,14 +215,14 @@ mod tests {

#[test]
fn padding() {
let code = r###"
let code = r#"
key = hexstr_to_data("7fddb57453c241d03efbed3ac44e371c");
data1 = hexstr_to_data("d5de42b461646c255c87bd29");
data2 = hexstr_to_data("d5de42b461646c255c87bd2900000000");
iv = hexstr_to_data("ee283a3fc75575e33efd4887");
aes128_gcm_encrypt(key: key, data: data1, iv: iv);
aes128_gcm_encrypt(key: key, data: data2, iv: iv);
"###;
"#;
let mut register = Register::default();
let binding = ContextBuilder::default();
let context = binding.build();
Expand Down
Loading

0 comments on commit 4b332b4

Please sign in to comment.