1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
|
/*
* AIDE (Advanced Intrusion Detection Environment)
*
* Copyright (C) 2019-2022 Hannes von Haugwitz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _CONF_AST_H_INCLUDED
#define _CONF_AST_H_INCLUDED
#include <stdbool.h>
#include "rx_rule.h"
typedef enum config_option {
ACL_NO_SYMLINK_FOLLOW_OPTION,
DATABASE_ADD_METADATA_OPTION,
DATABASE_ATTRIBUTES_OPTION,
DATABASE_GZIP_OPTION,
DATABASE_IN_OPTION,
DATABASE_OUT_OPTION,
DATABASE_NEW_OPTION,
LOG_LEVEL_OPTION,
REPORT_BASE16_OPTION,
REPORT_DETAILED_INIT_OPTION,
REPORT_FORCE_ATTRS_OPTION,
REPORT_GROUPED_OPTION,
REPORT_IGNORE_ADDED_ATTRS_OPTION,
REPORT_IGNORE_REMOVED_ATTRS_OPTION,
REPORT_IGNORE_CHANGED_ATTRS_OPTION,
REPORT_IGNORE_E2FSATTRS_OPTION,
REPORT_LEVEL_OPTION,
REPORT_QUIET_OPTION,
REPORT_APPEND_OPTION,
REPORT_SUMMARIZE_CHANGES_OPTION,
REPORT_URL_OPTION,
ROOT_PREFIX_OPTION,
WARN_DEAD_SYMLINKS_OPTION,
VERBOSE_OPTION,
CONFIG_VERSION,
CONFIG_CHECK_WARN_UNRESTRICTED_RULES,
REPORT_FORMAT_OPTION,
LIMIT_CMDLINE_OPTION,
NUM_WORKERS,
} config_option;
typedef struct {
config_option option;
char *config_name;
char *report_string;
} config_option_t;
extern config_option_t config_options[];
typedef enum attribute_operator {
ATTR_OP_PLUS = 0,
ATTR_OP_MINUS,
ATTR_OP_GROUP,
} attribute_operator;
typedef struct attribute_expression {
attribute_operator op;
struct attribute_expression* left;
char* right;
} attribute_expression;
typedef enum string_operator {
STR_OP_STR,
STR_OP_VARIABLE,
STR_OP_CONCAT,
} string_operator;
typedef struct string_expression {
string_operator op;
char* str;
struct string_expression* left;
struct string_expression* right;
} string_expression;
typedef struct config_option_statement {
config_option option;
attribute_expression *a;
string_expression* e;
} config_option_statement;
typedef enum bool_operator {
BOOL_OP_NOT,
BOOL_OP_DEFINED,
BOOL_OP_HOSTNAME,
BOOL_OP_EXISTS,
} bool_operator;
typedef struct bool_expression {
bool_operator op;
string_expression* expr;
struct bool_expression* left;
struct bool_expression* right;
} bool_expression;
typedef struct if_condition {
bool_expression* expression;
int linenumber;
char *filename;
char* linebuf;
} if_condition;
typedef struct if_statement {
struct if_condition* condition;
struct ast* if_branch;
struct ast* else_branch;
} if_statement;
typedef struct define_statement {
char *name;
string_expression *value;
} define_statement;
typedef struct include_statement {
string_expression *path;
string_expression *rx;
bool execute;
string_expression *prefix;
} include_statement;
typedef struct x_include_setenv_statement {
char *variable;
string_expression *value;
} x_include_setenv_statement;
typedef struct undefine_statement {
char *name;
} undefine_statement;
typedef struct group_statement {
char *name;
attribute_expression *expr;
} group_statement;
typedef struct restriction_expression {
char* right;
struct restriction_expression* left;
} restriction_expression;
typedef struct rule_statement {
AIDE_RULE_TYPE type;
string_expression *path;
restriction_expression *restriction;
attribute_expression *attributes;
} rule_statement;
typedef struct ast {
enum {
config_option_type,
include_statement_type,
x_include_setenv_statement_type,
define_statement_type,
undefine_statement_type,
group_statement_type,
if_statement_type,
rule_statement_type,
} type;
union {
config_option_statement _config;
include_statement _include;
x_include_setenv_statement _x_include_setenv;
define_statement _define;
undefine_statement _undefine;
group_statement _group;
if_statement _if;
rule_statement _rule;
} statement;
int linenumber;
char *filename;
char* linebuf;
struct ast* next;
} ast;
string_expression* new_string(char*);
string_expression* new_variable(char*);
string_expression* new_string_concat(string_expression*, string_expression*);
ast* new_string_option_statement(config_option, string_expression*);
ast* new_attribute_option_statement(config_option, attribute_expression*);
ast* new_define_statement(char*, string_expression*);
ast* new_undefine_statement(char*);
ast* new_group_statement(char*, attribute_expression*);
ast* new_include_statement(string_expression*, string_expression*, bool, string_expression*);
ast* new_x_include_setenv_statement(char*, string_expression*);
ast* new_if_statement(struct if_condition*, struct ast*, struct ast*);
ast* new_rule_statement(AIDE_RULE_TYPE, string_expression*, restriction_expression*, attribute_expression*);
if_condition* new_if_condition(struct bool_expression*);
bool_expression* new_string_bool_expression(bool_operator, string_expression*);
bool_expression* new_bool_expression(bool_operator, bool_expression*, bool_expression*);
attribute_expression* new_attribute_expression(attribute_operator, attribute_expression*, char*);
restriction_expression* new_restriction_expression(restriction_expression*, char*);
void deep_free(ast*);
#endif
|