summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-10-07 14:14:45 -0400
committerMason Reed <mason@vector35.com>2025-10-07 14:14:45 -0400
commitaafb1e7a4ce244b3f0aa25ac201dfbeeff2110e8 (patch)
tree4be02337ba0193495b58ed1bb8246526dbb51521
parent2153c833b67de7e032ff135cdb322bb4e49d2bd1 (diff)
[WARP] Move WARP settings to own setting group
This then allows us to group the settings into more understandable subgroups such as fetcher & matcher
-rw-r--r--plugins/warp/src/matcher.rs43
-rw-r--r--plugins/warp/src/plugin.rs1
-rw-r--r--plugins/warp/src/plugin/settings.rs94
3 files changed, 100 insertions, 38 deletions
diff --git a/plugins/warp/src/matcher.rs b/plugins/warp/src/matcher.rs
index d97b4a18..48adee3a 100644
--- a/plugins/warp/src/matcher.rs
+++ b/plugins/warp/src/matcher.rs
@@ -316,21 +316,32 @@ pub struct MatcherSettings {
impl MatcherSettings {
pub const TRIVIAL_FUNCTION_LEN_DEFAULT: u64 = 20;
- pub const TRIVIAL_FUNCTION_LEN_SETTING: &'static str = "analysis.warp.trivialFunctionLength";
+ pub const TRIVIAL_FUNCTION_LEN_SETTING_ALIAS: [&'static str; 1] =
+ ["analysis.warp.trivialFunctionLength"];
+ pub const TRIVIAL_FUNCTION_LEN_SETTING: &'static str = "warp.matcher.trivialFunctionLength";
pub const MINIMUM_FUNCTION_LEN_DEFAULT: u64 = 0;
- pub const MINIMUM_FUNCTION_LEN_SETTING: &'static str = "analysis.warp.minimumFunctionLength";
+ pub const MINIMUM_FUNCTION_LEN_SETTING_ALIAS: [&'static str; 1] =
+ ["analysis.warp.minimumFunctionLength"];
+ pub const MINIMUM_FUNCTION_LEN_SETTING: &'static str = "warp.matcher.minimumFunctionLength";
pub const MAXIMUM_FUNCTION_LEN_DEFAULT: u64 = 0;
- pub const MAXIMUM_FUNCTION_LEN_SETTING: &'static str = "analysis.warp.maximumFunctionLength";
+ pub const MAXIMUM_FUNCTION_LEN_SETTING_ALIAS: [&'static str; 1] =
+ ["analysis.warp.maximumFunctionLength"];
+ pub const MAXIMUM_FUNCTION_LEN_SETTING: &'static str = "warp.matcher.maximumFunctionLength";
pub const MINIMUM_MATCHED_CONSTRAINTS_DEFAULT: usize = 1;
+ pub const MINIMUM_MATCHED_CONSTRAINTS_SETTING_ALIAS: [&'static str; 1] =
+ ["analysis.warp.minimumMatchedConstraints"];
pub const MINIMUM_MATCHED_CONSTRAINTS_SETTING: &'static str =
- "analysis.warp.minimumMatchedConstraints";
+ "warp.matcher.minimumMatchedConstraints";
pub const TRIVIAL_FUNCTION_ADJACENT_ALLOWED_DEFAULT: bool = false;
+ pub const TRIVIAL_FUNCTION_ADJACENT_ALLOWED_SETTING_ALIAS: [&'static str; 1] =
+ ["analysis.warp.trivialFunctionAdjacentAllowed"];
pub const TRIVIAL_FUNCTION_ADJACENT_ALLOWED_SETTING: &'static str =
- "analysis.warp.trivialFunctionAdjacentAllowed";
+ "warp.matcher.trivialFunctionAdjacentAllowed";
+ pub const MAXIMUM_POSSIBLE_FUNCTIONS_SETTING_ALIAS: [&'static str; 1] =
+ ["analysis.warp.maximumPossibleFunctions"];
pub const MAXIMUM_POSSIBLE_FUNCTIONS_SETTING: &'static str =
- "analysis.warp.maximumPossibleFunctions";
+ "warp.matcher.maximumPossibleFunctions";
pub const MAXIMUM_POSSIBLE_FUNCTIONS_DEFAULT: u64 = 1000;
-
/// Populates the [MatcherSettings] to the current Binary Ninja settings instance.
///
/// Call this once when you initialize so that the settings exist.
@@ -343,7 +354,8 @@ impl MatcherSettings {
"type" : "number",
"default" : Self::TRIVIAL_FUNCTION_LEN_DEFAULT,
"description" : "Functions below this length in bytes will be required to match on constraints.",
- "ignore" : []
+ "ignore" : [],
+ "aliases" : Self::TRIVIAL_FUNCTION_LEN_SETTING_ALIAS,
});
bn_settings.register_setting_json(
Self::TRIVIAL_FUNCTION_LEN_SETTING,
@@ -355,7 +367,8 @@ impl MatcherSettings {
"type" : "number",
"default" : Self::MINIMUM_FUNCTION_LEN_DEFAULT,
"description" : "Functions below this length will not be matched.",
- "ignore" : []
+ "ignore" : [],
+ "aliases" : Self::MINIMUM_FUNCTION_LEN_SETTING_ALIAS,
});
bn_settings.register_setting_json(
Self::MINIMUM_FUNCTION_LEN_SETTING,
@@ -367,7 +380,8 @@ impl MatcherSettings {
"type" : "number",
"default" : Self::MAXIMUM_FUNCTION_LEN_DEFAULT,
"description" : "Functions above this length will not be matched. A value of 0 will disable this check.",
- "ignore" : []
+ "ignore" : [],
+ "aliases" : Self::MAXIMUM_FUNCTION_LEN_SETTING_ALIAS,
});
bn_settings.register_setting_json(
Self::MAXIMUM_FUNCTION_LEN_SETTING,
@@ -379,7 +393,8 @@ impl MatcherSettings {
"type" : "number",
"default" : Self::MINIMUM_MATCHED_CONSTRAINTS_DEFAULT,
"description" : "When function constraints are checked the amount of constraints matched must be at-least this.",
- "ignore" : []
+ "ignore" : [],
+ "aliases" : Self::MINIMUM_MATCHED_CONSTRAINTS_SETTING_ALIAS,
});
bn_settings.register_setting_json(
Self::MINIMUM_MATCHED_CONSTRAINTS_SETTING,
@@ -391,7 +406,8 @@ impl MatcherSettings {
"type" : "boolean",
"default" : Self::TRIVIAL_FUNCTION_ADJACENT_ALLOWED_DEFAULT,
"description" : "When function constraints are checked if this is enabled functions can match based off trivial adjacent functions.",
- "ignore" : []
+ "ignore" : [],
+ "aliases" : Self::TRIVIAL_FUNCTION_ADJACENT_ALLOWED_SETTING_ALIAS,
});
bn_settings.register_setting_json(
Self::TRIVIAL_FUNCTION_ADJACENT_ALLOWED_SETTING,
@@ -403,7 +419,8 @@ impl MatcherSettings {
"type" : "number",
"default" : Self::MAXIMUM_POSSIBLE_FUNCTIONS_DEFAULT,
"description" : "When matching any function that has a list of possible functions greater than this number will be skipped. A value of 0 will disable this check.",
- "ignore" : []
+ "ignore" : [],
+ "aliases" : Self::MAXIMUM_POSSIBLE_FUNCTIONS_SETTING_ALIAS,
});
bn_settings.register_setting_json(
Self::MAXIMUM_POSSIBLE_FUNCTIONS_SETTING,
diff --git a/plugins/warp/src/plugin.rs b/plugins/warp/src/plugin.rs
index 229b0ae0..5746a9bc 100644
--- a/plugins/warp/src/plugin.rs
+++ b/plugins/warp/src/plugin.rs
@@ -139,6 +139,7 @@ pub extern "C" fn CorePluginInit() -> bool {
// Register our matcher and plugin settings globally.
let mut global_bn_settings = Settings::new();
+ global_bn_settings.register_group("warp", "WARP");
MatcherSettings::register(&mut global_bn_settings);
PluginSettings::register(&mut global_bn_settings);
diff --git a/plugins/warp/src/plugin/settings.rs b/plugins/warp/src/plugin/settings.rs
index a6286a8e..6469be0f 100644
--- a/plugins/warp/src/plugin/settings.rs
+++ b/plugins/warp/src/plugin/settings.rs
@@ -1,3 +1,4 @@
+use crate::container::SourceTag;
use binaryninja::settings::{QueryOptions, Settings as BNSettings};
use serde_json::json;
use std::string::ToString;
@@ -25,7 +26,11 @@ pub struct PluginSettings {
/// A source must have at least one of these tags to be considered a valid source.
///
/// This is set to [PluginSettings::SOURCE_TAGS_DEFAULT] by default.
- pub whitelisted_source_tags: Vec<String>,
+ pub allowed_source_tags: Vec<SourceTag>,
+ /// The maximum number of functions to fetch in a single batch.
+ ///
+ /// This is set to [PluginSettings::FETCH_BATCH_SIZE_DEFAULT] by default.
+ pub fetch_batch_size: usize,
/// Whether to allow networked WARP requests. Turning this off will not disable local WARP functionality.
///
/// This is set to [PluginSettings::ENABLE_SERVER_DEFAULT] by default.
@@ -33,34 +38,58 @@ pub struct PluginSettings {
}
impl PluginSettings {
- pub const WHITELISTED_SOURCE_TAGS_DEFAULT: Vec<String> = vec![];
- pub const WHITELISTED_SOURCE_TAGS_SETTING: &'static str = "analysis.warp.whitelistedSourceTags";
+ pub const ALLOWED_SOURCE_TAGS_DEFAULT: [&'static str; 2] = ["official", "trusted"];
+ pub const ALLOWED_SOURCE_TAGS_SETTING: &'static str = "warp.fetcher.allowedSourceTags";
+ pub const FETCH_BATCH_SIZE_DEFAULT: usize = 100;
+ pub const FETCH_BATCH_SIZE_SETTING: &'static str = "warp.fetcher.fetchBatchSize";
pub const LOAD_BUNDLED_FILES_DEFAULT: bool = true;
- pub const LOAD_BUNDLED_FILES_SETTING: &'static str = "analysis.warp.loadBundledFiles";
+ pub const LOAD_BUNDLED_FILES_SETTING: &'static str = "warp.container.loadBundledFiles";
+ pub const LOAD_BUNDLED_FILES_SETTING_ALIAS: [&'static str; 1] =
+ ["analysis.warp.loadBundledFiles"];
pub const LOAD_USER_FILES_DEFAULT: bool = true;
- pub const LOAD_USER_FILES_SETTING: &'static str = "analysis.warp.loadUserFiles";
+ pub const LOAD_USER_FILES_SETTING: &'static str = "warp.container.loadUserFiles";
+ pub const LOAD_USER_FILES_SETTING_ALIAS: [&'static str; 1] = ["analysis.warp.loadUserFiles"];
pub const SERVER_URL_DEFAULT: &'static str = "https://warp.binary.ninja";
- pub const SERVER_URL_SETTING: &'static str = "analysis.warp.serverUrl";
+ pub const SERVER_URL_SETTING: &'static str = "warp.container.serverUrl";
+ pub const SERVER_URL_SETTING_ALIAS: [&'static str; 1] = ["analysis.warp.serverUrl"];
pub const SERVER_API_KEY_DEFAULT: Option<String> = None;
- pub const SERVER_API_KEY_SETTING: &'static str = "analysis.warp.serverApiKey";
+ pub const SERVER_API_KEY_SETTING: &'static str = "warp.container.serverApiKey";
+ pub const SERVER_API_KEY_SETTING_ALIAS: [&'static str; 1] = ["analysis.warp.serverApiKey"];
pub const SECONDARY_SERVER_URL_DEFAULT: Option<String> = None;
- pub const SECONDARY_SERVER_URL_SETTING: &'static str = "analysis.warp.secondServerUrl";
+ pub const SECONDARY_SERVER_URL_SETTING: &'static str = "warp.container.secondServerUrl";
+ pub const SECONDARY_SERVER_URL_SETTING_ALIAS: [&'static str; 1] =
+ ["analysis.warp.secondServerUrl"];
pub const SECONDARY_SERVER_API_KEY_DEFAULT: Option<String> = None;
- pub const SECONDARY_SERVER_API_KEY_SETTING: &'static str = "analysis.warp.secondServerApiKey";
+ pub const SECONDARY_SERVER_API_KEY_SETTING: &'static str = "warp.container.secondServerApiKey";
+ pub const SECONDARY_SERVER_API_KEY_SETTING_ALIAS: [&'static str; 1] =
+ ["analysis.warp.secondServerApiKey"];
pub const ENABLE_SERVER_DEFAULT: bool = false;
pub const ENABLE_SERVER_SETTING: &'static str = "network.enableWARP";
pub fn register(bn_settings: &mut BNSettings) {
- let whitelisted_source_tags_prop = json!({
- "title" : "Blacklisted Sources",
+ let allowed_source_tags_prop = json!({
+ "title" : "Allowed Source Tags",
"type" : "array",
- "default" : Self::WHITELISTED_SOURCE_TAGS_DEFAULT,
- "description" : "Add a sources UUID to this list to blacklist it from being considered a valid source. This is useful for sources that are known to be false positives.",
+ "default" : Self::ALLOWED_SOURCE_TAGS_DEFAULT,
+ "description" : "The source tags that are allowed to be fetched from the server. Any source that does not have at least one of these tags will be ignored.",
+ "ignore" : [],
+ });
+ bn_settings.register_setting_json(
+ Self::ALLOWED_SOURCE_TAGS_SETTING,
+ &allowed_source_tags_prop.to_string(),
+ );
+ let fetch_size_props = json!({
+ "title" : "Fetch Batch Limit",
+ "type" : "number",
+ "minValue" : 1,
+ "maxValue" : 1000,
+ "default" : Self::FETCH_BATCH_SIZE_DEFAULT,
+ "description" : "The maximum number of functions to fetch in a single batch. This is used to limit the amount of functions to fetch at once, lowering this value will make the fetch process more comprehensive at the cost of more network requests.",
"ignore" : [],
});
bn_settings.register_setting_json(
- Self::WHITELISTED_SOURCE_TAGS_SETTING,
- &whitelisted_source_tags_prop.to_string(),
+ Self::FETCH_BATCH_SIZE_SETTING,
+ &fetch_size_props.to_string(),
);
let load_bundled_files_prop = json!({
"title" : "Load Bundled Files",
@@ -68,6 +97,7 @@ impl PluginSettings {
"default" : Self::LOAD_BUNDLED_FILES_DEFAULT,
"description" : "Whether to load bundled WARP files on startup. Turn this off if you want to manually load them.",
"ignore" : ["SettingsProjectScope", "SettingsResourceScope"],
+ "aliases" : Self::LOAD_BUNDLED_FILES_SETTING_ALIAS,
"requiresRestart" : true
});
bn_settings.register_setting_json(
@@ -80,7 +110,8 @@ impl PluginSettings {
"default" : Self::LOAD_USER_FILES_DEFAULT,
"description" : "Whether to load user WARP files on startup. Turn this off if you want to manually load them.",
"ignore" : ["SettingsProjectScope", "SettingsResourceScope"],
- "requiresRestart" : true
+ "requiresRestart" : true,
+ "aliases" : Self::LOAD_USER_FILES_SETTING_ALIAS,
});
bn_settings.register_setting_json(
Self::LOAD_USER_FILES_SETTING,
@@ -92,7 +123,8 @@ impl PluginSettings {
"default" : Self::SERVER_URL_DEFAULT,
"description" : "The WARP server to use.",
"ignore" : ["SettingsProjectScope", "SettingsResourceScope"],
- "requiresRestart" : true
+ "requiresRestart" : true,
+ "aliases" : Self::SERVER_URL_SETTING_ALIAS,
});
bn_settings.register_setting_json(Self::SERVER_URL_SETTING, &server_url_prop.to_string());
let server_api_key_prop = json!({
@@ -102,7 +134,8 @@ impl PluginSettings {
"description" : "The API key to use for the selected WARP server, if not specified you will be unable to push data, and may be rate limited.",
"ignore" : ["SettingsProjectScope", "SettingsResourceScope"],
"hidden": true,
- "requiresRestart" : true
+ "requiresRestart" : true,
+ "aliases" : Self::SERVER_API_KEY_SETTING_ALIAS,
});
bn_settings.register_setting_json(
Self::SERVER_API_KEY_SETTING,
@@ -114,7 +147,8 @@ impl PluginSettings {
"default" : Self::SECONDARY_SERVER_URL_DEFAULT,
"description" : "",
"ignore" : ["SettingsProjectScope", "SettingsResourceScope"],
- "requiresRestart" : true
+ "requiresRestart" : true,
+ "aliases" : Self::SECONDARY_SERVER_URL_SETTING_ALIAS
});
bn_settings.register_setting_json(
Self::SECONDARY_SERVER_URL_SETTING,
@@ -127,7 +161,8 @@ impl PluginSettings {
"description" : "",
"ignore" : ["SettingsProjectScope", "SettingsResourceScope"],
"hidden": true,
- "requiresRestart" : true
+ "requiresRestart" : true,
+ "aliases" : Self::SECONDARY_SERVER_API_KEY_SETTING_ALIAS
});
bn_settings.register_setting_json(
Self::SECONDARY_SERVER_API_KEY_SETTING,
@@ -183,14 +218,19 @@ impl PluginSettings {
settings.enable_server = bn_settings.get_bool(Self::ENABLE_SERVER_SETTING);
}
- if bn_settings.contains(Self::WHITELISTED_SOURCE_TAGS_SETTING) {
+ if bn_settings.contains(Self::ALLOWED_SOURCE_TAGS_SETTING) {
let whitelisted_source_tags_str = bn_settings
- .get_string_list_with_opts(Self::WHITELISTED_SOURCE_TAGS_SETTING, query_opts);
- settings.whitelisted_source_tags = whitelisted_source_tags_str
+ .get_string_list_with_opts(Self::ALLOWED_SOURCE_TAGS_SETTING, query_opts);
+ settings.allowed_source_tags = whitelisted_source_tags_str
.iter()
- .map(|s| s.to_string())
+ .map(SourceTag::from)
.collect();
}
+ if bn_settings.contains(Self::FETCH_BATCH_SIZE_SETTING) {
+ settings.fetch_batch_size = bn_settings
+ .get_integer_with_opts(Self::FETCH_BATCH_SIZE_SETTING, query_opts)
+ as usize;
+ }
settings
}
}
@@ -198,7 +238,11 @@ impl PluginSettings {
impl Default for PluginSettings {
fn default() -> Self {
Self {
- whitelisted_source_tags: PluginSettings::WHITELISTED_SOURCE_TAGS_DEFAULT,
+ allowed_source_tags: PluginSettings::ALLOWED_SOURCE_TAGS_DEFAULT
+ .into_iter()
+ .map(SourceTag::from)
+ .collect(),
+ fetch_batch_size: PluginSettings::FETCH_BATCH_SIZE_DEFAULT,
load_bundled_files: PluginSettings::LOAD_BUNDLED_FILES_DEFAULT,
load_user_files: PluginSettings::LOAD_USER_FILES_DEFAULT,
server_url: PluginSettings::SERVER_URL_DEFAULT.to_string(),