Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syscollector decoder #461

Merged
merged 2 commits into from
Mar 21, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions etc/rules/0016-wazuh_rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,10 @@
<group>agent_restarting,configuration_failure,</group>
</rule>

<!-- Ignore syscollector events -->
<rule id="221" level="0">
<decoded_as>syscollector</decoded_as>
<description>Syscollector event.</description>
</rule>

</group>
3 changes: 3 additions & 0 deletions src/analysisd/analysisd.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,9 @@ void OS_ReadMSG_analysisd(int m_queue)
/* Initialize Rootcheck */
RootcheckInit();

/* Initialize Syscollector */
SyscollectorInit();

/* Initialize host info */
HostinfoInit();

Expand Down
1 change: 1 addition & 0 deletions src/analysisd/decoders/decode-xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ int SetDecodeXML()
addDecoder2list(SYSCHECK_DEL);
addDecoder2list(HOSTINFO_NEW);
addDecoder2list(HOSTINFO_MOD);
addDecoder2list(SYSCOLLECTOR_MOD);

/* Set ids - for our two lists */
if (!os_setdecoderids(NULL)) {
Expand Down
1 change: 1 addition & 0 deletions src/analysisd/decoders/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ int SetDecodeXML(void);
void HostinfoInit(void);
void SyscheckInit(void);
void RootcheckInit(void);
void SyscollectorInit(void);

int ReadDecodeXML(const char *file);

Expand Down
15 changes: 15 additions & 0 deletions src/analysisd/decoders/syscollector.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ static int decode_program(char *agent_id, cJSON * logJSON);
static int decode_port(char *agent_id, cJSON * logJSON);
static int decode_process(char *agent_id, cJSON * logJSON);

static OSDecoderInfo *sysc_decoder = NULL;

void SyscollectorInit(){

os_calloc(1, sizeof(OSDecoderInfo), sysc_decoder);
sysc_decoder->id = getDecoderfromlist(SYSCOLLECTOR_MOD);
sysc_decoder->name = SYSCOLLECTOR_MOD;
sysc_decoder->type = OSSEC_RL;
sysc_decoder->fts = 0;

mdebug1("SyscollectorInit completed.");
}

/* Special decoder for syscollector */
int DecodeSyscollector(Eventinfo *lf)
{
Expand All @@ -39,6 +52,8 @@ int DecodeSyscollector(Eventinfo *lf)
// Decoding JSON
JSON_Decoder_Exec(lf);

lf->decoder_info = sysc_decoder;

// Check location
if (lf->location[0] == '(') {
char* search;
Expand Down
17 changes: 9 additions & 8 deletions src/analysisd/rules.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,15 @@ int _setlevels(RuleNode *node, int nnode);
#define SYSCHECK_MODULE 13
#define HOSTINFO_MODULE 15

#define ROOTCHECK_MOD "rootcheck"
#define HOSTINFO_NEW "hostinfo_new"
#define HOSTINFO_MOD "hostinfo_modified"
#define SYSCHECK_MOD "syscheck_integrity_changed"
#define SYSCHECK_MOD2 "syscheck_integrity_changed_2nd"
#define SYSCHECK_MOD3 "syscheck_integrity_changed_3rd"
#define SYSCHECK_NEW "syscheck_new_entry"
#define SYSCHECK_DEL "syscheck_deleted"
#define ROOTCHECK_MOD "rootcheck"
#define HOSTINFO_NEW "hostinfo_new"
#define HOSTINFO_MOD "hostinfo_modified"
#define SYSCHECK_MOD "syscheck_integrity_changed"
#define SYSCHECK_MOD2 "syscheck_integrity_changed_2nd"
#define SYSCHECK_MOD3 "syscheck_integrity_changed_3rd"
#define SYSCHECK_NEW "syscheck_new_entry"
#define SYSCHECK_DEL "syscheck_deleted"
#define SYSCOLLECTOR_MOD "syscollector"

/* Global variables */
extern int _max_freq;
Expand Down