Debian Codegraph @

src/report_plain.c

raw symbols SCIP
1 /*
2 * AIDE (Advanced Intrusion Detection Environment)
3 *
4 * Copyright (C) 1999-2006, 2010, 2011, 2013, 2015-2016, 2018-2025 Rami Lehti,
5 * Pablo Virolainen, Mike Markley, Richard van den Berg,
6 * Hannes von Haugwitz
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23 #include <stdlib.h>
24 #include "config.h"cxx . . $ `<file>/include/config.h`/
25 #include "aide.h"cxx . . $ `<file>/include/aide.h`/
26 #include "attributes.h"cxx . . $ `<file>/include/attributes.h`/
27 #include "conf_ast.h"cxx . . $ `<file>/include/conf_ast.h`/
28 #include "db.h"cxx . . $ `<file>/include/db.h`/
29 #include "db_config.h"cxx . . $ `<file>/include/db_config.h`/
30 #include "db_line.h"cxx . . $ `<file>/include/db_line.h`/
31 #include "report.h"cxx . . $ `<file>/include/report.h`/
32 #include "seltree.h"cxx . . $ `<file>/include/seltree.h`/
33 #include "stdbool.h"
34 #include "url.h"cxx . . $ `<file>/include/url.h`/
35 #include "locale-aide.h"cxx . . $ `<file>/include/locale-aide.h`/
36
37 #define PLAIN_REPORT_HEADLINE_FMTcxx . . $ `src/report_plain.c:37:9`! "\n\n---------------------------------------------------\n%s:\n---------------------------------------------------\n"
38
39 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! firstcxx . . $ first. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
40
41 static void print_report_dbline_attributes_plaincxx . . $ print_report_dbline_attributes_plain(a3815088d7b5e335).(report_tcxx . . $ report_t# *, db_linecxx . . $ db_line#*, db_linecxx . . $ db_line#*, DB_ATTR_TYPEcxx . . $ `include/attributes.h:25:9`!);
42
43 static char* _get_not_grouped_list_stringcxx . . $ _get_not_grouped_list_string(ec346f625076085b).(report_tcxx . . $ report_t# *report) {
44 if (report->naddcxx . . $ report_t#nadd. && report->nremcxx . . $ report_t#nrem. && report->nchgcxx . . $ report_t#nchg.) { return _cxx . . $ `include/locale-aide.h:33:9`!("Added, removed and changed entries"); }
45 else if (report->naddcxx . . $ report_t#nadd. && report->nremcxx . . $ report_t#nrem.) { return _cxx . . $ `include/locale-aide.h:33:9`!("Added and removed entries"); }
46 else if (report->naddcxx . . $ report_t#nadd. && report->nchgcxx . . $ report_t#nchg.) { return _cxx . . $ `include/locale-aide.h:33:9`!("Added and changed entries"); }
47 else if (report->nremcxx . . $ report_t#nrem. && report->nchgcxx . . $ report_t#nchg.) { return _cxx . . $ `include/locale-aide.h:33:9`!("Removed and changed entries"); }
48 else if (report->naddcxx . . $ report_t#nadd.) { return _cxx . . $ `include/locale-aide.h:33:9`!("Added entries"); }
49 else if (report->nremcxx . . $ report_t#nrem.) { return _cxx . . $ `include/locale-aide.h:33:9`!("Removed entries"); }
50 else { return _cxx . . $ `include/locale-aide.h:33:9`!("Changed entries"); }
51 }
52
53 static void _print_config_optioncxx . . $ _print_config_option(21fa13cc67b7dd0d).(report_tcxx . . $ report_t# *report, config_optioncxx . . $ config_option# option, const char* value) {
54 if (firstcxx . . $ first.) { firstcxx . . $ first.=falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; }
55 else { report_printfcxx . . $ report_printf(4e012a91a5600c6).(report," | "); }
56 char *value_safe = stresccxx . . $ stresc(a8b8e32347182212).(value);
57 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, "%s: %s", config_optionscxx . . $ config_options.[option].report_stringcxx . . $ $anonymous_type_f4816c30b1564b4_0#report_string., value_safe);
58 freecxx . . $ free(5d22bdacc48458e8).(value_safe);
59 }
60
61 static void _print_report_optioncxx . . $ _print_report_option(21fa13cc67b7dd0d).(report_tcxx . . $ report_t# *report, config_optioncxx . . $ config_option# option, const char* value) {
62 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, "%s: %s\n", config_optionscxx . . $ config_options.[option].report_stringcxx . . $ $anonymous_type_f4816c30b1564b4_0#report_string., value);
63 }
64
65 static void _print_attributecxx . . $ _print_attribute(7f3fc18eaf6294aa).(report_tcxx . . $ report_t# *report, db_linecxx . . $ db_line#* oline, db_linecxx . . $ db_line#* nline, ATTRIBUTEcxx . . $ ATTRIBUTE# attribute) {
66 char **ovalues = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
67 char **nvalues = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
68 int onumber, nnumber, i, c;
69 int p = (confcxx . . $ conf.->print_details_widthcxx . . $ db_config#print_details_width.-(4 + MAX_WIDTH_DETAILS_STRINGcxx . . $ `include/attributes.h:89:9`!))/2;
70
71 DB_ATTR_TYPEcxx . . $ `include/attributes.h:25:9`! attr = ATTRcxx . . $ `include/attributes.h:28:9`!(attribute);
72 const char* name = attributescxx . . $ attributes.[attribute].details_stringcxx . . $ $anonymous_type_bb8296fff58edf70_1#details_string.;
73
74 onumber=get_attribute_valuescxx . . $ get_attribute_values(daa3275b1ddcb9d1).(attr, oline, &ovalues, report);
75 nnumber=get_attribute_valuescxx . . $ get_attribute_values(daa3275b1ddcb9d1).(attr, nline, &nvalues, report);
76
77 i = 0;
78 while (i<onumber || i<nnumber) {
79 char *ovalue = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
80 char *nvalue = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
81 int olen = 0;
82 int nlen = 0;
83 if (i<onumber){
84 ovalue = stresccxx . . $ stresc(a8b8e32347182212).(ovalues[i]);
85 olen = strlencxx . . $ strlen(751346f8406fd082).(ovalue);
86 }
87 if (i<nnumber) {
88 nvalue = stresccxx . . $ stresc(a8b8e32347182212).(nvalues[i]);
89 nlen = strlencxx . . $ strlen(751346f8406fd082).(nvalue);
90 }
91 int k = 0;
92 while (olen-p*k >= 0 || nlen-p*k >= 0) {
93 c = k*(p-1);
94 if (!onumber) {
95 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report," %-*s%c %-*c %.*s\n", MAX_WIDTH_DETAILS_STRINGcxx . . $ `include/attributes.h:89:9`!, (i+k)?"":name, (i+k)?' ':':', p, ' ', p-1, nlen-c>0?&nvalue[c]:"");
96 } else if (!nnumber) {
97 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report," %-*s%c %.*s\n", MAX_WIDTH_DETAILS_STRINGcxx . . $ `include/attributes.h:89:9`!, (i+k)?"":name, (i+k)?' ':':', p-1, olen-c>0?&ovalue[c]:"");
98 } else {
99 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report," %-*s%c %-*.*s| %.*s\n", MAX_WIDTH_DETAILS_STRINGcxx . . $ `include/attributes.h:89:9`!, (i+k)?"":name, (i+k)?' ':':', p, p-1, olen-c>0?&ovalue[c]:"", p-1, nlen-c>0?&nvalue[c]:"");
100 }
101 k++;
102 }
103 ++i;
104 freecxx . . $ free(5d22bdacc48458e8).(ovalue);
105 freecxx . . $ free(5d22bdacc48458e8).(nvalue);
106 }
107 for(i=0; i < onumber; ++i) { freecxx . . $ free(5d22bdacc48458e8).(ovalues[i]); ovalues[i]=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; } freecxx . . $ free(5d22bdacc48458e8).(ovalues); ovalues=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
108 for(i=0; i < nnumber; ++i) { freecxx . . $ free(5d22bdacc48458e8).(nvalues[i]); nvalues[i]=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; } freecxx . . $ free(5d22bdacc48458e8).(nvalues); nvalues=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
109 }
110
111 static void _print_database_attributescxx . . $ _print_database_attributes(c89731a28d87173).(report_tcxx . . $ report_t# *report, db_linecxx . . $ db_line#* db) {
112 print_report_dbline_attributes_plaincxx . . $ print_report_dbline_attributes_plain(a3815088d7b5e335).(report, db, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, db->attrcxx . . $ db_line#attr.);
113 }
114
115 static void print_report_outline_plaincxx . . $ print_report_outline_plain(5c5b916f0dae0aa1).(report_tcxx . . $ report_t# *report) {
116 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, "%s\n", get_summary_stringcxx . . $ get_summary_string(ec346f625076085b).(report));
117 }
118
119 static void print_report_new_database_written_plaincxx . . $ print_report_new_database_written_plain(5c5b916f0dae0aa1).(report_tcxx . . $ report_t# *report) {
120 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report,_cxx . . $ `include/locale-aide.h:33:9`!("New AIDE database written to %s\n"),confcxx . . $ conf.->database_outcxx . . $ db_config#database_out..urlcxx . . $ database#url.->valuecxx . . $ url_t#value.);
121 }
122
123 static void print_report_config_options_plaincxx . . $ print_report_config_options_plain(5c5b916f0dae0aa1).(report_tcxx . . $ report_t# *report) {
124 firstcxx . . $ first. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
125 print_report_config_optionscxx . . $ print_report_config_options(8fd66a0c554c67cb).(report, _print_config_optioncxx . . $ _print_config_option(21fa13cc67b7dd0d).);
126 if (!firstcxx . . $ first.) { report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, "\n"); }
127 }
128
129 static void print_report_report_options_plaincxx . . $ print_report_report_options_plain(5c5b916f0dae0aa1).(report_tcxx . . $ report_t# *report) {
130 print_report_report_optionscxx . . $ print_report_report_options(8fd66a0c554c67cb).(report, _print_report_optioncxx . . $ _print_report_option(21fa13cc67b7dd0d).);
131 }
132
133 static void print_report_starttime_version_plaincxx . . $ print_report_starttime_version_plain(bd72d82e8b6e7cd5).(report_tcxx . . $ report_t# *report, const char* start_time, const char* aide_version) {
134 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, _cxx . . $ `include/locale-aide.h:33:9`!("Start timestamp: %s (AIDE %s)\n"), start_time, aide_version);
135 }
136
137 static void print_report_endtime_runtime_plaincxx . . $ print_report_endtime_runtime_plain(112969454c88f9a1).(report_tcxx . . $ report_t#* report, const char* end_time, long run_time) {
138 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, _cxx . . $ `include/locale-aide.h:33:9`!("\n\nEnd timestamp: %s (run time: %ldm %lds)\n"), end_time, run_time/60, run_time%60);
139 }
140
141 static void print_report_summary_plaincxx . . $ print_report_summary_plain(5c5b916f0dae0aa1).(report_tcxx . . $ report_t# *report) {
142 if(confcxx . . $ conf.->actioncxx . . $ db_config#action.&(DO_COMPAREcxx . . $ `include/db_config.h:49:9`!|DO_DIFFcxx . . $ `include/db_config.h:50:9`!) && (report->naddcxx . . $ report_t#nadd.||report->nremcxx . . $ report_t#nrem.||report->nchgcxx . . $ report_t#nchg.)) {
143 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report,_cxx . . $ `include/locale-aide.h:33:9`!("\nSummary:\n Total number of entries:\t%li\n Added entries:\t\t%li\n"
144 " Removed entries:\t\t%li\n Changed entries:\t\t%li"), report->ntotalcxx . . $ report_t#ntotal., report->naddcxx . . $ report_t#nadd., report->nremcxx . . $ report_t#nrem., report->nchgcxx . . $ report_t#nchg.);
145 } else {
146 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, _cxx . . $ `include/locale-aide.h:33:9`!("\nNumber of entries:\t%li"), report->ntotalcxx . . $ report_t#ntotal.);
147 }
148 }
149
150 static void print_line_plaincxx . . $ print_line_plain(77e6edcfaabdcef6).(report_tcxx . . $ report_t#* report, char* filename, int node_checked, seltreecxx . . $ seltree#* node) {
151 char *filename_safe = stresccxx . . $ stresc(a8b8e32347182212).(filename);
152 if(report->summarize_changescxx . . $ report_t#summarize_changes.) {
153 char* summary = get_summarize_changes_stringcxx . . $ get_summarize_changes_string(995b9c65a0e968c6).(report, node);
154 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, "\n%s: %s", summary, filename_safe);
155 freecxx . . $ free(5d22bdacc48458e8).(summary); summary=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
156 } else {
157 if (node_checked&NODE_ADDEDcxx . . $ `include/db.h:60:9`!) {
158 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, _cxx . . $ `include/locale-aide.h:33:9`!("\nadded: %s"), filename_safe);
159 } else if (node_checked&NODE_REMOVEDcxx . . $ `include/db.h:61:9`!) {
160 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, _cxx . . $ `include/locale-aide.h:33:9`!("\nremoved: %s"), filename_safe);
161 } else if (node_checked&NODE_CHANGEDcxx . . $ `include/db.h:62:9`!) {
162 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, _cxx . . $ `include/locale-aide.h:33:9`!("\nchanged: %s"), filename_safe);
163 }
164 }
165 freecxx . . $ free(5d22bdacc48458e8).(filename_safe);
166 }
167
168 static void print_report_dbline_attributes_plaincxx . . $ print_report_dbline_attributes_plain(a3815088d7b5e335).(report_tcxx . . $ report_t# *report, db_linecxx . . $ db_line#* oline, db_linecxx . . $ db_line#* nline, DB_ATTR_TYPEcxx . . $ `include/attributes.h:25:9`! report_attrs) {
169 if (report_attrs) {
170 db_linecxx . . $ db_line#* line = nline==NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!?oline:nline;
171 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, "\n");
172 if (line->permcxx . . $ db_line#perm.) {
173 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, "%s: ", get_file_type_stringcxx . . $ get_file_type_string(f109d7e0a0ca42b3).(line->permcxx . . $ db_line#perm.));
174 }
175 char *filename_safe = stresccxx . . $ stresc(a8b8e32347182212).(line->filenamecxx . . $ db_line#filename.);
176 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, "%s\n", filename_safe);
177 freecxx . . $ free(5d22bdacc48458e8).(filename_safe);
178
179 print_dbline_attrscxx . . $ print_dbline_attrs(74750e9842f268de).(report, oline, nline, report_attrs, _print_attributecxx . . $ _print_attribute(7f3fc18eaf6294aa).);
180 }
181 }
182
183 static void print_report_databases_plaincxx . . $ print_report_databases_plain(5c5b916f0dae0aa1).(report_tcxx . . $ report_t# *report) {
184 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, PLAIN_REPORT_HEADLINE_FMTcxx . . $ `src/report_plain.c:37:9`!,_cxx . . $ `include/locale-aide.h:33:9`!("The attributes of the (uncompressed) database(s)"));
185 print_databases_attrscxx . . $ print_databases_attrs(e6fbbe7f0ff0be64).(report, _print_database_attributescxx . . $ _print_database_attributes(c89731a28d87173).);
186 }
187
188 static void print_report_entries_plaincxx . . $ print_report_entries_plain(87970db00a1cace1).(report_tcxx . . $ report_t# *report, seltreecxx . . $ seltree#* node, const int filter) {
189 switch (filter) {
190 case NODE_ADDEDcxx . . $ `include/db.h:60:9`!:
191 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, PLAIN_REPORT_HEADLINE_FMTcxx . . $ `src/report_plain.c:37:9`!,_cxx . . $ `include/locale-aide.h:33:9`!("Added entries"));
192 break;
193 case NODE_REMOVEDcxx . . $ `include/db.h:61:9`!:
194 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, PLAIN_REPORT_HEADLINE_FMTcxx . . $ `src/report_plain.c:37:9`!,_cxx . . $ `include/locale-aide.h:33:9`!("Removed entries"));
195 break;
196 case NODE_CHANGEDcxx . . $ `include/db.h:62:9`!:
197 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, PLAIN_REPORT_HEADLINE_FMTcxx . . $ `src/report_plain.c:37:9`!,_cxx . . $ `include/locale-aide.h:33:9`!("Changed entries"));
198 break;
199 default:
200 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, PLAIN_REPORT_HEADLINE_FMTcxx . . $ `src/report_plain.c:37:9`!, _get_not_grouped_list_stringcxx . . $ _get_not_grouped_list_string(ec346f625076085b).(report));
201 break;
202 }
203 print_report_entriescxx . . $ print_report_entries(f8d8678ee3db360e).(report, node, filter, print_line_plaincxx . . $ print_line_plain(77e6edcfaabdcef6).);
204 }
205
206 static void print_report_details_plaincxx . . $ print_report_details_plain(3a601c4c6d2db327).(report_tcxx . . $ report_t# *report, seltreecxx . . $ seltree#* node) {
207 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, PLAIN_REPORT_HEADLINE_FMTcxx . . $ `src/report_plain.c:37:9`!,_cxx . . $ `include/locale-aide.h:33:9`!("Detailed information about changes"));
208 print_report_detailscxx . . $ print_report_details(c1b9a86155df1be7).(report, node, print_report_dbline_attributes_plaincxx . . $ print_report_dbline_attributes_plain(a3815088d7b5e335).);
209 }
210
211 static void print_report_diff_attrs_entries_plaincxx . . $ print_report_diff_attrs_entries_plain(5c5b916f0dae0aa1).(report_tcxx . . $ report_t# *report) {
212 for(int i = 0; i < report->num_diff_attrs_entriescxx . . $ report_t#num_diff_attrs_entries.; ++i) {
213 char *str = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
214 char *entry_safe = stresccxx . . $ stresc(a8b8e32347182212).(report->diff_attrs_entriescxx . . $ report_t#diff_attrs_entries.[i].entrycxx . . $ diff_attrs_entry#entry.);
215 report_printfcxx . . $ report_printf(4e012a91a5600c6).(report, "Entry %s in databases has different attributes: %s\n",
216 entry_safe,
217 str= diff_attributescxx . . $ diff_attributes(39cd1df6f24d7ad6).(report->diff_attrs_entriescxx . . $ report_t#diff_attrs_entries.[i].old_attrscxx . . $ diff_attrs_entry#old_attrs., report->diff_attrs_entriescxx . . $ report_t#diff_attrs_entries.[i].new_attrscxx . . $ diff_attrs_entry#new_attrs.));
218 freecxx . . $ free(5d22bdacc48458e8).(entry_safe);
219 freecxx . . $ free(5d22bdacc48458e8).(str);
220 }
221 report->num_diff_attrs_entriescxx . . $ report_t#num_diff_attrs_entries. = 0;
222 freecxx . . $ free(5d22bdacc48458e8).(report->diff_attrs_entriescxx . . $ report_t#diff_attrs_entries.);
223 }
224
225 report_format_modulecxx . . $ report_format_module# report_module_plaincxx . . $ report_module_plain. = {
226 .print_report_config_options = print_report_config_options_plaincxx . . $ print_report_config_options_plain(5c5b916f0dae0aa1).,
227 .print_report_databases = print_report_databases_plaincxx . . $ print_report_databases_plain(5c5b916f0dae0aa1).,
228 .print_report_details = print_report_details_plaincxx . . $ print_report_details_plain(3a601c4c6d2db327).,
229 .print_report_diff_attrs_entries = print_report_diff_attrs_entries_plaincxx . . $ print_report_diff_attrs_entries_plain(5c5b916f0dae0aa1).,
230 .print_report_endtime_runtime = print_report_endtime_runtime_plaincxx . . $ print_report_endtime_runtime_plain(112969454c88f9a1).,
231 .print_report_entries = print_report_entries_plaincxx . . $ print_report_entries_plain(87970db00a1cace1).,
232 .print_report_footer = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
233 .print_report_header = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
234 .print_report_new_database_written = print_report_new_database_written_plaincxx . . $ print_report_new_database_written_plain(5c5b916f0dae0aa1).,
235 .print_report_outline = print_report_outline_plaincxx . . $ print_report_outline_plain(5c5b916f0dae0aa1).,
236 .print_report_report_options = print_report_report_options_plaincxx . . $ print_report_report_options_plain(5c5b916f0dae0aa1).,
237 .print_report_starttime_version = print_report_starttime_version_plaincxx . . $ print_report_starttime_version_plain(bd72d82e8b6e7cd5).,
238 .print_report_summary = print_report_summary_plaincxx . . $ print_report_summary_plain(5c5b916f0dae0aa1).,
239 };