commit
f1ff2d17aa
@ -0,0 +1 @@
|
||||
SOURCES/liblognorm-2.0.6.tar.gz
|
@ -0,0 +1 @@
|
||||
61c72b58f511924ab80401b0719803963872c73d SOURCES/liblognorm-2.0.6.tar.gz
|
@ -0,0 +1,204 @@
|
||||
From eb2299a0897577048205e4d8a331168d82ce09d0 Mon Sep 17 00:00:00 2001
|
||||
From: Noriko Hosoi <nhosoi@momo7.localdomain>
|
||||
Date: Thu, 26 Jul 2018 17:18:38 -0700
|
||||
Subject: [PATCH] Add a parameter skipempty to the json field type.
|
||||
|
||||
If skipempty is set as follows, empty json objects are dropped from
|
||||
the parsed result.
|
||||
%field_name:json:skipempty%
|
||||
|
||||
If any parameter other than "skipempty" is given ("bogus" in this
|
||||
example), an error message "invalid flag for JSON parser: bogus"
|
||||
is issued.
|
||||
---
|
||||
src/parser.c | 127 ++++++++++++++++++++++++++++++++++++++++++
|
||||
src/parser.h | 2 +-
|
||||
src/pdag.c | 2 +-
|
||||
3 files changed, 129 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/parser.c b/src/parser.c
|
||||
index 77407c6..6736c6f 100644
|
||||
--- a/src/parser.c
|
||||
+++ b/src/parser.c
|
||||
@@ -2325,6 +2325,85 @@ PARSER_Parse(v2IPTables)
|
||||
return r;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * Delete children of the given object if it has children and they are empty.
|
||||
+ *
|
||||
+ * return 0 if object is not empty
|
||||
+ * return 1 if object is empty
|
||||
+ * return < 0 if error
|
||||
+ *
|
||||
+ * Caller should do this:
|
||||
+ * if (jsonSkipEmpty(obj) > 0) {
|
||||
+ * json_object_put(obj);
|
||||
+ * obj = NULL;
|
||||
+ * }
|
||||
+ * or otherwise not use obj if jsonSkipEmpty returns > 0.
|
||||
+ */
|
||||
+static int
|
||||
+jsonSkipEmpty(struct json_object *__restrict__ json)
|
||||
+{
|
||||
+ int rc = 0;
|
||||
+ struct json_object *val = NULL;
|
||||
+
|
||||
+ if(json == NULL) {
|
||||
+ rc = 1;
|
||||
+ goto finalize_it;
|
||||
+ }
|
||||
+
|
||||
+ switch (json_object_get_type(json)) {
|
||||
+ case json_type_string:
|
||||
+ rc = json_object_get_string_len(json) == 0;
|
||||
+ break;
|
||||
+ case json_type_array:
|
||||
+ {
|
||||
+ int i;
|
||||
+ int arrayLen = json_object_array_length(json);
|
||||
+ for (i = 0 ; i < arrayLen ; ++i) {
|
||||
+ val = json_object_array_get_idx(json, i);
|
||||
+ if ((rc = jsonSkipEmpty(val)) > 0) {
|
||||
+ /* delete the empty item and reset the index and arrayLen */
|
||||
+ json_object_array_del_idx(json, i--);
|
||||
+ arrayLen = json_object_array_length(json);
|
||||
+ } else if (rc < 0) {
|
||||
+ goto finalize_it;
|
||||
+ }
|
||||
+ }
|
||||
+ rc = json_object_array_length(json) == 0;
|
||||
+ break;
|
||||
+ }
|
||||
+ case json_type_object:
|
||||
+ {
|
||||
+ struct json_object_iterator it = json_object_iter_begin(json);
|
||||
+ struct json_object_iterator itEnd = json_object_iter_end(json);
|
||||
+ while (!json_object_iter_equal(&it, &itEnd)) {
|
||||
+ val = json_object_iter_peek_value(&it);
|
||||
+ if ((rc = jsonSkipEmpty(val)) > 0) {
|
||||
+ json_object_object_del(json, json_object_iter_peek_name(&it));
|
||||
+ } else if (rc < 0) {
|
||||
+ goto finalize_it;
|
||||
+ }
|
||||
+ json_object_iter_next(&it);
|
||||
+ }
|
||||
+ rc = json_object_object_length(json) == 0;
|
||||
+ }
|
||||
+ case json_type_null:
|
||||
+ case json_type_boolean:
|
||||
+ case json_type_double:
|
||||
+ case json_type_int:
|
||||
+ default: break;
|
||||
+ }
|
||||
+finalize_it:
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Parameters for field type json
|
||||
+ * skipempty - skips empty json objects.
|
||||
+ * - %field_name:json:skipempty%
|
||||
+ */
|
||||
+struct data_JSON {
|
||||
+ int skipempty;
|
||||
+};
|
||||
/**
|
||||
* Parse JSON. This parser tries to find JSON data inside a message.
|
||||
* If it finds valid JSON, it will extract it. Extra data after the
|
||||
@@ -2340,6 +2419,7 @@ PARSER_Parse(v2IPTables)
|
||||
PARSER_Parse(JSON)
|
||||
const size_t i = *offs;
|
||||
struct json_tokener *tokener = NULL;
|
||||
+ struct data_JSON *const data = (struct data_JSON*) pdata;
|
||||
|
||||
if(npb->str[i] != '{' && npb->str[i] != ']') {
|
||||
/* this can't be json, see RFC4627, Sect. 2
|
||||
@@ -2368,6 +2448,20 @@ PARSER_Parse(JSON)
|
||||
if(value == NULL) {
|
||||
json_object_put(json);
|
||||
} else {
|
||||
+ if (data && data->skipempty) {
|
||||
+ int rc = jsonSkipEmpty(json);
|
||||
+ if (rc < 0) {
|
||||
+ json_object_put(json);
|
||||
+ FAIL(LN_WRONGPARSER);
|
||||
+ } else if (rc > 0) {
|
||||
+ /*
|
||||
+ * json value is empty.
|
||||
+ * E.g., {"message":""}, {"message":[]}, {"message":{}}
|
||||
+ */
|
||||
+ json_object_put(json);
|
||||
+ FAIL(0);
|
||||
+ }
|
||||
+ }
|
||||
*value = json;
|
||||
}
|
||||
|
||||
@@ -2376,7 +2470,40 @@ PARSER_Parse(JSON)
|
||||
json_tokener_free(tokener);
|
||||
return r;
|
||||
}
|
||||
+PARSER_Construct(JSON)
|
||||
+{
|
||||
+ int r = 0;
|
||||
+ struct json_object *ed;
|
||||
+ struct data_JSON *data = NULL;
|
||||
+ char *flag;
|
||||
|
||||
+ if(json == NULL)
|
||||
+ goto done;
|
||||
+
|
||||
+ if(json_object_object_get_ex(json, "extradata", &ed) == 0) {
|
||||
+ /* No JSON parameter */
|
||||
+ goto done;
|
||||
+ }
|
||||
+ data = (struct data_JSON*) calloc(1, sizeof(struct data_JSON));
|
||||
+ flag = json_object_get_string(ed);
|
||||
+ if (strcasecmp(flag, "skipempty") == 0) {
|
||||
+ data->skipempty = 1;
|
||||
+ } else {
|
||||
+ ln_errprintf(ctx, 0, "invalid flag for JSON parser: %s", flag);
|
||||
+ r = LN_BADCONFIG;
|
||||
+ goto done;
|
||||
+ }
|
||||
+ *pdata = data;
|
||||
+done:
|
||||
+ if(r != 0) {
|
||||
+ free(data);
|
||||
+ }
|
||||
+ return r;
|
||||
+}
|
||||
+PARSER_Destruct(JSON)
|
||||
+{
|
||||
+ free(pdata);
|
||||
+}
|
||||
|
||||
/* check if a char is valid inside a name of a NameValue list
|
||||
* The set of valid characters may be extended if there is good
|
||||
diff --git a/src/parser.h b/src/parser.h
|
||||
index 38be62d..5b4a821 100644
|
||||
--- a/src/parser.h
|
||||
+++ b/src/parser.h
|
||||
@@ -70,7 +70,7 @@ PARSERDEF_NO_DATA(Time24hr);
|
||||
PARSERDEF_NO_DATA(Duration);
|
||||
PARSERDEF_NO_DATA(IPv4);
|
||||
PARSERDEF_NO_DATA(IPv6);
|
||||
-PARSERDEF_NO_DATA(JSON);
|
||||
+PARSERDEF(JSON);
|
||||
PARSERDEF_NO_DATA(CEESyslog);
|
||||
PARSERDEF_NO_DATA(v2IPTables);
|
||||
PARSERDEF_NO_DATA(CiscoInterfaceSpec);
|
||||
diff --git a/src/pdag.c b/src/pdag.c
|
||||
index 0768e99..9feb755 100644
|
||||
--- a/src/pdag.c
|
||||
+++ b/src/pdag.c
|
||||
@@ -90,7 +90,7 @@ static struct ln_parser_info parser_lookup_table[] = {
|
||||
PARSER_ENTRY_NO_DATA("duration", Duration, 16),
|
||||
PARSER_ENTRY_NO_DATA("cisco-interface-spec", CiscoInterfaceSpec, 4),
|
||||
PARSER_ENTRY_NO_DATA("name-value-list", NameValue, 8),
|
||||
- PARSER_ENTRY_NO_DATA("json", JSON, 4),
|
||||
+ PARSER_ENTRY("json", JSON, 4),
|
||||
PARSER_ENTRY_NO_DATA("cee-syslog", CEESyslog, 4),
|
||||
PARSER_ENTRY_NO_DATA("mac48", MAC48, 16),
|
||||
PARSER_ENTRY_NO_DATA("cef", CEF, 4),
|
@ -0,0 +1,198 @@
|
||||
%define htmldir %{_docdir}/liblognorm/html
|
||||
|
||||
Name: liblognorm
|
||||
Version: 2.0.6
|
||||
Release: 5%{?dist}
|
||||
Summary: Fast samples-based log normalization library
|
||||
License: LGPLv2+
|
||||
URL: http://www.liblognorm.com
|
||||
Source0: http://www.liblognorm.com/files/download/%{name}-%{version}.tar.gz
|
||||
|
||||
BuildRequires: gcc
|
||||
BuildRequires: chrpath
|
||||
BuildRequires: libfastjson-devel
|
||||
BuildRequires: libestr-devel
|
||||
BuildRequires: pcre-devel
|
||||
|
||||
Patch0: liblognorm-2.0.0-rhbz1990737-add-skipempty.patch
|
||||
|
||||
%description
|
||||
Briefly described, liblognorm is a tool to normalize log data.
|
||||
|
||||
People who need to take a look at logs often have a common problem. Logs from
|
||||
different machines (from different vendors) usually have different formats for
|
||||
their logs. Even if it is the same type of log (e.g. from firewalls), the log
|
||||
entries are so different, that it is pretty hard to read these. This is where
|
||||
liblognorm comes into the game. With this tool you can normalize all your logs.
|
||||
All you need is liblognorm and its dependencies and a sample database that fits
|
||||
the logs you want to normalize.
|
||||
|
||||
%package devel
|
||||
Summary: Development tools for programs using liblognorm library
|
||||
Requires: %{name}%{?_isa} = %{version}-%{release}
|
||||
Requires: json-c-devel%{?_isa}
|
||||
Requires: libestr-devel%{?_isa}
|
||||
|
||||
%description devel
|
||||
The liblognorm-devel package includes header files, libraries necessary for
|
||||
developing programs which use liblognorm library.
|
||||
|
||||
%package doc
|
||||
Summary: HTML documentation for liblognorm
|
||||
BuildRequires: python3-sphinx
|
||||
BuildRequires: make
|
||||
|
||||
%description doc
|
||||
This sub-package contains documentation for liblognorm in a HTML form.
|
||||
|
||||
%package utils
|
||||
Summary: Lognormalizer utility for normalizing log files
|
||||
Requires: %{name}%{?_isa} = %{version}-%{release}
|
||||
|
||||
%description utils
|
||||
The lognormalizer is the core of liblognorm, it is a utility for normalizing
|
||||
log files.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch0 -p1 -b .skipempty
|
||||
|
||||
%build
|
||||
%configure --enable-regexp --enable-docs --docdir=%{htmldir} --includedir=%{_includedir}/%{name}/
|
||||
|
||||
|
||||
%install
|
||||
make V=1 install INSTALL="install -p" DESTDIR=%{buildroot}
|
||||
rm -f %{buildroot}/%{_libdir}/*.{a,la}
|
||||
chrpath -d %{buildroot}%{_bindir}/lognormalizer
|
||||
chrpath -d %{buildroot}%{_libdir}/liblognorm.so
|
||||
rm %{buildroot}%{htmldir}/{objects.inv,.buildinfo}
|
||||
|
||||
%ldconfig_scriptlets
|
||||
|
||||
%files
|
||||
%{!?_licensedir:%global license %%doc}
|
||||
%license COPYING
|
||||
%doc AUTHORS ChangeLog README
|
||||
%exclude %{htmldir}
|
||||
|
||||
%{_libdir}/lib*.so.*
|
||||
|
||||
%files devel
|
||||
%{_libdir}/lib*.so
|
||||
%{_includedir}/%{name}/*.h
|
||||
%{_libdir}/pkgconfig/*.pc
|
||||
|
||||
%files doc
|
||||
%doc %{htmldir}
|
||||
|
||||
%files utils
|
||||
%{_bindir}/lognormalizer
|
||||
|
||||
|
||||
%changelog
|
||||
* Wed Aug 02 2023 Attila Lakatos <alakatos@redhat.com> - 2.0.6-5
|
||||
- Rebuild
|
||||
resolves: rhbz#2227729
|
||||
|
||||
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 2.0.6-4
|
||||
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
|
||||
Related: rhbz#1991688
|
||||
|
||||
* Fri Aug 06 2021 Attila Lakatos <alakatos@redhat.com> - 2.0.6-3
|
||||
- Add skipempty to liblognorm json type
|
||||
resolves: rhbz#1990737
|
||||
|
||||
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 2.0.6-2
|
||||
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
|
||||
|
||||
* Tue Mar 02 2021 Attila Lakatos <alakatos@redhat.com> - 2.0.6-1
|
||||
- Rebase to 2.0.6
|
||||
|
||||
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.3-11
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
||||
|
||||
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.3-10
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
|
||||
|
||||
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.3-9
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
|
||||
|
||||
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.3-8
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
|
||||
|
||||
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.3-7
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
|
||||
|
||||
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.3-6
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
|
||||
|
||||
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.3-5
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
|
||||
|
||||
* Thu Oct 12 2017 Marek Tamaskovic <mtamasko@redhat.com> - 2.0.3-4
|
||||
- Fix header files location
|
||||
- resolves rhbz#1113573
|
||||
|
||||
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.3-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
|
||||
|
||||
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.3-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
|
||||
|
||||
* Wed Mar 29 2017 Radovan Sroka <rsroka@redhat.com> - 2.0.2-1
|
||||
- rebase to 2.0.3
|
||||
|
||||
* Thu Feb 9 2017 Radovan Sroka <rsroka@redhat.com> - 2.0.2-2
|
||||
- removed forgoten commented line
|
||||
|
||||
* Thu Feb 9 2017 Radovan Sroka <rsroka@redhat.com> - 2.0.2-1
|
||||
- rebase to 2.0.2
|
||||
|
||||
* Tue Oct 4 2016 Radovan Sroka <rsroka@redhat.com> - 2.0.1-1
|
||||
- rebase to 2.0.1
|
||||
|
||||
* Tue Mar 15 2016 Radovan Sroka <rsroka@redhat.com> - 1.1.3-1
|
||||
- rebase to v1.1.3
|
||||
|
||||
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
|
||||
|
||||
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.1.1-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
|
||||
|
||||
* Sun Mar 15 2015 Tomas Heinrich <theinric@redhat.com> - 1.1.1-1
|
||||
- rebase to 1.1.1 (soname bump)
|
||||
- drop liblognorm-0.3.4-pc-file.patch, not needed anymore
|
||||
- update dependencies for the new version
|
||||
- add a new subpackage for documentation
|
||||
- enable support for reqular expressions
|
||||
- make build more verbose
|
||||
|
||||
* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.3.7-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
|
||||
|
||||
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.3.7-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
|
||||
|
||||
* Wed Jul 31 2013 Tomas Heinrich <theinric@redhat.com> - 0.3.7-1
|
||||
- rebase to 0.3.7
|
||||
|
||||
* Wed Dec 12 2012 Mahaveer Darade <mah.darade@gmail.com> - 0.3.5-1
|
||||
- upgrade to upstream version 0.3.5
|
||||
- drop patch0, merged upstream
|
||||
liblognorm-0.3.4-rename-to-lognormalizer.patch
|
||||
- remove trailing whitespace
|
||||
|
||||
* Fri Oct 05 2012 mdarade <mdarade@redhat.com> - 0.3.4-4
|
||||
- Modified description of main & util package
|
||||
|
||||
* Thu Sep 20 2012 Mahaveer Darade <mdarade@redhat.com> - 0.3.4-3
|
||||
- Renamed normalizer binary to lognormalizer
|
||||
- Updated pc file to exclude lee and lestr
|
||||
|
||||
* Mon Aug 27 2012 mdarade <mdarade@redhat.com> - 0.3.4-2
|
||||
- Updated BuildRequires to contain libestr-devel
|
||||
|
||||
* Wed Aug 1 2012 Milan Bartos <mbartos@redhat.com> - 0.3.4-1
|
||||
- initial port
|
Loading…
Reference in new issue