summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/mmanon.html6
-rw-r--r--doc/rsyslog_conf_modules.html8
-rw-r--r--plugins/mmanon/mmanon.c54
3 files changed, 53 insertions, 15 deletions
diff --git a/doc/mmanon.html b/doc/mmanon.html
index 23aa8446..b8691247 100644
--- a/doc/mmanon.html
+++ b/doc/mmanon.html
@@ -22,7 +22,11 @@ such exists.
<p>Currently none.
<p>&nbsp;</p>
<p><b>Action Confguration Parameters</b>:</p>
-<p>Currently none.
+<ul>
+<li><b>replacementChar</b><br>In simple mode, this sets the character
+that the to-be-anonymized part of the IP address is to be overwritten
+with. The default is "x".
+</ul>
<p><b>Caveats/Known Bugs:</b>
<ul>
diff --git a/doc/rsyslog_conf_modules.html b/doc/rsyslog_conf_modules.html
index 4a688352..554b20f4 100644
--- a/doc/rsyslog_conf_modules.html
+++ b/doc/rsyslog_conf_modules.html
@@ -101,16 +101,14 @@ They can be implemented using either the output module or the parser module inte
From the rsyslog core's point of view, they actually are output or parser modules, it is their
implementation that makes them special.
<p>Currently, there exists only a limited set of such modules, but new ones could be written with
-the methods the engine provides. They could be used, for example, to:
-<ul>
-<li>anonymize message content
-<li>add dynamically computed content to message (fields)
-</ul>
+the methods the engine provides. They could be used, for example, to
+add dynamically computed content to message (fields).
<p>Message modification modules are usually written for one specific task and thus
usually are not generic enough to be reused. However, existing module's code is
probably an excellent starting base for writing a new module. Currently, the following
modules exist inside the source tree:
<ul>
+<li><a href="mmanon.html">mmanon</a> - used to anonymize log messages.
<li><a href="mmnormalize.html">mmnormalize</a> - used to normalize log messages.
Note that this actually is a <b>generic</b> module.
<li><a href="mmjsonparse.html">mmjsonparse</a> - used to interpret CEE/lumberjack
diff --git a/plugins/mmanon/mmanon.c b/plugins/mmanon/mmanon.c
index 90e7fc81..f84cc8e9 100644
--- a/plugins/mmanon/mmanon.c
+++ b/plugins/mmanon/mmanon.c
@@ -48,6 +48,7 @@ DEF_OMOD_STATIC_DATA
typedef struct _instanceData {
+ char replChar;
} instanceData;
struct modConfData_s {
@@ -56,6 +57,18 @@ struct modConfData_s {
static modConfData_t *loadModConf = NULL;/* modConf ptr to use for the current load process */
static modConfData_t *runModConf = NULL;/* modConf ptr to use for the current exec process */
+
+/* tables for interfacing with the v6 config system */
+/* action (instance) parameters */
+static struct cnfparamdescr actpdescr[] = {
+ { "replacementchar", eCmdHdlrGetChar, 0 },
+};
+static struct cnfparamblk actpblk =
+ { CNFPARAMBLK_VERSION,
+ sizeof(actpdescr)/sizeof(struct cnfparamdescr),
+ actpdescr
+ };
+
BEGINbeginCnfLoad
CODESTARTbeginCnfLoad
loadModConf = pModConf;
@@ -95,19 +108,42 @@ CODESTARTfreeInstance
ENDfreeInstance
+static inline void
+setInstParamDefaults(instanceData *pData)
+{
+ pData->replChar = 'x';
+}
+
BEGINnewActInst
+ struct cnfparamvals *pvals;
+ int i;
CODESTARTnewActInst
- /* Note: we currently do not have any parameters, so we do not need
- * the lst ptr. However, we will most probably need params in the
- * future.
- */
DBGPRINTF("newActInst (mmanon)\n");
+ if((pvals = nvlstGetParams(lst, &actpblk, NULL)) == NULL) {
+ ABORT_FINALIZE(RS_RET_MISSING_CNFPARAMS);
+ }
+
CODE_STD_STRING_REQUESTnewActInst(1)
CHKiRet(OMSRsetEntry(*ppOMSR, 0, NULL, OMSR_TPL_AS_MSG));
CHKiRet(createInstance(&pData));
- /*setInstParamDefaults(pData);*/
+ setInstParamDefaults(pData);
+
+ for(i = 0 ; i < actpblk.nParams ; ++i) {
+ if(!pvals[i].bUsed)
+ continue;
+ if(!strcmp(actpblk.descr[i].name, "replacementchar")) {
+ pData->replChar = es_getBufAddr(pvals[i].val.d.estr)[0];
+ //pData->replChar = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
+ //} else if(!strcmp(actpblk.descr[i].name, "serverport")) {
+ // pData->port = (int) pvals[i].val.d.n;
+ } else {
+ dbgprintf("mmanon: program error, non-handled "
+ "param '%s'\n", actpblk.descr[i].name);
+ }
+ }
+
CODE_STD_FINALIZERnewActInst
-/* cnfparamvalsDestruct(pvals, &actpblk);*/
+ cnfparamvalsDestruct(pvals, &actpblk);
ENDnewActInst
@@ -141,7 +177,7 @@ dbgprintf("DDDD: got octet %d\n", num);
/* currently works for IPv4 only! */
void
-anonip(uchar *msg, int lenMsg, int *idx)
+anonip(instanceData *pData, uchar *msg, int lenMsg, int *idx)
{
int i = *idx;
int octet;
@@ -171,7 +207,7 @@ dbgprintf("DDDD: in anonip: %s\n", msg+(*idx));
/* OK, we now found an ip address */
while(ipstart < i) {
if(msg[ipstart] != '.')
- msg[ipstart] = 'x';
+ msg[ipstart] = pData->replChar;
++ipstart;
}
@@ -191,7 +227,7 @@ CODESTARTdoAction
msg = getMSG(pMsg);
DBGPRINTF("DDDD: calling mmanon with msg '%s'\n", msg);
for(i = 0 ; i < lenMsg ; ++i) {
- anonip(msg, lenMsg, &i);
+ anonip(pData, msg, lenMsg, &i);
}
ENDdoAction