linux-audit.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Richard Guy Briggs <rgb@redhat.com>
To: Linux-Audit Mailing List <linux-audit@redhat.com>
Cc: Richard Guy Briggs <rgb@redhat.com>, eparis@parisplace.org
Subject: [PATCH ghak28/ghak25 user v6 2/2] ausearch-parse: mod parser for YAASAO for NETFILTER_CFG
Date: Wed, 20 May 2020 12:52:20 -0400	[thread overview]
Message-ID: <1589993540-21629-3-git-send-email-rgb@redhat.com> (raw)
In-Reply-To: <1589993540-21629-1-git-send-email-rgb@redhat.com>

Modify the YAASAO parser to accomodate the ghak25 NETFILTER_CFG record.

Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
---
 src/ausearch-parse.c | 52 ++++++++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/src/ausearch-parse.c b/src/ausearch-parse.c
index be1d32cdfa5f..cd8632a58ac0 100644
--- a/src/ausearch-parse.c
+++ b/src/ausearch-parse.c
@@ -173,11 +173,11 @@ int extract_search_items(llist *l)
 			case AUDIT_BPRM_FCAPS:
 			case AUDIT_CAPSET:
 			case AUDIT_MMAP:
-			case AUDIT_NETFILTER_CFG:
 			case AUDIT_PROCTITLE:
 			case AUDIT_REPLACE...AUDIT_BPF:
 				// Nothing to parse
 				break;
+			case AUDIT_NETFILTER_CFG:
 			case AUDIT_EVENT_LISTENER:
 				ret = parse_yaasao(n, s);
 				break;
@@ -2596,7 +2596,7 @@ static int parse_yaasao(lnode *n, search_items *s)
 		} else
 			return 54;
 	}
-	// get uid if not already filled
+	// optionally get uid if not already filled
 	if ((s->uid == -1 && !s->tuid) && (event_uid != -1 || event_tuid)) {
 		str = strstr(term, "uid=");
 		if (str) {
@@ -2610,31 +2610,31 @@ static int parse_yaasao(lnode *n, search_items *s)
 			if (errno)
 				return 56;
 			*term = ' ';
-			if (s->tuid) free((void *)s->tuid);
-			s->tuid = lookup_uid("uid", s->uid);
 		} else
-			return 57;
+			s->uid = 0;
+		if (s->tuid) free((void *)s->tuid);
+		s->tuid = lookup_uid("uid", s->uid);
 	}
-	// get loginuid if not already filled
+	// optionally get loginuid if not already filled
 	if ((s->loginuid == -2 && !s->tauid) && (event_loginuid != -2 || event_tauid)) {
 		str = strstr(term, "auid=");
 		if (str) {
 			ptr = str + 5;
 			term = strchr(ptr, ' ');
 			if (term == NULL)
-				return 58;
+				return 57;
 			*term = 0;
 			errno = 0;
 			s->loginuid = strtoul(ptr, NULL, 10);
 			if (errno)
-				return 59;
+				return 58;
 			*term = ' ';
-			if (s->tauid) free((void *)s->tauid);
-			s->tauid = lookup_uid("auid", s->loginuid);
 		} else
-			return 60;
+			s->loginuid = (unsigned long)-1;
+		if (s->tauid) free((void *)s->tauid);
+		s->tauid = lookup_uid("auid", s->loginuid);
 	}
-	// get tty if not already filled
+	// optionally get tty if not already filled
 	if (!s->terminal && event_terminal) {
 		// dont do this search unless needed
 		str = strstr(term, "tty=");
@@ -2642,31 +2642,31 @@ static int parse_yaasao(lnode *n, search_items *s)
 			str += 4;
 			term = strchr(str, ' ');
 			if (term == NULL)
-				return 61;
+				return 59;
 			*term = 0;
 			if (s->terminal) // ANOM_NETLINK has one
 				free(s->terminal);
 			s->terminal = strdup(str);
 			*term = ' ';
 		} else
-			return 62;
+			s->terminal = strdup("(none)");
 	}
-	// get ses if not already filled
+	// optionally get ses if not already filled
 	if (s->session_id == -2 && event_session_id != -2 ) {
 		str = strstr(term, "ses=");
 		if (str) {
 			ptr = str + 4;
 			term = strchr(ptr, ' ');
 			if (term == NULL)
-				return 63;
+				return 60;
 			*term = 0;
 			errno = 0;
 			s->session_id = strtoul(ptr, NULL, 10);
 			if (errno)
-				return 64;
+				return 61;
 			*term = ' ';
 		} else
-			return 65
+			s->session_id = (unsigned long)-1;
 	}
 	// get subject if not already filled
 	if (!s->avc && event_subject) {
@@ -2676,7 +2676,7 @@ static int parse_yaasao(lnode *n, search_items *s)
 			str += 5;
 			term = strchr(str, ' ');
 			if (term == NULL)
-				return 66;
+				return 62;
 			*term = 0;
 			if (audit_avc_init(s) == 0) {
 				anode an;
@@ -2686,9 +2686,9 @@ static int parse_yaasao(lnode *n, search_items *s)
 				alist_append(s->avc, &an);
 				*term = ' ';
 			} else
-				return 67;
+				return 63;
 		} else
-			return 68;
+			return 64;
 	}
 	// get command line if not already filled
 	if (!s->comm && event_comm) {
@@ -2703,16 +2703,16 @@ static int parse_yaasao(lnode *n, search_items *s)
 				str++;
 				term = strchr(str, '"');
 				if (term == NULL)
-					return 69;
+					return 65;
 				*term = 0;
 				s->comm = strdup(str);
 				*term = '"';
 			} else 
 				s->comm = unescape(str);
 		} else
-			return 70;
+			return 66;
 	}
-	// get exe if not already filled
+	// optionally get exe if not already filled
 	if (!s->exe && event_exe) {
 		// dont do this search unless needed
 		str = strstr(n->message, "exe=");
@@ -2722,14 +2722,14 @@ static int parse_yaasao(lnode *n, search_items *s)
 				str++;
 				term = strchr(str, '"');
 				if (term == NULL)
-					return 71;
+					return 67;
 				*term = 0;
 				s->exe = strdup(str);
 				*term = '"';
 			} else 
 				s->exe = unescape(str);
 		} else
-			return 72;
+			s->exe = strdup("(null)");
 	}
 	return 0;
 }
-- 
1.8.3.1

--
Linux-audit mailing list
Linux-audit@redhat.com
https://www.redhat.com/mailman/listinfo/linux-audit


      parent reply	other threads:[~2020-05-20 16:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-20 16:52 [PATCH ghak28/ghak25 user v6 0/2] parse EVENT_LISTENER and NETFILTER_CFG Richard Guy Briggs
2020-05-20 16:52 ` [PATCH ghak28/ghak25 user v6 1/2] ausearch-parse: add parser for YAASAO Richard Guy Briggs
2020-05-20 16:52 ` Richard Guy Briggs [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1589993540-21629-3-git-send-email-rgb@redhat.com \
    --to=rgb@redhat.com \
    --cc=eparis@parisplace.org \
    --cc=linux-audit@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).