From b92109c09669ff6a1d77ab701e4ed65a0a3c793a Mon Sep 17 00:00:00 2001 From: savacano28 Date: Mon, 23 Dec 2024 19:16:32 +0100 Subject: [PATCH 01/23] [agent] Add code quality tools --- .circleci/config.yml | 60 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3698c6b..d7f0892 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,6 +18,16 @@ jobs: - run: ./rustup-init.exe -vy - run: rustup toolchain install stable-x86_64-pc-windows-msvc - run: rustup default stable-x86_64-pc-windows-msvc + # Install quality tools + - run: | + rustup component add clippy + rustup component add rustfmt + cargo install cargo-audit + # Run checks + - run: cargo clippy -- -D warnings + - run: cargo fmt -- --check + - run: cargo audit + - run: cargo test --release - run: cargo build --release - save_cache: key: cargo-{{ arch }}-{{ checksum "Cargo.toml" }} @@ -62,6 +72,16 @@ jobs: - run: ./rustup-init.exe -vy - run: Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\rustup" toolchain install stable-aarch64-pc-windows-msvc' - run: Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\rustup" default stable-aarch64-pc-windows-msvc' + # Install quality tools + - run: | + rustup component add clippy + rustup component add rustfmt + cargo install cargo-audit + # Run checks + - run: cargo clippy -- -D warnings + - run: cargo fmt -- --check + - run: cargo audit + - run: cargo test --release - run: $env:PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\ARM64\bin;" + $env:PATH; Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\cargo" build --release' - save_cache: key: cargo-{{ arch }}-{{ checksum "Cargo.toml" }} @@ -106,6 +126,16 @@ jobs: - run: sudo apt-get -y install curl musl-tools - run: curl https://sh.rustup.rs -sSf | sh -s -- -y - run: . "$HOME/.cargo/env"; rustup target add x86_64-unknown-linux-musl + # Install quality tools + - run: | + rustup component add clippy + rustup component add rustfmt + cargo install cargo-audit + # Run checks + - run: cargo clippy -- -D warnings + - run: cargo fmt -- --check + - run: cargo audit + - run: cargo test --release - run: . "$HOME/.cargo/env"; cargo build --target=x86_64-unknown-linux-musl --release - run: strip ./target/x86_64-unknown-linux-musl/release/openbas-implant - save_cache: @@ -150,6 +180,16 @@ jobs: - run: sudo apt-get -y install curl musl-tools - run: curl https://sh.rustup.rs -sSf | sh -s -- -y - run: . "$HOME/.cargo/env"; rustup target add aarch64-unknown-linux-musl + # Install quality tools + - run: | + rustup component add clippy + rustup component add rustfmt + cargo install cargo-audit + # Run checks + - run: cargo clippy -- -D warnings + - run: cargo fmt -- --check + - run: cargo audit + - run: cargo test --release - run: . "$HOME/.cargo/env"; cargo build --target=aarch64-unknown-linux-musl --release - run: strip ./target/aarch64-unknown-linux-musl/release/openbas-implant - save_cache: @@ -192,6 +232,16 @@ jobs: - cargo-{{ arch }}-{{ checksum "Cargo.toml" }} - cargo-{{ arch }} - run: curl https://sh.rustup.rs -sSf | sh -s -- -y + # Install quality tools + - run: | + rustup component add clippy + rustup component add rustfmt + cargo install cargo-audit + # Run checks + - run: cargo clippy -- -D warnings + - run: cargo fmt -- --check + - run: cargo audit + - run: cargo test --release - run: . "$HOME/.cargo/env"; cargo build --release - run: strip ./target/release/openbas-implant - save_cache: @@ -230,6 +280,16 @@ jobs: - cargo-{{ arch }}-{{ checksum "Cargo.toml" }} - cargo-{{ arch }} - run: curl https://sh.rustup.rs -sSf | sh -s -- -y + # Install quality tools + - run: | + rustup component add clippy + rustup component add rustfmt + cargo install cargo-audit + # Run checks + - run: cargo clippy -- -D warnings + - run: cargo fmt -- --check + - run: cargo audit + - run: cargo test --release - run: . "$HOME/.cargo/env"; cargo build --release - run: strip ./target/release/openbas-implant - save_cache: From 9e4fce903867a96cd7875079b867fa8d7e8c4763 Mon Sep 17 00:00:00 2001 From: savacano28 Date: Mon, 23 Dec 2024 19:20:38 +0100 Subject: [PATCH 02/23] [implant] Add code quality tools --- src/api/manage_inject.rs | 16 ++++++++-------- src/api/manage_reporting.rs | 4 ++-- src/api/mod.rs | 12 ++++++------ src/common/error_model.rs | 2 +- src/handle/handle_command.rs | 8 ++++---- src/handle/handle_dns_resolution.rs | 4 ++-- src/handle/handle_execution.rs | 4 ++-- src/handle/handle_file.rs | 6 +++--- src/main.rs | 18 +++++++++--------- src/process/command_exec.rs | 2 +- src/process/exec_utils.rs | 1 - src/process/file_exec.rs | 4 ++-- src/tests/process/command_exec_tests.rs | 1 - 13 files changed, 40 insertions(+), 42 deletions(-) diff --git a/src/api/manage_inject.rs b/src/api/manage_inject.rs index 03f437c..79ad0fb 100644 --- a/src/api/manage_inject.rs +++ b/src/api/manage_inject.rs @@ -70,13 +70,13 @@ pub struct UpdateInput { impl Client { pub fn get_executable_payload(&self, inject_id: String) -> Result { - return match self.get(&format!("/api/injects/{}/executable-payload", inject_id)).call() { + match self.get(&format!("/api/injects/{}/executable-payload", inject_id)).call() { Ok(response) => Ok(response.into_json()?), Err(ureq::Error::Status(_, response)) => { Err(Error::Api(response.into_string().unwrap())) } Err(err) => Err(Error::Internal(err.to_string())), - }; + } } pub fn update_status( @@ -85,7 +85,7 @@ impl Client { input: UpdateInput, ) -> Result { let post_data = ureq::json!(input); - return match self + match self .post(&format!("/api/injects/execution/callback/{}", inject_id)) .send_json(post_data) { @@ -94,11 +94,11 @@ impl Client { Err(Error::Api(response.into_string().unwrap())) } Err(err) => Err(Error::Internal(err.to_string())), - }; + } } pub fn download_file(&self, document_id: &String, in_memory: bool) -> Result { - return match self + match self .get(&format!("/api/documents/{}/file", document_id)) .call() { @@ -111,7 +111,7 @@ impl Client { let executable_path = current_exe_patch.parent().unwrap(); let name = dis.params.get("filename").unwrap(); let file_directory = executable_path.join(name); - return if in_memory { + if in_memory { let buf = BufWriter::new(Vec::new()); let _ = write_response(buf, response); Ok(String::from(name)) @@ -125,12 +125,12 @@ impl Client { return Err(Error::Io(err)); } }; - }; + } } Err(ureq::Error::Status(_, response)) => { Err(Error::Api(response.into_string().unwrap())) } Err(err) => Err(Error::Internal(err.to_string())), - }; + } } } diff --git a/src/api/manage_reporting.rs b/src/api/manage_reporting.rs index 8094930..ce8b82e 100644 --- a/src/api/manage_reporting.rs +++ b/src/api/manage_reporting.rs @@ -12,7 +12,7 @@ pub fn report_success( ) { let message = ExecutionOutput { action: String::from(semantic), - stderr: stderr.unwrap_or(String::new()), + stderr: stderr.unwrap_or_default(), stdout, exit_code: -1, }; @@ -37,7 +37,7 @@ pub fn report_error( ) { let message = ExecutionOutput { action: String::from(semantic), - stdout: stdout.unwrap_or(String::new()), + stdout: stdout.unwrap_or_default(), stderr, exit_code: -1, }; diff --git a/src/api/mod.rs b/src/api/mod.rs index 835d901..f008746 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -42,15 +42,15 @@ impl Client { pub fn post(&self, route: &str) -> Request { let api_route = format!("{}{}", self.server_url, route); - let request = self.http_client.post(&api_route) - .set("Authorization", &format!("Bearer {}", self.token)); - return request; + + self.http_client.post(&api_route) + .set("Authorization", &format!("Bearer {}", self.token)) } pub fn get(&self, route: &str) -> Request { let api_route = format!("{}{}", self.server_url, route); - let request = self.http_client.get(&api_route) - .set("Authorization", &format!("Bearer {}", self.token)); - return request; + + self.http_client.get(&api_route) + .set("Authorization", &format!("Bearer {}", self.token)) } } \ No newline at end of file diff --git a/src/common/error_model.rs b/src/common/error_model.rs index 8dd3644..e1c4db2 100644 --- a/src/common/error_model.rs +++ b/src/common/error_model.rs @@ -12,7 +12,7 @@ impl fmt::Display for Error { match self { Error::Internal(message) => write!(f, "{}", message), Error::Api(api_message) => write!(f, "{}", api_message), - Error::Io(io) => write!(f, "{}", io.to_string()), + Error::Io(io) => write!(f, "{}", io), } } } diff --git a/src/handle/handle_command.rs b/src/handle/handle_command.rs index 2c9beb7..71d6944 100644 --- a/src/handle/handle_command.rs +++ b/src/handle/handle_command.rs @@ -11,13 +11,13 @@ use crate::process::command_exec::command_execution; fn compute_working_dir() -> PathBuf { let current_exe_patch = env::current_exe().unwrap(); - return current_exe_patch.parent().unwrap().to_path_buf(); + current_exe_patch.parent().unwrap().to_path_buf() } pub fn compute_command(command: &String) -> String { let executable_command = command.clone(); let working_dir = compute_working_dir(); - return executable_command.replace("#{location}", working_dir.to_str().unwrap()); + executable_command.replace("#{location}", working_dir.to_str().unwrap()) } pub fn handle_execution_command( @@ -32,7 +32,7 @@ pub fn handle_execution_command( info!("{} execution: {:?}", semantic, command); let command_result = command_execution(command.as_str(), executor.as_str(), pre_check); let elapsed = now.elapsed().as_millis(); - return handle_execution_result(semantic, api, inject_id, command_result, elapsed); + handle_execution_result(semantic, api, inject_id, command_result, elapsed) } pub fn handle_command(inject_id: String, api: &Client, contract_payload: &InjectorContractPayload) { @@ -41,7 +41,7 @@ pub fn handle_command(inject_id: String, api: &Client, contract_payload: &Inject let executable_command = compute_command(&command); let _ = handle_execution_command( "implant execution", - &api, + api, inject_id.clone(), &executable_command, &executor, diff --git a/src/handle/handle_dns_resolution.rs b/src/handle/handle_dns_resolution.rs index fad3ed1..f8f506e 100644 --- a/src/handle/handle_dns_resolution.rs +++ b/src/handle/handle_dns_resolution.rs @@ -21,10 +21,10 @@ pub fn handle_dns_resolution(inject_id: String, api: &Client, contract_payload: "{hostname}: {}", addrs .map(|socket_addr: SocketAddr| { - return match socket_addr { + match socket_addr { SocketAddr::V4(v4) => v4.ip().to_string(), SocketAddr::V6(v6) => v6.ip().to_string(), - }; + } }) .collect::>() .join(", ") diff --git a/src/handle/handle_execution.rs b/src/handle/handle_execution.rs index 1b10de3..ba9f142 100644 --- a/src/handle/handle_execution.rs +++ b/src/handle/handle_execution.rs @@ -13,7 +13,7 @@ pub fn handle_execution_result( command_result: Result, elapsed: u128, ) -> i32 { - return match command_result { + match command_result { Ok(res) => { info!("{} execution stdout: {:?}", semantic, res.stdout); info!("{} execution stderr: {:?}", semantic, res.stderr); @@ -60,5 +60,5 @@ pub fn handle_execution_result( // Return error code -1 } - }; + } } diff --git a/src/handle/handle_file.rs b/src/handle/handle_file.rs index c7f7b3b..5c47ad1 100644 --- a/src/handle/handle_file.rs +++ b/src/handle/handle_file.rs @@ -18,7 +18,7 @@ pub fn handle_execution_file( info!("{} execution: {:?}", semantic, filename); let command_result = file_execution(filename.as_str()); let elapsed = now.elapsed().as_millis(); - return handle_execution_result(semantic, api, inject_id, command_result, elapsed); + handle_execution_result(semantic, api, inject_id, command_result, elapsed) } pub fn handle_file( @@ -27,7 +27,7 @@ pub fn handle_file( file_target: &Option, in_memory: bool, ) -> Result { - return match file_target { + match file_target { None => { let stderr = String::from("Payload download fail, document not specified"); report_error(api, "file drop", inject_id.clone(), None, stderr.clone(), 0); @@ -50,5 +50,5 @@ pub fn handle_file( } } } - }; + } } diff --git a/src/main.rs b/src/main.rs index a9c336d..e5d5ce1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,7 +42,7 @@ struct Args { } pub fn mode() -> String { - return env::var("env").unwrap_or_else(|_| ENV_PRODUCTION.into()); + env::var("env").unwrap_or_else(|_| ENV_PRODUCTION.into()) } pub fn handle_payload(inject_id: String, api: &Client, contract_payload: &InjectorContractPayload) { @@ -61,7 +61,7 @@ pub fn handle_payload(inject_id: String, api: &Client, contract_payload: &Inject let check_prerequisites = compute_command(check_cmd.as_ref().unwrap()); check_status = handle_execution_command( "prerequisite check", - &api, + api, inject_id.clone(), &check_prerequisites, &prerequisite.executor, @@ -73,7 +73,7 @@ pub fn handle_payload(inject_id: String, api: &Client, contract_payload: &Inject let install_prerequisites = compute_command(&prerequisite.get_command); prerequisites_code += handle_execution_command( "prerequisite execution", - &api, + api, inject_id.clone(), &install_prerequisites, &prerequisite.executor, @@ -87,10 +87,10 @@ pub fn handle_payload(inject_id: String, api: &Client, contract_payload: &Inject if prerequisites_code == 0 { let payload_type = &contract_payload.payload_type; match payload_type.as_str() { - "Command" => handle_command(inject_id.clone(), &api, &contract_payload), - "DnsResolution" => handle_dns_resolution(inject_id.clone(), &api, &contract_payload), - "Executable" => handle_file_execute(inject_id.clone(), &api, &contract_payload), - "FileDrop" => handle_file_drop(inject_id.clone(), &api, &contract_payload), + "Command" => handle_command(inject_id.clone(), api, contract_payload), + "DnsResolution" => handle_dns_resolution(inject_id.clone(), api, contract_payload), + "Executable" => handle_file_execute(inject_id.clone(), api, contract_payload), + "FileDrop" => handle_file_drop(inject_id.clone(), api, contract_payload), // "NetworkTraffic" => {}, // Not implemented yet _ => { let _ = api.update_status( @@ -124,7 +124,7 @@ pub fn handle_payload(inject_id: String, api: &Client, contract_payload: &Inject let executor = contract_payload.payload_cleanup_executor.clone().unwrap(); let _ = handle_execution_command( "cleanup execution", - &api, + api, inject_id.clone(), &executable_cleanup, &executor, @@ -156,5 +156,5 @@ fn main() -> Result<(), Error> { let contract_payload = payload.unwrap_or_else(|err| panic!("Fail getting payload {}", err)); handle_payload(args.inject_id.clone(), &api, &contract_payload); // endregion - return Ok(()); + Ok(()) } diff --git a/src/process/command_exec.rs b/src/process/command_exec.rs index f6ae9ca..a810967 100644 --- a/src/process/command_exec.rs +++ b/src/process/command_exec.rs @@ -48,7 +48,7 @@ pub fn format_windows_command(command:String) -> String { pub fn manage_result(invoke_output: Output, pre_check: bool) -> Result { let invoke_result = invoke_output.clone(); - let exit_code = invoke_result.status.code().unwrap_or_else(|| -99); + let exit_code = invoke_result.status.code().unwrap_or(-99); let stdout = decode_output(&invoke_result.stdout); let stderr = decode_output(&invoke_result.stderr); diff --git a/src/process/exec_utils.rs b/src/process/exec_utils.rs index aec92f9..aea237d 100644 --- a/src/process/exec_utils.rs +++ b/src/process/exec_utils.rs @@ -1,4 +1,3 @@ -use std::collections::HashMap; use std::process::Command; diff --git a/src/process/file_exec.rs b/src/process/file_exec.rs index 23de54d..57e5e06 100644 --- a/src/process/file_exec.rs +++ b/src/process/file_exec.rs @@ -9,13 +9,13 @@ use crate::process::exec_utils::is_executor_present; fn compute_working_file(filename: &str) -> PathBuf { let current_exe_patch = env::current_exe().unwrap(); let executable_path = current_exe_patch.parent().unwrap(); - return executable_path.join(filename); + executable_path.join(filename) } pub fn manage_result(invoke_output: Output) -> Result { let invoke_result = invoke_output.clone(); // 0 success | other = maybe prevented - let exit_code = invoke_result.status.code().unwrap_or_else(|| -99); + let exit_code = invoke_result.status.code().unwrap_or(-99); let stdout = String::from_utf8_lossy(&invoke_result.stdout).to_string(); let stderr = String::from_utf8_lossy(&invoke_result.stderr).to_string(); diff --git a/src/tests/process/command_exec_tests.rs b/src/tests/process/command_exec_tests.rs index a46fa5b..eab8b37 100644 --- a/src/tests/process/command_exec_tests.rs +++ b/src/tests/process/command_exec_tests.rs @@ -1,6 +1,5 @@ use crate::process::command_exec::decode_output; use crate::process::command_exec::format_powershell_command; -use crate::process::command_exec::format_windows_command; use crate::process::command_exec::invoke_command; From b8b9461dbf9f11367e56d117ca5eccf88d51a108 Mon Sep 17 00:00:00 2001 From: savacano28 Date: Mon, 23 Dec 2024 19:20:55 +0100 Subject: [PATCH 03/23] [implant] Add code quality tools --- src/api/manage_inject.rs | 13 ++++-- src/api/manage_reporting.rs | 2 +- src/api/mod.rs | 19 ++++++--- src/handle/handle_command.rs | 2 +- src/handle/handle_dns_resolution.rs | 11 +++-- src/handle/handle_execution.rs | 2 +- src/handle/handle_file.rs | 2 +- src/handle/handle_file_drop.rs | 8 +++- src/handle/handle_file_execute.rs | 8 +++- src/main.rs | 11 +++-- src/process/command_exec.rs | 53 +++++++++++++++---------- src/process/exec_utils.rs | 4 +- src/process/file_exec.rs | 21 +++++++--- src/process/mod.rs | 2 +- src/tests/mod.rs | 2 +- src/tests/process/command_exec_tests.rs | 3 +- 16 files changed, 103 insertions(+), 60 deletions(-) diff --git a/src/api/manage_inject.rs b/src/api/manage_inject.rs index 79ad0fb..069c243 100644 --- a/src/api/manage_inject.rs +++ b/src/api/manage_inject.rs @@ -1,6 +1,6 @@ -use std::{env, fs}; use std::fs::File; use std::io::{BufWriter, Write}; +use std::{env, fs}; use mailparse::{parse_content_disposition, parse_header}; use serde::{Deserialize, Serialize}; @@ -68,9 +68,14 @@ pub struct UpdateInput { } impl Client { - - pub fn get_executable_payload(&self, inject_id: String) -> Result { - match self.get(&format!("/api/injects/{}/executable-payload", inject_id)).call() { + pub fn get_executable_payload( + &self, + inject_id: String, + ) -> Result { + match self + .get(&format!("/api/injects/{}/executable-payload", inject_id)) + .call() + { Ok(response) => Ok(response.into_json()?), Err(ureq::Error::Status(_, response)) => { Err(Error::Api(response.into_string().unwrap())) diff --git a/src/api/manage_reporting.rs b/src/api/manage_reporting.rs index ce8b82e..93c2f18 100644 --- a/src/api/manage_reporting.rs +++ b/src/api/manage_reporting.rs @@ -1,5 +1,5 @@ -use crate::api::Client; use crate::api::manage_inject::UpdateInput; +use crate::api::Client; use crate::handle::ExecutionOutput; pub fn report_success( diff --git a/src/api/mod.rs b/src/api/mod.rs index f008746..e22db85 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -15,7 +15,12 @@ pub struct Client { } impl Client { - pub fn new(server_url: String, token: String, unsecured_certificate: bool, with_proxy: bool) -> Client { + pub fn new( + server_url: String, + token: String, + unsecured_certificate: bool, + with_proxy: bool, + ) -> Client { let mut http_client = ureq::AgentBuilder::new() .timeout_connect(Duration::from_secs(2)) .timeout(Duration::from_secs(5)) @@ -42,15 +47,17 @@ impl Client { pub fn post(&self, route: &str) -> Request { let api_route = format!("{}{}", self.server_url, route); - - self.http_client.post(&api_route) + + self.http_client + .post(&api_route) .set("Authorization", &format!("Bearer {}", self.token)) } pub fn get(&self, route: &str) -> Request { let api_route = format!("{}{}", self.server_url, route); - - self.http_client.get(&api_route) + + self.http_client + .get(&api_route) .set("Authorization", &format!("Bearer {}", self.token)) } -} \ No newline at end of file +} diff --git a/src/handle/handle_command.rs b/src/handle/handle_command.rs index 71d6944..6883d38 100644 --- a/src/handle/handle_command.rs +++ b/src/handle/handle_command.rs @@ -4,8 +4,8 @@ use std::time::Instant; use log::info; +use crate::api::manage_inject::InjectorContractPayload; use crate::api::Client; -use crate::api::manage_inject::{InjectorContractPayload}; use crate::handle::handle_execution::handle_execution_result; use crate::process::command_exec::command_execution; diff --git a/src/handle/handle_dns_resolution.rs b/src/handle/handle_dns_resolution.rs index f8f506e..2aba125 100644 --- a/src/handle/handle_dns_resolution.rs +++ b/src/handle/handle_dns_resolution.rs @@ -2,13 +2,16 @@ use std::net::{SocketAddr, ToSocketAddrs}; use log::info; -use crate::api::Client; use crate::api::manage_inject::{InjectorContractPayload, UpdateInput}; +use crate::api::Client; use crate::handle::ExecutionOutput; -pub fn handle_dns_resolution(inject_id: String, api: &Client, contract_payload: &InjectorContractPayload) { - let hostname_raw = &contract_payload - .dns_resolution_hostname; +pub fn handle_dns_resolution( + inject_id: String, + api: &Client, + contract_payload: &InjectorContractPayload, +) { + let hostname_raw = &contract_payload.dns_resolution_hostname; let data = hostname_raw.clone().unwrap(); let hostnames = data.split("\n"); for hostname in hostnames { diff --git a/src/handle/handle_execution.rs b/src/handle/handle_execution.rs index ba9f142..022aefc 100644 --- a/src/handle/handle_execution.rs +++ b/src/handle/handle_execution.rs @@ -1,7 +1,7 @@ use log::info; -use crate::api::Client; use crate::api::manage_inject::UpdateInput; +use crate::api::Client; use crate::common::error_model::Error; use crate::handle::ExecutionOutput; use crate::process::command_exec::ExecutionResult; diff --git a/src/handle/handle_file.rs b/src/handle/handle_file.rs index 5c47ad1..f59629a 100644 --- a/src/handle/handle_file.rs +++ b/src/handle/handle_file.rs @@ -2,8 +2,8 @@ use std::time::Instant; use log::info; -use crate::api::Client; use crate::api::manage_reporting::{report_error, report_success}; +use crate::api::Client; use crate::common::error_model::Error; use crate::handle::handle_execution::handle_execution_result; use crate::process::file_exec::file_execution; diff --git a/src/handle/handle_file_drop.rs b/src/handle/handle_file_drop.rs index 72d6038..4dc824e 100644 --- a/src/handle/handle_file_drop.rs +++ b/src/handle/handle_file_drop.rs @@ -1,8 +1,12 @@ +use crate::api::manage_inject::InjectorContractPayload; use crate::api::Client; -use crate::api::manage_inject::{InjectorContractPayload}; use crate::handle::handle_file::handle_file; -pub fn handle_file_drop(inject_id: String, api: &Client, contract_payload: &InjectorContractPayload) { +pub fn handle_file_drop( + inject_id: String, + api: &Client, + contract_payload: &InjectorContractPayload, +) { let InjectorContractPayload { file_drop_file, .. } = contract_payload; let _ = handle_file(inject_id, api, file_drop_file, false); } diff --git a/src/handle/handle_file_execute.rs b/src/handle/handle_file_execute.rs index a0873ac..86c8797 100644 --- a/src/handle/handle_file_execute.rs +++ b/src/handle/handle_file_execute.rs @@ -1,8 +1,12 @@ +use crate::api::manage_inject::InjectorContractPayload; use crate::api::Client; -use crate::api::manage_inject::{InjectorContractPayload}; use crate::handle::handle_file::{handle_execution_file, handle_file}; -pub fn handle_file_execute(inject_id: String, api: &Client, contract_payload: &InjectorContractPayload) { +pub fn handle_file_execute( + inject_id: String, + api: &Client, + contract_payload: &InjectorContractPayload, +) { let InjectorContractPayload { executable_file, .. } = contract_payload; diff --git a/src/main.rs b/src/main.rs index e5d5ce1..af5b2cd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,8 +5,8 @@ use clap::Parser; use log::info; use rolling_file::{BasicRollingFileAppender, RollingConditionBasic}; -use crate::api::Client; use crate::api::manage_inject::{InjectorContractPayload, UpdateInput}; +use crate::api::Client; use crate::common::error_model::Error; use crate::handle::handle_command::{compute_command, handle_command, handle_execution_command}; use crate::handle::handle_dns_resolution::handle_dns_resolution; @@ -57,7 +57,7 @@ pub fn handle_payload(inject_id: String, api: &Client, contract_payload: &Inject for prerequisite in prerequisites.iter() { let mut check_status = 1; let check_cmd = &prerequisite.check_command; - if check_cmd.is_some() && !check_cmd.clone().unwrap().is_empty(){ + if check_cmd.is_some() && !check_cmd.clone().unwrap().is_empty() { let check_prerequisites = compute_command(check_cmd.as_ref().unwrap()); check_status = handle_execution_command( "prerequisite check", @@ -151,7 +151,12 @@ fn main() -> Result<(), Error> { let args = Args::parse(); info!("Starting OpenBAS implant {} {}", VERSION, mode()); - let api = Client::new(args.uri, args.token, args.unsecured_certificate == "true", args.with_proxy == "true"); + let api = Client::new( + args.uri, + args.token, + args.unsecured_certificate == "true", + args.with_proxy == "true", + ); let payload = api.get_executable_payload(args.inject_id.clone()); let contract_payload = payload.unwrap_or_else(|err| panic!("Fail getting payload {}", err)); handle_payload(args.inject_id.clone(), &api, &contract_payload); diff --git a/src/process/command_exec.rs b/src/process/command_exec.rs index a810967..be7c670 100644 --- a/src/process/command_exec.rs +++ b/src/process/command_exec.rs @@ -14,7 +14,11 @@ pub struct ExecutionResult { pub exit_code: i32, } -pub fn invoke_command(executor: &str, cmd_expression: &str, args: &[&str]) -> std::io::Result { +pub fn invoke_command( + executor: &str, + cmd_expression: &str, + args: &[&str], +) -> std::io::Result { Command::new(executor) .args(args) .arg(cmd_expression) @@ -28,25 +32,21 @@ pub fn decode_command(encoded_command: &str) -> String { let decoded_bytes = STANDARD .decode(encoded_command) .expect("Failed to decode Base64 command"); - String::from_utf8(decoded_bytes) - .expect("Decoded command is not valid UTF-8") + String::from_utf8(decoded_bytes).expect("Decoded command is not valid UTF-8") } -pub fn format_powershell_command(command:String) -> String { +pub fn format_powershell_command(command: String) -> String { format!( "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8;$ErrorActionPreference = 'Stop'; {} ; exit $LASTEXITCODE", command ) } -pub fn format_windows_command(command:String) -> String { - format!( - "setlocal & {} & exit /b errorlevel", - command - ) +pub fn format_windows_command(command: String) -> String { + format!("setlocal & {} & exit /b errorlevel", command) } -pub fn manage_result(invoke_output: Output, pre_check: bool) -> Result { +pub fn manage_result(invoke_output: Output, pre_check: bool) -> Result { let invoke_result = invoke_output.clone(); let exit_code = invoke_result.status.code().unwrap_or(-99); @@ -81,19 +81,19 @@ pub fn decode_output(raw_bytes: &[u8]) -> String { } #[cfg(target_os = "windows")] -pub fn get_executor( executor: &str) -> &str { +pub fn get_executor(executor: &str) -> &str { match executor { "cmd" | "bash" | "sh" => executor, - _ => "powershell" + _ => "powershell", } } #[cfg(any(target_os = "linux", target_os = "macos"))] -pub fn get_executor( executor: &str) -> &str { +pub fn get_executor(executor: &str) -> &str { match executor { "bash" => executor, "psh" => "powershell", - _ => "sh" + _ => "sh", } } @@ -106,7 +106,8 @@ pub fn get_psh_arg() -> Vec<&'static str> { "Hidden", "-NonInteractive", "-NoProfile", - "-Command"]) + "-Command", + ]) } #[cfg(any(target_os = "linux", target_os = "macos"))] @@ -116,26 +117,34 @@ pub fn get_psh_arg() -> Vec<&'static str> { "Bypass", "-NonInteractive", "-NoProfile", - "-Command"]) + "-Command", + ]) } -pub fn command_execution(command: &str, executor: &str, pre_check: bool) -> Result { +pub fn command_execution( + command: &str, + executor: &str, + pre_check: bool, +) -> Result { let final_executor = get_executor(executor); - let mut formatted_cmd= decode_command(command); + let mut formatted_cmd = decode_command(command); let mut args: Vec<&str> = vec!["-c"]; - if !is_executor_present(final_executor){ - return Err(Error::Internal(format!("Executor {} is not available.", final_executor))); + if !is_executor_present(final_executor) { + return Err(Error::Internal(format!( + "Executor {} is not available.", + final_executor + ))); } if final_executor == "cmd" { formatted_cmd = format_windows_command(formatted_cmd); args = vec!["/V", "/C"]; - } else if final_executor == "powershell" { + } else if final_executor == "powershell" { formatted_cmd = format_powershell_command(formatted_cmd); args = get_psh_arg(); } let invoke_output = invoke_command(final_executor, &formatted_cmd, args.as_slice()); manage_result(invoke_output?, pre_check) -} \ No newline at end of file +} diff --git a/src/process/exec_utils.rs b/src/process/exec_utils.rs index aea237d..05981c4 100644 --- a/src/process/exec_utils.rs +++ b/src/process/exec_utils.rs @@ -1,10 +1,8 @@ use std::process::Command; - - pub fn is_executor_present(executor: &str) -> bool { Command::new(executor) .spawn() .map(|mut child| child.kill().is_ok()) .unwrap_or(false) -} \ No newline at end of file +} diff --git a/src/process/file_exec.rs b/src/process/file_exec.rs index 57e5e06..c929594 100644 --- a/src/process/file_exec.rs +++ b/src/process/file_exec.rs @@ -12,7 +12,7 @@ fn compute_working_file(filename: &str) -> PathBuf { executable_path.join(filename) } -pub fn manage_result(invoke_output: Output) -> Result { +pub fn manage_result(invoke_output: Output) -> Result { let invoke_result = invoke_output.clone(); // 0 success | other = maybe prevented let exit_code = invoke_result.status.code().unwrap_or(-99); @@ -39,11 +39,17 @@ pub fn manage_result(invoke_output: Output) -> Result { #[cfg(target_os = "windows")] pub fn file_execution(filename: &str) -> Result { let executor = "powershell.exe"; - if !is_executor_present(executor){ - return Err(Error::Internal(format!("Executor '{}' is not available.", executor))); + if !is_executor_present(executor) { + return Err(Error::Internal(format!( + "Executor '{}' is not available.", + executor + ))); } let script_file_name = compute_working_file(filename); - let win_path = format!("$ErrorActionPreference = 'Stop'; & '{}'; exit $LASTEXITCODE", script_file_name.to_str().unwrap()); + let win_path = format!( + "$ErrorActionPreference = 'Stop'; & '{}'; exit $LASTEXITCODE", + script_file_name.to_str().unwrap() + ); let command_args = &[ "-ExecutionPolicy", "Bypass", @@ -66,8 +72,11 @@ pub fn file_execution(filename: &str) -> Result { #[cfg(any(target_os = "linux", target_os = "macos"))] pub fn file_execution(filename: &str) -> Result { let executor = "bash"; - if !is_executor_present(executor){ - return Err(Error::Internal(format!("Executor '{}' is not available.", executor))); + if !is_executor_present(executor) { + return Err(Error::Internal(format!( + "Executor '{}' is not available.", + executor + ))); } let script_file_name = compute_working_file(filename); // Prepare and execute the command diff --git a/src/process/mod.rs b/src/process/mod.rs index 84f11e9..be03231 100644 --- a/src/process/mod.rs +++ b/src/process/mod.rs @@ -1,3 +1,3 @@ pub mod command_exec; +pub mod exec_utils; pub mod file_exec; -pub mod exec_utils; \ No newline at end of file diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 36dfa7e..fc7973d 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -1 +1 @@ -pub mod process; \ No newline at end of file +pub mod process; diff --git a/src/tests/process/command_exec_tests.rs b/src/tests/process/command_exec_tests.rs index eab8b37..97c00e6 100644 --- a/src/tests/process/command_exec_tests.rs +++ b/src/tests/process/command_exec_tests.rs @@ -2,7 +2,6 @@ use crate::process::command_exec::decode_output; use crate::process::command_exec::format_powershell_command; use crate::process::command_exec::invoke_command; - #[test] fn test_decode_output_with_hello() { let output = vec![72, 101, 108, 108, 111]; @@ -36,4 +35,4 @@ fn test_invoke_command_powershell_special_character() { let invoke_output = invoke_command("powershell", &formatted_cmd, args.as_slice()); let stdout = decode_output(&invoke_output.unwrap().stdout); assert_eq!(stdout, "Helloé\r\n"); -} \ No newline at end of file +} From bc12db1c6c64bb472432e9ab51702f9c8e453a16 Mon Sep 17 00:00:00 2001 From: savacano28 Date: Mon, 23 Dec 2024 19:28:05 +0100 Subject: [PATCH 04/23] [implant] Add code quality tools --- src/api/manage_inject.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/manage_inject.rs b/src/api/manage_inject.rs index 069c243..5a79e9c 100644 --- a/src/api/manage_inject.rs +++ b/src/api/manage_inject.rs @@ -123,13 +123,13 @@ impl Client { } else { let output_file = File::create(file_directory.clone()).unwrap(); let file_write = write_response(output_file, response); - return match file_write { + match file_write { Ok(_) => Ok(String::from(name)), Err(err) => { let _ = fs::remove_file(file_directory.clone()); - return Err(Error::Io(err)); + Err(Error::Io(err)) } - }; + } } } Err(ureq::Error::Status(_, response)) => { From 45ddecdfca6566325aa5dc4ac336a5b5e120f61e Mon Sep 17 00:00:00 2001 From: savacano28 Date: Mon, 23 Dec 2024 19:28:59 +0100 Subject: [PATCH 05/23] [implant] Add code quality tools --- src/api/mod.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/api/mod.rs b/src/api/mod.rs index e22db85..1040622 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -1,5 +1,7 @@ use std::sync::Arc; use std::time::Duration; +use rustls::ClientConfig; +use rustls_platform_verifier::BuilderVerifierExt; use ureq::{Agent, Request}; pub mod manage_inject; @@ -28,8 +30,11 @@ impl Client { .try_proxy_from_env(with_proxy); if unsecured_certificate { let arc_crypto_provider = Arc::new(rustls::crypto::ring::default_provider()); - let config = rustls_platform_verifier::tls_config_with_provider(arc_crypto_provider) - .expect("Failed to create TLS config with crypto provider"); + let config = ClientConfig::builder_with_provider(arc_crypto_provider) + .with_safe_default_protocol_versions() + .unwrap() + .with_platform_verifier() + .with_no_client_auth(); http_client = http_client.tls_config(Arc::new(config)); } // Remove trailing slash From db7ee9c028248c6d1d2fbb80706252ea6afff995 Mon Sep 17 00:00:00 2001 From: savacano28 Date: Mon, 23 Dec 2024 19:30:42 +0100 Subject: [PATCH 06/23] [implant] Add code quality tools --- src/handle/handle_command.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/handle/handle_command.rs b/src/handle/handle_command.rs index 6883d38..b63efda 100644 --- a/src/handle/handle_command.rs +++ b/src/handle/handle_command.rs @@ -14,7 +14,7 @@ fn compute_working_dir() -> PathBuf { current_exe_patch.parent().unwrap().to_path_buf() } -pub fn compute_command(command: &String) -> String { +pub fn compute_command(command: &str) -> String { let executable_command = command.clone(); let working_dir = compute_working_dir(); executable_command.replace("#{location}", working_dir.to_str().unwrap()) @@ -25,7 +25,7 @@ pub fn handle_execution_command( api: &Client, inject_id: String, command: &String, - executor: &String, + executor: &str, pre_check: bool, ) -> i32 { let now = Instant::now(); From 2a1eeacbfc1a611236c2eb7e6d842e2b16e45105 Mon Sep 17 00:00:00 2001 From: savacano28 Date: Mon, 23 Dec 2024 19:31:52 +0100 Subject: [PATCH 07/23] [implant] Add code quality tools --- src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.rs b/src/main.rs index af5b2cd..a1f8506 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +#![feature(str_as_str)] + use std::env; use std::sync::atomic::AtomicBool; From 5f98e25e19e962ae7cfba006240d1cdd97b52be1 Mon Sep 17 00:00:00 2001 From: savacano28 Date: Mon, 23 Dec 2024 19:36:00 +0100 Subject: [PATCH 08/23] [implant] Add code quality tools --- src/handle/handle_command.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handle/handle_command.rs b/src/handle/handle_command.rs index b63efda..e5bd859 100644 --- a/src/handle/handle_command.rs +++ b/src/handle/handle_command.rs @@ -15,7 +15,7 @@ fn compute_working_dir() -> PathBuf { } pub fn compute_command(command: &str) -> String { - let executable_command = command.clone(); + let executable_command = command; let working_dir = compute_working_dir(); executable_command.replace("#{location}", working_dir.to_str().unwrap()) } From 88bc64aac6f9a580ad3877cdfcaf722a04dc973f Mon Sep 17 00:00:00 2001 From: savacano28 Date: Mon, 23 Dec 2024 21:00:04 +0100 Subject: [PATCH 09/23] [implant] clean --- src/api/mod.rs | 4 ++-- src/handle/handle_command.rs | 2 +- src/main.rs | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/api/mod.rs b/src/api/mod.rs index 1040622..6d64f4d 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -1,7 +1,7 @@ -use std::sync::Arc; -use std::time::Duration; use rustls::ClientConfig; use rustls_platform_verifier::BuilderVerifierExt; +use std::sync::Arc; +use std::time::Duration; use ureq::{Agent, Request}; pub mod manage_inject; diff --git a/src/handle/handle_command.rs b/src/handle/handle_command.rs index e5bd859..dd56730 100644 --- a/src/handle/handle_command.rs +++ b/src/handle/handle_command.rs @@ -30,7 +30,7 @@ pub fn handle_execution_command( ) -> i32 { let now = Instant::now(); info!("{} execution: {:?}", semantic, command); - let command_result = command_execution(command.as_str(), executor.as_str(), pre_check); + let command_result = command_execution(command.as_str(), executor, pre_check); let elapsed = now.elapsed().as_millis(); handle_execution_result(semantic, api, inject_id, command_result, elapsed) } diff --git a/src/main.rs b/src/main.rs index a1f8506..af5b2cd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,3 @@ -#![feature(str_as_str)] - use std::env; use std::sync::atomic::AtomicBool; From 5283cf090fc22830ae53b5b5f406fb19ef7c7bc8 Mon Sep 17 00:00:00 2001 From: savacano28 Date: Mon, 23 Dec 2024 21:20:28 +0100 Subject: [PATCH 10/23] [implant] clean --- src/tests/process/command_exec_tests.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tests/process/command_exec_tests.rs b/src/tests/process/command_exec_tests.rs index 97c00e6..db4bb50 100644 --- a/src/tests/process/command_exec_tests.rs +++ b/src/tests/process/command_exec_tests.rs @@ -32,7 +32,12 @@ fn test_invoke_command_powershell_special_character() { let command = "echo Helloé"; let formatted_cmd = format_powershell_command(command.to_string()); let args: Vec<&str> = vec!["-c"]; - let invoke_output = invoke_command("powershell", &formatted_cmd, args.as_slice()); - let stdout = decode_output(&invoke_output.unwrap().stdout); + + let invoke_output = match invoke_command("powershell", &formatted_cmd, args.as_slice()) { + Ok(output) => output, + Err(e) => panic!("Failed to invoke PowerShell command: {}", e), + }; + + let stdout = decode_output(&invoke_output.stdout); assert_eq!(stdout, "Helloé\r\n"); } From feaf7e15ddf5217019f9f5f98c3a54d9f03e3684 Mon Sep 17 00:00:00 2001 From: savacano28 Date: Mon, 23 Dec 2024 21:24:09 +0100 Subject: [PATCH 11/23] [implant] clean --- .circleci/config.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index d7f0892..18bb307 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,6 +18,7 @@ jobs: - run: ./rustup-init.exe -vy - run: rustup toolchain install stable-x86_64-pc-windows-msvc - run: rustup default stable-x86_64-pc-windows-msvc + - run: cargo clean # Install quality tools - run: | rustup component add clippy @@ -72,6 +73,7 @@ jobs: - run: ./rustup-init.exe -vy - run: Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\rustup" toolchain install stable-aarch64-pc-windows-msvc' - run: Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\rustup" default stable-aarch64-pc-windows-msvc' + - run: cargo clean # Install quality tools - run: | rustup component add clippy @@ -126,6 +128,7 @@ jobs: - run: sudo apt-get -y install curl musl-tools - run: curl https://sh.rustup.rs -sSf | sh -s -- -y - run: . "$HOME/.cargo/env"; rustup target add x86_64-unknown-linux-musl + - run: cargo clean # Install quality tools - run: | rustup component add clippy @@ -180,6 +183,7 @@ jobs: - run: sudo apt-get -y install curl musl-tools - run: curl https://sh.rustup.rs -sSf | sh -s -- -y - run: . "$HOME/.cargo/env"; rustup target add aarch64-unknown-linux-musl + - run: cargo clean # Install quality tools - run: | rustup component add clippy @@ -232,6 +236,7 @@ jobs: - cargo-{{ arch }}-{{ checksum "Cargo.toml" }} - cargo-{{ arch }} - run: curl https://sh.rustup.rs -sSf | sh -s -- -y + - run: cargo clean # Install quality tools - run: | rustup component add clippy @@ -280,6 +285,7 @@ jobs: - cargo-{{ arch }}-{{ checksum "Cargo.toml" }} - cargo-{{ arch }} - run: curl https://sh.rustup.rs -sSf | sh -s -- -y + - run: cargo clean # Install quality tools - run: | rustup component add clippy From 6c57fae160a2b773e426442950b8781b595adda9 Mon Sep 17 00:00:00 2001 From: savacano28 Date: Mon, 23 Dec 2024 21:33:38 +0100 Subject: [PATCH 12/23] [implant] clean --- .circleci/config.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 18bb307..d7f0892 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,7 +18,6 @@ jobs: - run: ./rustup-init.exe -vy - run: rustup toolchain install stable-x86_64-pc-windows-msvc - run: rustup default stable-x86_64-pc-windows-msvc - - run: cargo clean # Install quality tools - run: | rustup component add clippy @@ -73,7 +72,6 @@ jobs: - run: ./rustup-init.exe -vy - run: Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\rustup" toolchain install stable-aarch64-pc-windows-msvc' - run: Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\rustup" default stable-aarch64-pc-windows-msvc' - - run: cargo clean # Install quality tools - run: | rustup component add clippy @@ -128,7 +126,6 @@ jobs: - run: sudo apt-get -y install curl musl-tools - run: curl https://sh.rustup.rs -sSf | sh -s -- -y - run: . "$HOME/.cargo/env"; rustup target add x86_64-unknown-linux-musl - - run: cargo clean # Install quality tools - run: | rustup component add clippy @@ -183,7 +180,6 @@ jobs: - run: sudo apt-get -y install curl musl-tools - run: curl https://sh.rustup.rs -sSf | sh -s -- -y - run: . "$HOME/.cargo/env"; rustup target add aarch64-unknown-linux-musl - - run: cargo clean # Install quality tools - run: | rustup component add clippy @@ -236,7 +232,6 @@ jobs: - cargo-{{ arch }}-{{ checksum "Cargo.toml" }} - cargo-{{ arch }} - run: curl https://sh.rustup.rs -sSf | sh -s -- -y - - run: cargo clean # Install quality tools - run: | rustup component add clippy @@ -285,7 +280,6 @@ jobs: - cargo-{{ arch }}-{{ checksum "Cargo.toml" }} - cargo-{{ arch }} - run: curl https://sh.rustup.rs -sSf | sh -s -- -y - - run: cargo clean # Install quality tools - run: | rustup component add clippy From 4eb0510ea2fba59b673420bc2c3d2b7ebc2e6cc3 Mon Sep 17 00:00:00 2001 From: savacano28 Date: Tue, 24 Dec 2024 07:43:04 +0100 Subject: [PATCH 13/23] [implant] clean --- .circleci/config.yml | 12 ++++++------ src/tests/process/command_exec_tests.rs | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d7f0892..95954c8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release + - run: cargo test --release --ignored - run: cargo build --release - save_cache: key: cargo-{{ arch }}-{{ checksum "Cargo.toml" }} @@ -81,7 +81,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release + - run: cargo test --release --ignored - run: $env:PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\ARM64\bin;" + $env:PATH; Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\cargo" build --release' - save_cache: key: cargo-{{ arch }}-{{ checksum "Cargo.toml" }} @@ -135,7 +135,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release + - run: cargo test --release --ignored - run: . "$HOME/.cargo/env"; cargo build --target=x86_64-unknown-linux-musl --release - run: strip ./target/x86_64-unknown-linux-musl/release/openbas-implant - save_cache: @@ -189,7 +189,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release + - run: cargo test --release --ignored - run: . "$HOME/.cargo/env"; cargo build --target=aarch64-unknown-linux-musl --release - run: strip ./target/aarch64-unknown-linux-musl/release/openbas-implant - save_cache: @@ -241,7 +241,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release + - run: cargo test --release --ignored - run: . "$HOME/.cargo/env"; cargo build --release - run: strip ./target/release/openbas-implant - save_cache: @@ -289,7 +289,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release + - run: cargo test --release --ignored - run: . "$HOME/.cargo/env"; cargo build --release - run: strip ./target/release/openbas-implant - save_cache: diff --git a/src/tests/process/command_exec_tests.rs b/src/tests/process/command_exec_tests.rs index db4bb50..985e5e8 100644 --- a/src/tests/process/command_exec_tests.rs +++ b/src/tests/process/command_exec_tests.rs @@ -27,6 +27,7 @@ fn test_decode_output_with_wrong_character() { assert_eq!(decoded_output, "Hello�"); } +#[ignore] #[test] fn test_invoke_command_powershell_special_character() { let command = "echo Helloé"; From 3a53a71cdec8b3d465d6044c7ad6404a358aa67c Mon Sep 17 00:00:00 2001 From: savacano28 Date: Tue, 24 Dec 2024 07:48:31 +0100 Subject: [PATCH 14/23] [implant] clean --- .circleci/config.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 95954c8..7a0d439 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release --ignored + - run: cargo test --release -- --ignored - run: cargo build --release - save_cache: key: cargo-{{ arch }}-{{ checksum "Cargo.toml" }} @@ -81,7 +81,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release --ignored + - run: cargo test --release -- --ignored - run: $env:PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\ARM64\bin;" + $env:PATH; Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\cargo" build --release' - save_cache: key: cargo-{{ arch }}-{{ checksum "Cargo.toml" }} @@ -135,7 +135,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release --ignored + - run: cargo test --release -- --ignored - run: . "$HOME/.cargo/env"; cargo build --target=x86_64-unknown-linux-musl --release - run: strip ./target/x86_64-unknown-linux-musl/release/openbas-implant - save_cache: @@ -189,7 +189,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release --ignored + - run: cargo test --release -- --ignored - run: . "$HOME/.cargo/env"; cargo build --target=aarch64-unknown-linux-musl --release - run: strip ./target/aarch64-unknown-linux-musl/release/openbas-implant - save_cache: @@ -241,7 +241,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release --ignored + - run: cargo test --release -- --ignored - run: . "$HOME/.cargo/env"; cargo build --release - run: strip ./target/release/openbas-implant - save_cache: @@ -289,7 +289,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release --ignored + - run: cargo test --release -- --ignored - run: . "$HOME/.cargo/env"; cargo build --release - run: strip ./target/release/openbas-implant - save_cache: From 5645e3c8026da5a287e079adbde9565687bd3c68 Mon Sep 17 00:00:00 2001 From: savacano28 Date: Tue, 24 Dec 2024 07:57:36 +0100 Subject: [PATCH 15/23] [implant] clean --- .circleci/config.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7a0d439..826f453 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release -- --ignored + - run: cargo test --release -- --include--ignored - run: cargo build --release - save_cache: key: cargo-{{ arch }}-{{ checksum "Cargo.toml" }} @@ -81,7 +81,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release -- --ignored + - run: cargo test --release -- --include--ignored - run: $env:PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\ARM64\bin;" + $env:PATH; Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\cargo" build --release' - save_cache: key: cargo-{{ arch }}-{{ checksum "Cargo.toml" }} @@ -135,7 +135,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release -- --ignored + - run: cargo test --release -- --include--ignored - run: . "$HOME/.cargo/env"; cargo build --target=x86_64-unknown-linux-musl --release - run: strip ./target/x86_64-unknown-linux-musl/release/openbas-implant - save_cache: @@ -189,7 +189,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release -- --ignored + - run: cargo test --release -- --include--ignored - run: . "$HOME/.cargo/env"; cargo build --target=aarch64-unknown-linux-musl --release - run: strip ./target/aarch64-unknown-linux-musl/release/openbas-implant - save_cache: @@ -241,7 +241,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release -- --ignored + - run: cargo test --release -- --include--ignored - run: . "$HOME/.cargo/env"; cargo build --release - run: strip ./target/release/openbas-implant - save_cache: @@ -289,7 +289,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release -- --ignored + - run: cargo test --release -- --include--ignored - run: . "$HOME/.cargo/env"; cargo build --release - run: strip ./target/release/openbas-implant - save_cache: From c617404bc8d77f5f70d7b0334c516255d6ae98f0 Mon Sep 17 00:00:00 2001 From: savacano28 Date: Tue, 24 Dec 2024 08:02:53 +0100 Subject: [PATCH 16/23] [implant] clean --- .circleci/config.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 826f453..7ec1bbc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release -- --include--ignored + - run: cargo test --release -- --include-ignored - run: cargo build --release - save_cache: key: cargo-{{ arch }}-{{ checksum "Cargo.toml" }} @@ -81,7 +81,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release -- --include--ignored + - run: cargo test --release -- --include-ignored - run: $env:PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\ARM64\bin;" + $env:PATH; Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\cargo" build --release' - save_cache: key: cargo-{{ arch }}-{{ checksum "Cargo.toml" }} @@ -135,7 +135,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release -- --include--ignored + - run: cargo test --release -- --include-ignored - run: . "$HOME/.cargo/env"; cargo build --target=x86_64-unknown-linux-musl --release - run: strip ./target/x86_64-unknown-linux-musl/release/openbas-implant - save_cache: @@ -189,7 +189,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release -- --include--ignored + - run: cargo test --release -- --include-ignored - run: . "$HOME/.cargo/env"; cargo build --target=aarch64-unknown-linux-musl --release - run: strip ./target/aarch64-unknown-linux-musl/release/openbas-implant - save_cache: @@ -241,7 +241,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release -- --include--ignored + - run: cargo test --release -- --include-ignored - run: . "$HOME/.cargo/env"; cargo build --release - run: strip ./target/release/openbas-implant - save_cache: @@ -289,7 +289,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release -- --include--ignored + - run: cargo test --release -- --include-ignored - run: . "$HOME/.cargo/env"; cargo build --release - run: strip ./target/release/openbas-implant - save_cache: From c704e4390e79ae83be3404ca09c8b730288cd378 Mon Sep 17 00:00:00 2001 From: savacano28 Date: Tue, 24 Dec 2024 08:13:31 +0100 Subject: [PATCH 17/23] [implant] clean --- .circleci/config.yml | 12 ++++++------ .github/ISSUE_TEMPLATE/feature_request.md | 8 ++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7ec1bbc..c76dd34 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release -- --include-ignored + - run: cargo test --release - run: cargo build --release - save_cache: key: cargo-{{ arch }}-{{ checksum "Cargo.toml" }} @@ -81,7 +81,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release -- --include-ignored + - run: cargo test --release - run: $env:PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\ARM64\bin;" + $env:PATH; Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\cargo" build --release' - save_cache: key: cargo-{{ arch }}-{{ checksum "Cargo.toml" }} @@ -135,7 +135,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release -- --include-ignored + - run: cargo test --release - run: . "$HOME/.cargo/env"; cargo build --target=x86_64-unknown-linux-musl --release - run: strip ./target/x86_64-unknown-linux-musl/release/openbas-implant - save_cache: @@ -189,7 +189,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release -- --include-ignored + - run: cargo test --release - run: . "$HOME/.cargo/env"; cargo build --target=aarch64-unknown-linux-musl --release - run: strip ./target/aarch64-unknown-linux-musl/release/openbas-implant - save_cache: @@ -241,7 +241,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release -- --include-ignored + - run: cargo test --release - run: . "$HOME/.cargo/env"; cargo build --release - run: strip ./target/release/openbas-implant - save_cache: @@ -289,7 +289,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release -- --include-ignored + - run: cargo test --release - run: . "$HOME/.cargo/env"; cargo build --release - run: strip ./target/release/openbas-implant - save_cache: diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 4c9a46b..912f22f 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -7,6 +7,14 @@ assignees: '' --- +## Context + + + ## Use case From 6b9b2e79c75a8fac788b2a3a0fa85ba2c5ea3d1b Mon Sep 17 00:00:00 2001 From: savacano28 Date: Tue, 24 Dec 2024 09:12:54 +0100 Subject: [PATCH 18/23] [implant] clean --- .circleci/config.yml | 6 ++++++ CODE_QUALITY.md | 51 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 CODE_QUALITY.md diff --git a/.circleci/config.yml b/.circleci/config.yml index c76dd34..13a4453 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,6 +20,7 @@ jobs: - run: rustup default stable-x86_64-pc-windows-msvc # Install quality tools - run: | + rustup update rustup component add clippy rustup component add rustfmt cargo install cargo-audit @@ -74,6 +75,7 @@ jobs: - run: Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\rustup" default stable-aarch64-pc-windows-msvc' # Install quality tools - run: | + rustup update rustup component add clippy rustup component add rustfmt cargo install cargo-audit @@ -128,6 +130,7 @@ jobs: - run: . "$HOME/.cargo/env"; rustup target add x86_64-unknown-linux-musl # Install quality tools - run: | + rustup update rustup component add clippy rustup component add rustfmt cargo install cargo-audit @@ -182,6 +185,7 @@ jobs: - run: . "$HOME/.cargo/env"; rustup target add aarch64-unknown-linux-musl # Install quality tools - run: | + rustup update rustup component add clippy rustup component add rustfmt cargo install cargo-audit @@ -234,6 +238,7 @@ jobs: - run: curl https://sh.rustup.rs -sSf | sh -s -- -y # Install quality tools - run: | + rustup update rustup component add clippy rustup component add rustfmt cargo install cargo-audit @@ -282,6 +287,7 @@ jobs: - run: curl https://sh.rustup.rs -sSf | sh -s -- -y # Install quality tools - run: | + rustup update rustup component add clippy rustup component add rustfmt cargo install cargo-audit diff --git a/CODE_QUALITY.md b/CODE_QUALITY.md new file mode 100644 index 0000000..0de57f0 --- /dev/null +++ b/CODE_QUALITY.md @@ -0,0 +1,51 @@ +# Code Quality Guidelines + +This document outlines the tools and standards used to maintain code quality in this project. Please follow these guidelines to ensure the codebase remains clean, efficient, and secure. + +## Quality Tools + +### Clippy + +Clippy is a Rust linter that provides a collection of lints to catch common mistakes and improve code quality. + +- **How to Run Clippy Locally:** + To run Clippy, execute the following command: + ```bash + cargo clippy -- -D warnings + +This will cause the build to fail if there are any warnings or errors. + +Clippy on CI: Clippy is run automatically on CI as part of the build process. Ensure that no warnings or errors are present before pushing your changes. + +### Rustfmt + +Rustfmt automatically formats Rust code to conform to style guidelines. + +- **How to Run Rustfmt Locally:** + To check if your code is formatted properly, run: + ```bash + cargo fmt -- --check + +This will not modify any files but will indicate if formatting is required. + +Rustfmt on CI: Rustfmt is run as part of the CI pipeline, and the build will fail if there are formatting issues. + +### Cargo Audit + +Cargo Audit checks for known vulnerabilities in the dependencies of your project. + +- **How to Run Cargo Audit Locally:** + To check for security vulnerabilities, run: + ```bash + cargo audit + +If any vulnerabilities are found, please resolve them before submitting your code. + +### Running Tests + +Unit tests and integration tests are run automatically on CI using the following command: + + ```bash + cargo test --release + +Make sure your code passes all tests before pushing. \ No newline at end of file From be10a89b0a2f19e764b245fcd6323c08a8575f27 Mon Sep 17 00:00:00 2001 From: savacano28 Date: Tue, 24 Dec 2024 09:20:58 +0100 Subject: [PATCH 19/23] [implant] clean --- CODE_QUALITY.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CODE_QUALITY.md b/CODE_QUALITY.md index 0de57f0..37226e8 100644 --- a/CODE_QUALITY.md +++ b/CODE_QUALITY.md @@ -45,7 +45,8 @@ If any vulnerabilities are found, please resolve them before submitting your cod Unit tests and integration tests are run automatically on CI using the following command: +- **How to Test Locally:** ```bash - cargo test --release + cargo test Make sure your code passes all tests before pushing. \ No newline at end of file From 70d4534a5fcdfc0a47126405332cb47778e58b69 Mon Sep 17 00:00:00 2001 From: savacano28 Date: Tue, 24 Dec 2024 10:23:10 +0100 Subject: [PATCH 20/23] [implant] clean --- .circleci/config.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 13a4453..c76dd34 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,7 +20,6 @@ jobs: - run: rustup default stable-x86_64-pc-windows-msvc # Install quality tools - run: | - rustup update rustup component add clippy rustup component add rustfmt cargo install cargo-audit @@ -75,7 +74,6 @@ jobs: - run: Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\rustup" default stable-aarch64-pc-windows-msvc' # Install quality tools - run: | - rustup update rustup component add clippy rustup component add rustfmt cargo install cargo-audit @@ -130,7 +128,6 @@ jobs: - run: . "$HOME/.cargo/env"; rustup target add x86_64-unknown-linux-musl # Install quality tools - run: | - rustup update rustup component add clippy rustup component add rustfmt cargo install cargo-audit @@ -185,7 +182,6 @@ jobs: - run: . "$HOME/.cargo/env"; rustup target add aarch64-unknown-linux-musl # Install quality tools - run: | - rustup update rustup component add clippy rustup component add rustfmt cargo install cargo-audit @@ -238,7 +234,6 @@ jobs: - run: curl https://sh.rustup.rs -sSf | sh -s -- -y # Install quality tools - run: | - rustup update rustup component add clippy rustup component add rustfmt cargo install cargo-audit @@ -287,7 +282,6 @@ jobs: - run: curl https://sh.rustup.rs -sSf | sh -s -- -y # Install quality tools - run: | - rustup update rustup component add clippy rustup component add rustfmt cargo install cargo-audit From 6fb35df4dfa29b8d724ccd2527f86eab8454ef2a Mon Sep 17 00:00:00 2001 From: savacano28 Date: Tue, 24 Dec 2024 10:29:24 +0100 Subject: [PATCH 21/23] [implant] clean --- .circleci/config.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index c76dd34..29e2382 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,6 +24,7 @@ jobs: rustup component add rustfmt cargo install cargo-audit # Run checks + - run: cargo check - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit @@ -78,6 +79,7 @@ jobs: rustup component add rustfmt cargo install cargo-audit # Run checks + - run: cargo check - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit @@ -132,6 +134,7 @@ jobs: rustup component add rustfmt cargo install cargo-audit # Run checks + - run: cargo check - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit @@ -186,6 +189,7 @@ jobs: rustup component add rustfmt cargo install cargo-audit # Run checks + - run: cargo check - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit @@ -238,6 +242,7 @@ jobs: rustup component add rustfmt cargo install cargo-audit # Run checks + - run: cargo check - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit @@ -286,6 +291,7 @@ jobs: rustup component add rustfmt cargo install cargo-audit # Run checks + - run: cargo check - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit From 5662fa86decb4445a53d23c3efe652e06fcf35c6 Mon Sep 17 00:00:00 2001 From: savacano28 Date: Tue, 24 Dec 2024 15:22:43 +0100 Subject: [PATCH 22/23] [implant] clean --- .circleci/config.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 29e2382..52bbb24 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,13 +22,11 @@ jobs: - run: | rustup component add clippy rustup component add rustfmt - cargo install cargo-audit # Run checks - run: cargo check - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - - run: cargo audit - - run: cargo test --release + - run: cargo test --release - run: cargo build --release - save_cache: key: cargo-{{ arch }}-{{ checksum "Cargo.toml" }} @@ -77,13 +75,11 @@ jobs: - run: | rustup component add clippy rustup component add rustfmt - cargo install cargo-audit # Run checks - run: cargo check - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - - run: cargo audit - - run: cargo test --release + - run: cargo test --release - run: $env:PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\ARM64\bin;" + $env:PATH; Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\cargo" build --release' - save_cache: key: cargo-{{ arch }}-{{ checksum "Cargo.toml" }} @@ -138,7 +134,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release + - run: cargo test --release - run: . "$HOME/.cargo/env"; cargo build --target=x86_64-unknown-linux-musl --release - run: strip ./target/x86_64-unknown-linux-musl/release/openbas-implant - save_cache: @@ -193,7 +189,7 @@ jobs: - run: cargo clippy -- -D warnings - run: cargo fmt -- --check - run: cargo audit - - run: cargo test --release + - run: cargo test --release - run: . "$HOME/.cargo/env"; cargo build --target=aarch64-unknown-linux-musl --release - run: strip ./target/aarch64-unknown-linux-musl/release/openbas-implant - save_cache: From 585e90421f2e52463cd0dca4ca7cb4ff052bda5d Mon Sep 17 00:00:00 2001 From: savacano28 Date: Tue, 24 Dec 2024 16:45:51 +0100 Subject: [PATCH 23/23] [implant] clean --- .circleci/config.yml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 52bbb24..dfd30ca 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,15 +18,6 @@ jobs: - run: ./rustup-init.exe -vy - run: rustup toolchain install stable-x86_64-pc-windows-msvc - run: rustup default stable-x86_64-pc-windows-msvc - # Install quality tools - - run: | - rustup component add clippy - rustup component add rustfmt - # Run checks - - run: cargo check - - run: cargo clippy -- -D warnings - - run: cargo fmt -- --check - - run: cargo test --release - run: cargo build --release - save_cache: key: cargo-{{ arch }}-{{ checksum "Cargo.toml" }} @@ -71,15 +62,6 @@ jobs: - run: ./rustup-init.exe -vy - run: Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\rustup" toolchain install stable-aarch64-pc-windows-msvc' - run: Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\rustup" default stable-aarch64-pc-windows-msvc' - # Install quality tools - - run: | - rustup component add clippy - rustup component add rustfmt - # Run checks - - run: cargo check - - run: cargo clippy -- -D warnings - - run: cargo fmt -- --check - - run: cargo test --release - run: $env:PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\ARM64\bin;" + $env:PATH; Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\cargo" build --release' - save_cache: key: cargo-{{ arch }}-{{ checksum "Cargo.toml" }}