-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
anonymizer: option to skip SRC_IP (-S)/DST_IP (-D)
Two optional parameters were added to skip anonymization of SRC_IP (option -S) or DST_IP (option -D). Example to leave SRC_IP without any modification: /usr/bin/nemea/anonymizer -i u:input,u:output -S Example to leave both SRC_IP and DST_IP without any modification: /usr/bin/nemea/anonymizer -i u:input,u:output -S -D
- Loading branch information
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,11 @@ | |
* \author Tomas Jansky <[email protected]> | ||
* \author Martin Zadnik <[email protected]> | ||
* \author Tomas Cejka <[email protected]> | ||
* \date 2024 | ||
* \date 2017 | ||
*/ | ||
/* | ||
* Copyright (C) 2013-2018 CESNET | ||
* Copyright (C) 2013-2024 CESNET | ||
* | ||
* LICENSE TERMS | ||
* | ||
|
@@ -71,10 +72,15 @@ trap_module_info_t *module_info = NULL; | |
PARAM('k', "key", "Specify secret key, the key must be 32 characters long string or 32B sized hex string starting with 0x", required_argument, "string") \ | ||
PARAM('f', "file", "Specify file containing secret key, the key must be 32 characters long string or 32B sized hex string starting with 0x", required_argument, "string") \ | ||
PARAM('M', "murmur", "Use MurmurHash3 instead of Rijndael cipher.", no_argument, "none") \ | ||
PARAM('S', "srcip", "Disable anonymization of SRC_IP.", no_argument, "none") \ | ||
PARAM('D', "dstip", "Disable anonymization of DST_IP.", no_argument, "none") \ | ||
PARAM('d', "de-anonym", "Switch to de-anonymization mode.", no_argument, "none") | ||
|
||
static int stop = 0; | ||
|
||
static int disable_src_ip = 0; | ||
static int disable_dst_ip = 0; | ||
|
||
TRAP_DEFAULT_SIGNAL_HANDLER(stop = 1); | ||
|
||
const char *anon_field_names[] = {"SRC_IP", "DST_IP", "SIP_CALLED_PARTY", "SIP_CALLING_PARTY", "SIP_CALL_ID", "SIP_REQUEST_URI", "SIP_VIA"}; | ||
|
@@ -331,6 +337,13 @@ int set_fields_present(ur_template_t *tmplt) | |
int j = 0; | ||
|
||
for (i = 0; i < ANON_FIELDS_COUNT; i++) { | ||
// check skip flags for src_ip and dst_ip (-S / -D) and skip these fields | ||
if (disable_src_ip == 1 && strncmp(anon_field_names[i], "SRC_IP", 7) == 0) { | ||
continue; | ||
} | ||
if (disable_dst_ip == 1 && strncmp(anon_field_names[i], "DST_IP", 7) == 0) { | ||
continue; | ||
} | ||
anon_fields[j] = ur_get_id_by_name(anon_field_names[i]); | ||
if (anon_fields[j] != UR_E_INVALID_NAME && ur_is_present(tmplt, anon_fields[j])) { | ||
j++; | ||
|
@@ -415,6 +428,12 @@ int main(int argc, char **argv) | |
case 'd': | ||
mode = DEANONYMIZATION; | ||
break; | ||
case 'S': | ||
disable_src_ip = 1; | ||
break; | ||
case 'D': | ||
disable_dst_ip = 1; | ||
break; | ||
default: | ||
fprintf(stderr, "Invalid arguments.\n"); | ||
ret = 1; | ||
|