Skip to content

Commit

Permalink
Re-add newline (#613)
Browse files Browse the repository at this point in the history
* Re-add newline

* Add newline to eprint

* Fix tests

---------

Co-authored-by: KCarretto <Kcarretto@gmail.com>
  • Loading branch information
hulto and KCarretto authored Feb 20, 2024
1 parent 7569cca commit 2c320c8
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion implants/golem/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ mod tests {
}]);

let out = run_tomes(parsed_tomes).await?;
assert_eq!("hello world".to_string(), out.join(""));
assert_eq!("hello world\n".to_string(), out.join(""));
Ok(())
}
}
2 changes: 1 addition & 1 deletion implants/lib/eldritch/src/assets/copy_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ mod tests {
.collect::<Vec<&Message>>();
assert!(errors.is_empty());

let mut contents = String::new();
let mut contents: String = String::new();
tmp_file_dst.read_to_string(&mut contents)?;
assert!(contents.contains("hello from an embedded shell script"));

Expand Down
4 changes: 2 additions & 2 deletions implants/lib/eldritch/src/runtime/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ impl PrintHandler for Environment {
fn println(&self, text: &str) -> Result<()> {
self.send(ReportTextMessage {
id: self.id,
text: String::from(text),
text: format!("{}\n", text),
})?;

#[cfg(feature = "print_stdout")]
print!("{}", text);
println!("{}", text);

Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions implants/lib/eldritch/src/runtime/eprint_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::Result;
pub fn eprint(env: &Environment, message: String) -> Result<()> {
env.send(ReportErrorMessage {
id: env.id(),
error: message.clone(),
error: format!("{}\n", message),
})?;

#[cfg(feature = "print_stdout")]
Expand Down Expand Up @@ -59,7 +59,7 @@ mod test {
parameters: HashMap::new(),
file_names: Vec::new(),
},
want_error: String::from("Beep Boop an error occured"),
want_error: String::from("Beep Boop an error occured\n"),
},
}
}
24 changes: 12 additions & 12 deletions implants/lib/eldritch/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mod tests {
parameters: HashMap::new(),
file_names: Vec::new(),
},
want_text: String::from("2"),
want_text: format!("{}\n", "2"),
want_error: None,
},
multi_print: TestCase {
Expand All @@ -65,7 +65,7 @@ mod tests {
parameters: HashMap::new(),
file_names: Vec::new(),
},
want_text: String::from(r#"oceans rise, empires fall"#),
want_text: String::from("oceans \nrise, \nempires \nfall\n"),
want_error: None,
},
input_params: TestCase{
Expand All @@ -79,7 +79,7 @@ mod tests {
]),
file_names: Vec::new(),
},
want_text: String::from("echo hello_world"),
want_text: format!("{}\n", "echo hello_world"),
want_error: None,
},
file_bindings: TestCase {
Expand All @@ -89,7 +89,7 @@ mod tests {
parameters: HashMap::new(),
file_names: Vec::new(),
},
want_text: String::from(r#"["append", "compress", "copy", "download", "exists", "find", "follow", "is_dir", "is_file", "list", "mkdir", "moveto", "read", "remove", "replace", "replace_all", "template", "timestomp", "write"]"#),
want_text: format!("{}\n", r#"["append", "compress", "copy", "download", "exists", "find", "follow", "is_dir", "is_file", "list", "mkdir", "moveto", "read", "remove", "replace", "replace_all", "template", "timestomp", "write"]"#),
want_error: None,
},
process_bindings: TestCase {
Expand All @@ -99,7 +99,7 @@ mod tests {
parameters: HashMap::new(),
file_names: Vec::new(),
},
want_text: String::from(r#"["info", "kill", "list", "name", "netstat"]"#),
want_text: format!("{}\n", r#"["info", "kill", "list", "name", "netstat"]"#),
want_error: None,
},
sys_bindings: TestCase {
Expand All @@ -109,7 +109,7 @@ mod tests {
parameters: HashMap::new(),
file_names: Vec::new(),
},
want_text: String::from(r#"["dll_inject", "dll_reflect", "exec", "get_env", "get_ip", "get_os", "get_pid", "get_reg", "get_user", "hostname", "is_linux", "is_macos", "is_windows", "shell", "write_reg_hex", "write_reg_int", "write_reg_str"]"#),
want_text: format!("{}\n", r#"["dll_inject", "dll_reflect", "exec", "get_env", "get_ip", "get_os", "get_pid", "get_reg", "get_user", "hostname", "is_linux", "is_macos", "is_windows", "shell", "write_reg_hex", "write_reg_int", "write_reg_str"]"#),
want_error: None,
},
pivot_bindings: TestCase {
Expand All @@ -119,7 +119,7 @@ mod tests {
parameters: HashMap::new(),
file_names: Vec::new(),
},
want_text: String::from(r#"["arp_scan", "bind_proxy", "ncat", "port_forward", "port_scan", "smb_exec", "ssh_copy", "ssh_exec", "ssh_password_spray"]"#),
want_text: format!("{}\n", r#"["arp_scan", "bind_proxy", "ncat", "port_forward", "port_scan", "smb_exec", "ssh_copy", "ssh_exec", "ssh_password_spray"]"#),
want_error: None,
},
assets_bindings: TestCase {
Expand All @@ -129,7 +129,7 @@ mod tests {
parameters: HashMap::new(),
file_names: Vec::new(),
},
want_text: String::from(r#"["copy", "list", "read", "read_binary"]"#),
want_text: format!("{}\n", r#"["copy", "list", "read", "read_binary"]"#),
want_error: None,
},
crypto_bindings: TestCase {
Expand All @@ -139,7 +139,7 @@ mod tests {
parameters: HashMap::new(),
file_names: Vec::new(),
},
want_text: String::from(r#"["aes_decrypt_file", "aes_encrypt_file", "decode_b64", "encode_b64", "from_json", "hash_file", "to_json"]"#),
want_text: format!("{}\n", r#"["aes_decrypt_file", "aes_encrypt_file", "decode_b64", "encode_b64", "from_json", "hash_file", "to_json"]"#),
want_error: None,
},
time_bindings: TestCase {
Expand All @@ -149,7 +149,7 @@ mod tests {
parameters: HashMap::new(),
file_names: Vec::new(),
},
want_text: String::from(r#"["format_to_epoch", "format_to_readable", "now", "sleep"]"#),
want_text: format!("{}\n", r#"["format_to_epoch", "format_to_readable", "now", "sleep"]"#),
want_error: None,
},
report_bindings: TestCase {
Expand All @@ -159,7 +159,7 @@ mod tests {
parameters: HashMap::new(),
file_names: Vec::new(),
},
want_text: String::from(r#"["file", "process_list", "ssh_key", "user_password"]"#),
want_text: format!("{}\n", r#"["file", "process_list", "ssh_key", "user_password"]"#),
want_error: None,
},
regex_bindings: TestCase {
Expand All @@ -169,7 +169,7 @@ mod tests {
parameters: HashMap::new(),
file_names: Vec::new(),
},
want_text: String::from(r#"["match", "match_all", "replace", "replace_all"]"#),
want_text: format!("{}\n", r#"["match", "match_all", "replace", "replace_all"]"#),
want_error: None,
},
}
Expand Down
3 changes: 0 additions & 3 deletions tavern/tomes/hostname/main.eldritch
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
print(sys.hostname())
print("\n")
print("\n")
print("\n")

0 comments on commit 2c320c8

Please sign in to comment.