Hugal31 / yara-rust

Rust bindings for VirusTotal/Yara
Apache License 2.0
70 stars 30 forks source link

Add configuration of max process memory chunk #111

Closed vthib closed 1 year ago

vthib commented 1 year ago

The YR_CONFIG_MAX_PROCESS_MEMORY_CHUNK configuration is missing from yara-rust. However, there is a big issue when trying to add it, it's that this configuration uses a u64 value, while all other configs uses a u32.

The current design only works with u32s, where the get_configuration & set_configuration are generic over a config enum, and always retrieve/uses a u32 value.

To add a config that uses a u64 value, there are several possibilities:

enum ConfigToSet {
   MaxMatchData(u32),
   MaxProcessMemoryChunk(u64),
}

enum Config {
   MaxMatchData,
   MaxProcessMemoryChunk,
}
enum ConfigValue {
    U32(u32),
    U64(u64),
}

pub fn get_config(Config) -> Result<ConfigValue>;
pub fn set_config(ConfigToSet) -> Result<()>;

or something of that effect

Main issue is that it breaks backward compat, and it is very verbose. For the moment (and I don't suspect it will change), there is only 4 config parameters, so the verbosity is not that high.

Let me know what you think

vthib commented 1 year ago

Ci fail on linter is unrelated, caused by a new clippy warning in the build.rs file