Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
254 changes: 100 additions & 154 deletions docs/_docs/dev-guide/eldritch.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions implants/lib/eldritch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ sha1 = { workspace = true }
sha2 = { workspace = true }
sha256 = { workspace = true }
starlark = { workspace = true }
starlark_derive = { workspace = true }
sysinfo = { workspace = true }
tar = { workspace = true }
tempfile = { workspace = true }
Expand Down
92 changes: 0 additions & 92 deletions implants/lib/eldritch/src/assets.rs

This file was deleted.

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 @@ -13,7 +13,7 @@ fn copy_local(src: String, dst: String) -> Result<()> {

match fs::write(dst, src_file) {
Ok(_) => Ok(()),
Err(local_err) => Err(local_err.try_into()?),
Err(local_err) => Err(anyhow::anyhow!(local_err)),
}
}

Expand Down
60 changes: 60 additions & 0 deletions implants/lib/eldritch/src/assets/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
mod copy_impl;
mod list_impl;
mod read_binary_impl;
mod read_impl;

use rust_embed::RustEmbed;
use starlark::{environment::MethodsBuilder, eval::Evaluator, values::none::NoneType};
use starlark_derive::{starlark_module, starlark_value};

#[cfg(debug_assertions)]
#[derive(RustEmbed)]
#[folder = "../../../bin/embedded_files_test"]
pub struct Asset;

#[cfg(not(feature = "imix"))]
#[cfg(not(debug_assertions))]
#[derive(RustEmbed)]
#[folder = "../../../implants/golem/embed_files_golem_prod"]
pub struct Asset;

#[cfg(feature = "imix")]
#[cfg(not(debug_assertions))]
#[derive(RustEmbed)]
#[folder = "../../../implants/imix/install_scripts"]
pub struct Asset;

/*
* Define our library for this module.
*/
crate::eldritch_lib!(AssetsLibrary, "assets_library");

/*
* Below, we define starlark wrappers for all of our library methods.
* The functions must be defined here to be present on our library.
*/
#[starlark_module]
#[rustfmt::skip]
#[allow(clippy::needless_lifetimes, clippy::type_complexity, clippy::too_many_arguments)]
fn methods(builder: &mut MethodsBuilder) {
#[allow(unused_variables)]
fn copy<'v>(this: &AssetsLibrary, starlark_eval: &mut Evaluator<'v, '_>, src: String, dest: String) -> anyhow::Result<NoneType> {
copy_impl::copy(starlark_eval, src, dest)?;
Ok(NoneType{})
}

#[allow(unused_variables)]
fn list(this: &AssetsLibrary) -> anyhow::Result<Vec<String>> {
list_impl::list()
}

#[allow(unused_variables)]
fn read_binary(this: &AssetsLibrary, src: String) -> anyhow::Result<Vec<u32>> {
read_binary_impl::read_binary(src)
}

#[allow(unused_variables)]
fn read(this: &AssetsLibrary, src: String) -> anyhow::Result<String> {
read_impl::read(src)
}
}
88 changes: 0 additions & 88 deletions implants/lib/eldritch/src/crypto.rs

This file was deleted.

64 changes: 64 additions & 0 deletions implants/lib/eldritch/src/crypto/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
mod aes_decrypt_file_impl;
mod aes_encrypt_file_impl;
mod decode_b64_impl;
mod encode_b64_impl;
mod from_json_impl;
mod hash_file_impl;
mod to_json_impl;

use starlark::environment::MethodsBuilder;
use starlark::starlark_module;
use starlark::values::none::NoneType;
use starlark::values::starlark_value;
use starlark::values::{Heap, Value};

/*
* Define our library for this module.
*/
crate::eldritch_lib!(CryptoLibrary, "crypto_library");

/*
* Below, we define starlark wrappers for all of our library methods.
* The functions must be defined here to be present on our library.
*/
#[starlark_module]
#[rustfmt::skip]
#[allow(clippy::needless_lifetimes, clippy::type_complexity, clippy::too_many_arguments)]
fn methods(builder: &mut MethodsBuilder) {
#[allow(unused_variables)]
fn aes_encrypt_file<'v>(this: &CryptoLibrary, src: String, dst: String, key: String) -> anyhow::Result<NoneType> {
aes_encrypt_file_impl::encrypt_file(src, dst, key)?;
Ok(NoneType{})
}

#[allow(unused_variables)]
fn aes_decrypt_file<'v>(this: &CryptoLibrary, src: String, dst: String, key: String) -> anyhow::Result<NoneType> {
aes_decrypt_file_impl::decrypt_file(src, dst, key)?;
Ok(NoneType{})
}

#[allow(unused_variables)]
fn hash_file<'v>(this: &CryptoLibrary, file: String, algo: String) -> anyhow::Result<String> {
hash_file_impl::hash_file(file, algo)
}

#[allow(unused_variables)]
fn encode_b64<'v>(this: &CryptoLibrary, content: String, encode_type: Option<String>) -> anyhow::Result<String> {
encode_b64_impl::encode_b64(content, encode_type)
}

#[allow(unused_variables)]
fn decode_b64<'v>(this: &CryptoLibrary, content: String, encode_type: Option<String>) -> anyhow::Result<String> {
decode_b64_impl::decode_b64(content, encode_type)
}

#[allow(unused_variables)]
fn from_json<'v>(this: &CryptoLibrary, starlark_heap: &'v Heap, content: String) -> anyhow::Result<Value<'v>> {
from_json_impl::from_json(starlark_heap, content)
}

#[allow(unused_variables)]
fn to_json<'v>(this: &CryptoLibrary, content: Value) -> anyhow::Result<String> {
to_json_impl::to_json(content)
}
}
Loading