v0.3.10 - .

This commit is contained in:
Your Name
2025-09-24 10:49:48 -04:00
parent 01836a4b4c
commit be99595bde
7 changed files with 822 additions and 133 deletions

View File

@@ -2181,11 +2181,16 @@ int process_admin_auth_event(cJSON* event, char* error_message, size_t error_siz
// Parse the action from content (should be "add" or "remove")
cJSON* content_json = cJSON_Parse(content);
const char* action = "add"; // default
char action_buffer[16] = "add"; // Local buffer for action string
const char* action = action_buffer; // default
if (content_json) {
cJSON* action_obj = cJSON_GetObjectItem(content_json, "action");
if (action_obj && cJSON_IsString(action_obj)) {
action = cJSON_GetStringValue(action_obj);
const char* action_str = cJSON_GetStringValue(action_obj);
if (action_str) {
strncpy(action_buffer, action_str, sizeof(action_buffer) - 1);
action_buffer[sizeof(action_buffer) - 1] = '\0';
}
}
cJSON_Delete(content_json);
}
@@ -2248,19 +2253,10 @@ int process_admin_auth_event(cJSON* event, char* error_message, size_t error_siz
printf(" Extracted rule: type='%s', pattern_type='%s', pattern_value='%s'\n",
rule_type, pattern_type, pattern_value);
// Map rule_type to correct action (FIX THE BUG HERE)
const char* mapped_action = "allow"; // default
if (strcmp(rule_type, "pubkey_blacklist") == 0 || strcmp(rule_type, "hash_blacklist") == 0) {
mapped_action = "deny";
} else if (strcmp(rule_type, "pubkey_whitelist") == 0) {
mapped_action = "allow";
}
printf(" Mapped action for rule_type '%s': '%s'\n", rule_type, mapped_action);
// Process the auth rule based on action
if (strcmp(action, "add") == 0) {
printf(" Attempting to add rule to database...\n");
if (add_auth_rule_from_config(rule_type, pattern_type, pattern_value, mapped_action) == 0) {
if (add_auth_rule_from_config(rule_type, pattern_type, pattern_value, "allow") == 0) {
printf(" SUCCESS: Rule added to database\n");
rules_processed++;
} else {