Welcome to mirror list, hosted at ThFree Co, Russian Federation.

audit_httptest.c « zbxaudit « libs « src - github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4db08cec07b49cbddf4b3db838a92c9ce08d83ec (plain)
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
/*
** Zabbix
** Copyright (C) 2001-2021 Zabbix SIA
**
** 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.
**/

#include "dbcache.h"

#include "log.h"
#include "audit_httptest.h"

void	zbx_audit_httptest_create_entry(int audit_action, zbx_uint64_t httptestid, const char *name)
{
	zbx_audit_entry_t	local_audit_httptest_entry, **found_audit_httptest_entry;
	zbx_audit_entry_t	*local_audit_httptest_entry_x = &local_audit_httptest_entry;

	RETURN_IF_AUDIT_OFF();

	local_audit_httptest_entry.id = httptestid;
	local_audit_httptest_entry.cuid = NULL;
	local_audit_httptest_entry.id_table = AUDIT_HTTPTEST_ID;

	found_audit_httptest_entry = (zbx_audit_entry_t**)zbx_hashset_search(zbx_get_audit_hashset(),
			&(local_audit_httptest_entry_x));

	if (NULL == found_audit_httptest_entry)
	{
		zbx_audit_entry_t	*local_audit_httptest_entry_insert;

		local_audit_httptest_entry_insert = zbx_audit_entry_init(httptestid, AUDIT_HTTPTEST_ID, name,
				audit_action, AUDIT_RESOURCE_SCENARIO);

		zbx_hashset_insert(zbx_get_audit_hashset(), &local_audit_httptest_entry_insert,
				sizeof(local_audit_httptest_entry_insert));
	}
}

void	zbx_audit_httptest_update_json_add_data(zbx_uint64_t httptestid, zbx_uint64_t templateid, const char *name,
		const char *delay, unsigned char status, const char *agent, unsigned char authentication,
		const char *httpuser, const char *httppassword, const char *http_proxy, int retries,
		const char *ssl_cert_file, const char *ssl_key_file, const char *ssl_key_password, int verify_peer,
		int verify_host, zbx_uint64_t hostid)
{
	char	audit_key_templateid[AUDIT_DETAILS_KEY_LEN], audit_key_name[AUDIT_DETAILS_KEY_LEN],
		audit_key_delay[AUDIT_DETAILS_KEY_LEN], audit_key_status[AUDIT_DETAILS_KEY_LEN],
		audit_key_agent[AUDIT_DETAILS_KEY_LEN], audit_key_authentication[AUDIT_DETAILS_KEY_LEN],
		audit_key_httpuser[AUDIT_DETAILS_KEY_LEN], audit_key_http_proxy[AUDIT_DETAILS_KEY_LEN],
		audit_key_retries[AUDIT_DETAILS_KEY_LEN], audit_key_ssl_cert_file[AUDIT_DETAILS_KEY_LEN],
		audit_key_ssl_key_file[AUDIT_DETAILS_KEY_LEN], audit_key_verify_peer[AUDIT_DETAILS_KEY_LEN],
		audit_key_verify_host[AUDIT_DETAILS_KEY_LEN], audit_key_hostid[AUDIT_DETAILS_KEY_LEN];

	RETURN_IF_AUDIT_OFF();

#define AUDIT_KEY_SNPRINTF(r) zbx_snprintf(audit_key_##r, sizeof(audit_key_##r), "httptest."#r);
#define AUDIT_TABLE_NAME	"httptest"
	zbx_audit_update_json_append_uint64(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD,
			"httptest.httptestid", httptestid, AUDIT_TABLE_NAME, "httptestid");
	AUDIT_KEY_SNPRINTF(templateid)
	AUDIT_KEY_SNPRINTF(name)
	AUDIT_KEY_SNPRINTF(delay)
	AUDIT_KEY_SNPRINTF(status)
	AUDIT_KEY_SNPRINTF(agent)
	AUDIT_KEY_SNPRINTF(authentication)
	AUDIT_KEY_SNPRINTF(httpuser)
	AUDIT_KEY_SNPRINTF(http_proxy)
	AUDIT_KEY_SNPRINTF(retries)
	AUDIT_KEY_SNPRINTF(ssl_cert_file)
	AUDIT_KEY_SNPRINTF(ssl_key_file)
	AUDIT_KEY_SNPRINTF(verify_peer)
	AUDIT_KEY_SNPRINTF(verify_host)
	AUDIT_KEY_SNPRINTF(hostid)
#undef AUDIT_KEY_SNPRINTF
#define ADD_STR(r, t, f) zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, \
		audit_key_##r, r, t, f);
#define ADD_UINT64(r, t, f) zbx_audit_update_json_append_uint64(httptestid, AUDIT_HTTPTEST_ID, \
		AUDIT_DETAILS_ACTION_ADD, audit_key_##r, r, t, f);
#define ADD_INT(r, t, f) zbx_audit_update_json_append_int(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, \
		audit_key_##r, r, t, f);
	ADD_UINT64(templateid, AUDIT_TABLE_NAME, "templateid")
	ADD_STR(name, AUDIT_TABLE_NAME, "name")
	ADD_STR(delay, AUDIT_TABLE_NAME, "delay")
	ADD_INT(status, AUDIT_TABLE_NAME, "status")
	ADD_STR(agent, AUDIT_TABLE_NAME, "agent")
	ADD_INT(authentication, AUDIT_TABLE_NAME, "authentication")
	ADD_STR(httpuser, AUDIT_TABLE_NAME, "http_user")
	zbx_audit_update_json_append_string_secret(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD,
			"httptest.httppassword", httppassword, AUDIT_TABLE_NAME, "http_password");
	ADD_STR(http_proxy, AUDIT_TABLE_NAME, "http_proxy")
	ADD_INT(retries, AUDIT_TABLE_NAME, "retries")
	ADD_STR(ssl_cert_file, AUDIT_TABLE_NAME, "ssl_cert_file")
	ADD_STR(ssl_key_file, AUDIT_TABLE_NAME, "ssl_key_file")
	zbx_audit_update_json_append_string_secret(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD,
			"httptest.ssl_key_password", ssl_key_password, AUDIT_TABLE_NAME, "ssl_key_password");
	ADD_INT(verify_peer, AUDIT_TABLE_NAME, "verify_peer")
	ADD_INT(verify_host, AUDIT_TABLE_NAME, "verify_host")
	ADD_UINT64(hostid, AUDIT_TABLE_NAME, "hostid")
#undef AUDIT_TABLE_NAME
#undef ADD_STR
#undef ADD_UINT64
#undef ADD_INT
}

#define PREPARE_AUDIT_HTTPTEST_UPDATE(resource, type1, type2)							\
void	zbx_audit_httptest_update_json_update_##resource(zbx_uint64_t httptestid, type1 resource##_old,		\
		type1 resource##_new)										\
{														\
	char	buf[AUDIT_DETAILS_KEY_LEN];									\
														\
	RETURN_IF_AUDIT_OFF();											\
														\
	zbx_snprintf(buf, sizeof(buf), "httptest."#resource);							\
														\
	zbx_audit_update_json_update_##type2(httptestid, AUDIT_HTTPTEST_ID, buf, resource##_old,		\
			resource##_new);									\
}

PREPARE_AUDIT_HTTPTEST_UPDATE(templateid, zbx_uint64_t, uint64)
PREPARE_AUDIT_HTTPTEST_UPDATE(delay, const char*, string)
PREPARE_AUDIT_HTTPTEST_UPDATE(agent, const char*, string)
PREPARE_AUDIT_HTTPTEST_UPDATE(http_user, const char*, string)
PREPARE_AUDIT_HTTPTEST_UPDATE(http_password, const char*, string)
PREPARE_AUDIT_HTTPTEST_UPDATE(http_proxy, const char*, string)
PREPARE_AUDIT_HTTPTEST_UPDATE(retries, int, int)
PREPARE_AUDIT_HTTPTEST_UPDATE(status, int, int)
PREPARE_AUDIT_HTTPTEST_UPDATE(authentication, int, int)
PREPARE_AUDIT_HTTPTEST_UPDATE(ssl_cert_file, const char*, string)
PREPARE_AUDIT_HTTPTEST_UPDATE(ssl_key_file, const char*, string)
PREPARE_AUDIT_HTTPTEST_UPDATE(ssl_key_password, const char*, string)
PREPARE_AUDIT_HTTPTEST_UPDATE(verify_peer, int, int)
PREPARE_AUDIT_HTTPTEST_UPDATE(verify_host, int, int)

#undef PREPARE_AUDIT_HTTPTEST_UPDATE

int	zbx_audit_DBselect_delete_for_httptest(const char *sql, zbx_vector_uint64_t *ids)
{
	DB_RESULT	result;
	DB_ROW		row;

	if (NULL == (result = DBselect("%s", sql)))
		return FAIL;

	while (NULL != (row = DBfetch(result)))
	{
		zbx_uint64_t	id;

		ZBX_STR2UINT64(id, row[0]);
		zbx_vector_uint64_append(ids, id);

		zbx_audit_httptest_create_entry(AUDIT_ACTION_DELETE, id, row[1]);
	}

	DBfree_result(result);

	zbx_vector_uint64_sort(ids, ZBX_DEFAULT_UINT64_COMPARE_FUNC);

	return SUCCEED;
}

void	zbx_audit_httptest_update_json_add_httptest_tag(zbx_uint64_t httptestid, zbx_uint64_t tagid, const char *tag,
		const char *value)
{
	char	audit_key[AUDIT_DETAILS_KEY_LEN], audit_key_tag[AUDIT_DETAILS_KEY_LEN],
		audit_key_value[AUDIT_DETAILS_KEY_LEN];

	RETURN_IF_AUDIT_OFF();

	zbx_snprintf(audit_key, sizeof(audit_key), "httptest.tags[" ZBX_FS_UI64 "]", tagid);
	zbx_snprintf(audit_key_tag, sizeof(audit_key_tag), "httptest.tags[" ZBX_FS_UI64 "].tag", tagid);
	zbx_snprintf(audit_key_value, sizeof(audit_key_value), "httptest.tags[" ZBX_FS_UI64 "].value", tagid);

#define AUDIT_TABLE_NAME	"httptest_tag"
	zbx_audit_update_json_append_no_value(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
	zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_tag,
			tag, AUDIT_TABLE_NAME, "tag");
	zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_value,
			value, AUDIT_TABLE_NAME, "value");
#undef AUDIT_TABLE_NAME
}

void	zbx_audit_httptest_update_json_delete_tags(zbx_uint64_t httptestid, zbx_uint64_t tagid)
{
	char	buf[AUDIT_DETAILS_KEY_LEN];

	RETURN_IF_AUDIT_OFF();

	zbx_snprintf(buf, sizeof(buf), "httptest.tags[" ZBX_FS_UI64 "]", tagid);

	zbx_audit_update_json_append_no_value(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_DELETE, buf);
}

void	zbx_audit_httptest_update_json_add_httptest_httpstep(zbx_uint64_t httptestid, zbx_uint64_t httpstepid,
		const char *name, int no, const char *url, const char *timeout, const char *posts, const char *required,
		const char *status_codes, int follow_redirects, int retrieve_mode, int post_type)
{
	char	audit_key[AUDIT_DETAILS_KEY_LEN], audit_key_name[AUDIT_DETAILS_KEY_LEN],
		audit_key_no[AUDIT_DETAILS_KEY_LEN], audit_key_url[AUDIT_DETAILS_KEY_LEN],
		audit_key_timeout[AUDIT_DETAILS_KEY_LEN], audit_key_posts[AUDIT_DETAILS_KEY_LEN],
		audit_key_required[AUDIT_DETAILS_KEY_LEN], audit_key_status_codes[AUDIT_DETAILS_KEY_LEN],
		audit_key_follow_redirects[AUDIT_DETAILS_KEY_LEN], audit_key_retrieve_mode[AUDIT_DETAILS_KEY_LEN],
		audit_key_post_type[AUDIT_DETAILS_KEY_LEN];

	RETURN_IF_AUDIT_OFF();

	zbx_snprintf(audit_key, sizeof(audit_key), "httptest.steps[" ZBX_FS_UI64 "]", httpstepid);
	zbx_snprintf(audit_key_name, sizeof(audit_key_name), "httptest.steps[" ZBX_FS_UI64 "].name", httpstepid);
	zbx_snprintf(audit_key_no, sizeof(audit_key_no), "httptest.steps[" ZBX_FS_UI64 "].no", httpstepid);
	zbx_snprintf(audit_key_url, sizeof(audit_key_url), "httptest.steps[" ZBX_FS_UI64 "].url", httpstepid);
	zbx_snprintf(audit_key_timeout, sizeof(audit_key_timeout), "httptest.steps[" ZBX_FS_UI64 "].timeout",
			httpstepid);
	zbx_snprintf(audit_key_posts, sizeof(audit_key_posts), "httptest.steps[" ZBX_FS_UI64 "].posts", httpstepid);
	zbx_snprintf(audit_key_required, sizeof(audit_key_required), "httptest.steps[" ZBX_FS_UI64 "].required",
			httpstepid);
	zbx_snprintf(audit_key_status_codes, sizeof(audit_key_status_codes),
			"httptest.steps[" ZBX_FS_UI64 "].status_codes", httpstepid);
	zbx_snprintf(audit_key_follow_redirects, sizeof(audit_key_follow_redirects),
			"httptest.steps[" ZBX_FS_UI64 "].follow_redirects", httpstepid);
	zbx_snprintf(audit_key_retrieve_mode, sizeof(audit_key_retrieve_mode),
			"httptest.steps[" ZBX_FS_UI64 "].retrieve_mode", httpstepid);
	zbx_snprintf(audit_key_post_type, sizeof(audit_key_post_type), "httptest.steps[" ZBX_FS_UI64 "].post_type",
			httpstepid);

#define AUDIT_TABLE_NAME	"httpstep"
	zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_name,
			name, AUDIT_TABLE_NAME, "name");
	zbx_audit_update_json_append_int(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_no, no,
			AUDIT_TABLE_NAME, "no");
	zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_url,
			url, AUDIT_TABLE_NAME, "url");
	zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_timeout,
			timeout, AUDIT_TABLE_NAME, "timeout");
	zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_posts,
			posts, AUDIT_TABLE_NAME, "posts");
	zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD,
			audit_key_required, required, AUDIT_TABLE_NAME, "required");
	zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD,
			audit_key_status_codes, status_codes, AUDIT_TABLE_NAME, "status_codes");
	zbx_audit_update_json_append_int(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD,
			audit_key_follow_redirects, follow_redirects, AUDIT_TABLE_NAME, "follow_redirects");
	zbx_audit_update_json_append_int(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD,
			audit_key_retrieve_mode, retrieve_mode, AUDIT_TABLE_NAME, "retrieve_mode");
	zbx_audit_update_json_append_int(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD,
			audit_key_post_type, post_type, AUDIT_TABLE_NAME, "post_type");
#undef AUDIT_TABLE_NAME
}

#define PREPARE_AUDIT_HTTPSTEP_UPDATE(resource, type1, type2)							\
void	zbx_audit_httptest_update_json_httpstep_update_##resource(zbx_uint64_t httptestid,			\
		zbx_uint64_t httpstepid, type1 resource##_old, type1 resource##_new)				\
{														\
	char	buf[AUDIT_DETAILS_KEY_LEN];									\
														\
	RETURN_IF_AUDIT_OFF();											\
														\
	zbx_snprintf(buf, sizeof(buf), "httptest.steps[" ZBX_FS_UI64 "]."#resource, httpstepid);		\
														\
	zbx_audit_update_json_update_##type2(httptestid, AUDIT_HTTPTEST_ID, buf, resource##_old,		\
			resource##_new);									\
}

PREPARE_AUDIT_HTTPSTEP_UPDATE(url, const char*, string)
PREPARE_AUDIT_HTTPSTEP_UPDATE(posts, const char*, string)
PREPARE_AUDIT_HTTPSTEP_UPDATE(required, const char*, string)
PREPARE_AUDIT_HTTPSTEP_UPDATE(status_codes, const char*, string)
PREPARE_AUDIT_HTTPSTEP_UPDATE(timeout, const char*, string)
PREPARE_AUDIT_HTTPSTEP_UPDATE(follow_redirects, int, int)
PREPARE_AUDIT_HTTPSTEP_UPDATE(retrieve_mode, int, int)
PREPARE_AUDIT_HTTPSTEP_UPDATE(post_type, int, int)

#undef PREPARE_AUDIT_HTTPTEST_UPDATE

static const char *field_type_to_name(int type)
{
	if (ZBX_HTTPFIELD_HEADER == type)
	{
		return "header";
	}
	else if (ZBX_HTTPFIELD_VARIABLE == type)
	{
		return "variable";
	}
	else if (ZBX_HTTPFIELD_POST_FIELD == type)
	{
		return "post_field";
	}
	else if (ZBX_HTTPFIELD_QUERY_FIELD == type)
	{
		return "query_field";
	}
	else
	{
		zabbix_log(LOG_LEVEL_CRIT, "unexpected http field type: ->%d<-", type);
		THIS_SHOULD_NEVER_HAPPEN;
		exit(EXIT_FAILURE);
	}
}

void	zbx_audit_httptest_update_json_add_httptest_field(zbx_uint64_t httptestid, zbx_uint64_t httptestfieldid,
		int type, const char *name, const char *value)
{
	char	audit_key[AUDIT_DETAILS_KEY_LEN], audit_key_type[AUDIT_DETAILS_KEY_LEN],
		audit_key_name[AUDIT_DETAILS_KEY_LEN], audit_key_value[AUDIT_DETAILS_KEY_LEN];

	RETURN_IF_AUDIT_OFF();

	zbx_snprintf(audit_key_type, sizeof(audit_key_type), "%s", field_type_to_name(type));
	zbx_snprintf(audit_key, sizeof(audit_key), "httptest.%s[" ZBX_FS_UI64 "]", audit_key_type, httptestfieldid);
	zbx_snprintf(audit_key_name, sizeof(audit_key_name), "httptest.%s[" ZBX_FS_UI64 "].name", audit_key_type,
			httptestfieldid);
	zbx_snprintf(audit_key_value, sizeof(audit_key_value), "httptest.%s[" ZBX_FS_UI64 "].value", audit_key_type,
			httptestfieldid);

#define AUDIT_TABLE_NAME	"httpstep_field"
	zbx_audit_update_json_append_no_value(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
	zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_name,
			name, AUDIT_TABLE_NAME, "name");
	zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_value,
			value, AUDIT_TABLE_NAME, "value");
#undef AUDIT_TABLE_NAME
}

void	zbx_audit_httptest_update_json_delete_httptest_field(zbx_uint64_t httptestid, zbx_uint64_t fieldid, int type)
{
	char	audit_key[AUDIT_DETAILS_KEY_LEN], audit_key_type[AUDIT_DETAILS_KEY_LEN];

	RETURN_IF_AUDIT_OFF();

	zbx_snprintf(audit_key_type, sizeof(audit_key_type), "%s", field_type_to_name(type));
	zbx_snprintf(audit_key, sizeof(audit_key), "httptest.%s[" ZBX_FS_UI64 "]",audit_key_type, fieldid);

	zbx_audit_update_json_append_no_value(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_DELETE, audit_key);
}

void	zbx_audit_httptest_update_json_add_httpstep_field(zbx_uint64_t httptestid, zbx_uint64_t httpstepid,
		zbx_uint64_t httpstepfieldid, int type, const char *name, const char *value)
{
	char	audit_key[AUDIT_DETAILS_KEY_LEN], audit_key_type[AUDIT_DETAILS_KEY_LEN],
		audit_key_name[AUDIT_DETAILS_KEY_LEN], audit_key_value[AUDIT_DETAILS_KEY_LEN];

	RETURN_IF_AUDIT_OFF();

	zbx_snprintf(audit_key_type, sizeof(audit_key_type), "%s", field_type_to_name(type));
	zbx_snprintf(audit_key, sizeof(audit_key), "httptest.steps[" ZBX_FS_UI64 "].%s[" ZBX_FS_UI64 "]",
			httpstepid, audit_key_type, httpstepfieldid);
	zbx_snprintf(audit_key_name, sizeof(audit_key_name), "httptest.steps[" ZBX_FS_UI64 "].%s[" ZBX_FS_UI64 "].name",
			httpstepid, audit_key_type,  httpstepfieldid);
	zbx_snprintf(audit_key_value, sizeof(audit_key_value),
			"httptest.steps[" ZBX_FS_UI64 "].%s[" ZBX_FS_UI64 "].value", httpstepid, audit_key_type,
			httpstepfieldid);
#define AUDIT_TABLE_NAME	"httpstep_field"
	zbx_audit_update_json_append_no_value(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
	zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_name,
			name, AUDIT_TABLE_NAME, "name");
	zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_value,
			value, AUDIT_TABLE_NAME, "value");
#undef AUDIT_TABLE_NAME
}

void	zbx_audit_httptest_update_json_delete_httpstep_field(zbx_uint64_t httptestid, zbx_uint64_t httpstepid,
		zbx_uint64_t fieldid, int type)
{
	char	audit_key[AUDIT_DETAILS_KEY_LEN], audit_key_type[AUDIT_DETAILS_KEY_LEN];

	RETURN_IF_AUDIT_OFF();

	zbx_snprintf(audit_key_type, sizeof(audit_key_type), "%s", field_type_to_name(type));
	zbx_snprintf(audit_key, sizeof(audit_key), "httptest.steps[" ZBX_FS_UI64 "].%s[" ZBX_FS_UI64 "]",
			httpstepid, audit_key_type, fieldid);

	zbx_audit_update_json_append_no_value(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_DELETE, audit_key);
}