1 /* @(#) $Id: rules_op.h,v 1.3 2009/06/24 17:06:26 dcid Exp $ */
3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 3) as published by the FSF - Free Software
11 * License details at the LICENSE file included with OSSEC or
12 * online at: http://www.ossec.net/en/licensing.html
15 /* Common API for dealing with directory trees */
24 /* Event context - stored on a uint8 */
25 #define SAME_USER 0x001 /* 1 */
26 #define SAME_SRCIP 0x002 /* 2 */
27 #define SAME_ID 0x004 /* 4 */
28 #define SAME_LOCATION 0x008 /* 8 */
29 #define DIFFERENT_URL 0x010 /* */
30 #define SAME_SRCPORT 0x020
31 #define SAME_DSTPORT 0x040
32 #define NOT_SAME_USER 0xffe /* 0xfff - 0x001 */
33 #define NOT_SAME_SRCIP 0xffd /* 0xfff - 0x002 */
34 #define NOT_SAME_ID 0xffb /* 0xfff - 0x004 */
35 #define NOT_SAME_AGENT 0xff7 /* 0xfff - 0x008 */
38 /* Alert options - store on a uint8 */
40 #define DO_MAILALERT 0x002
41 #define DO_LOGALERT 0x004
42 #define NO_ALERT 0x010
43 #define DO_OVERWRITE 0x020
44 #define DO_PACKETINFO 0x040
45 #define DO_EXTRAINFO 0x100
46 #define SAME_EXTRAINFO 0x200
49 /** Types of events (from decoders) **/
50 #define UNKNOWN 0 /* Unkown */
51 #define SYSLOG 1 /* syslog messages */
52 #define IDS 2 /* IDS alerts */
53 #define FIREWALL 3 /* Firewall events */
54 #define WEBLOG 7 /* Apache logs */
55 #define SQUID 8 /* Squid logs */
56 #define WINDOWS 9 /* Windows logs */
57 #define HOST_INFO 10 /* Host information logs (from nmap or similar) */
58 #define OSSEC_RL 11 /* Ossec rules */
61 /* FTS allowed values */
62 #define FTS_NAME 001000
63 #define FTS_USER 002000
64 #define FTS_DSTUSER 004000
65 #define FTS_SRCIP 000100
66 #define FTS_DSTIP 000200
67 #define FTS_LOCATION 000400
69 #define FTS_DATA 000020
70 #define FTS_SYSTEMNAME 000040
75 typedef struct _RuleInfo
77 int sigid; /* id attribute -- required*/
78 int level; /* level attribute --required */
83 u_int8_t context; /* Not an user option */
85 int firedtimes; /* Not an user option */
86 int time_ignored; /* Not an user option */
90 int group_prev_matched_sz;
96 /* Not an option in the rule */
100 u_int16_t context_opts;
106 u_int16_t decoded_as;
108 /* List of previously matched events */
109 OSList *sid_prev_matched;
111 /* Pointer to a list (points to sid_prev_matched of if_matched_sid */
114 /* List of previously matched events in this group.
115 * Every rule that has if_matched_group will have this
116 * list. Every rule that matches this group, it going to
117 * have a pointer to it (group_search).
119 OSList **group_prev_matched;
121 /* Pointer to group_prev_matched */
122 OSList *group_search;
124 /* Function pointer to the event_search. */
125 void *(*event_search)(void *lf, void *rule);
132 /* Policy-based rules */
145 OSMatch *program_name;
149 char *comment; /* description in the xml */
157 OSRegex *if_matched_regex;
158 OSMatch *if_matched_group;
167 int OS_ReadXMLRules(char *rulefile,
168 void *(*ruleact_function)(RuleInfo *rule, void *data),