Skip to content

Commit 9b1a21d

Browse files
committed
Resolve obj of kill syscalls
During NORM_PID normalization, each OBJ_PID record is scanned and its opid collected, with the first opid recorded as the primary object while treating the target as a process group.
1 parent 8fdfe53 commit 9b1a21d

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

auparse/normalize.c

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -778,25 +778,38 @@ static int normalize_syscall(auparse_state_t *au, const char *syscall)
778778
D.thing.what = NORM_WHAT_SOCKET;
779779
set_socket_object(au);
780780
break;
781-
case NORM_PID:
782-
if (auparse_get_num_records(au) > 2) {
783-
// FIXME: this has implications for object
781+
case NORM_PID: {
782+
unsigned int r, cnt;
783+
value_t attr;
784+
785+
act = "killed-pid";
786+
D.thing.what = NORM_WHAT_PROCESS;
787+
788+
// Loop to see how many OBJ_PID we have (normally 1)
789+
cnt = auparse_get_num_records(au);
790+
for (r = 1; r < cnt; r++) {
791+
auparse_goto_record_num(au, r);
792+
if (auparse_get_type(au) != AUDIT_OBJ_PID)
793+
continue;
794+
auparse_first_field(au);
795+
if (auparse_find_field(au, "opid")) {
796+
attr = set_record(0,
797+
auparse_get_record_num(au));
798+
attr = set_field(attr,
799+
auparse_get_field_num(au));
800+
if (is_unset(D.thing.primary))
801+
D.thing.primary = attr;
802+
cllist_append(&D.thing.attr, attr,
803+
NULL);
804+
}
805+
}
806+
// If there's more than one, it's a process group
807+
if (D.thing.attr.cnt > 1) {
784808
act = "killed-list-of-pids";
785809
D.thing.what = NORM_WHAT_PROCESS_GROUP;
786-
} else {
787-
act = "killed-pid";
788-
D.thing.what = NORM_WHAT_PROCESS;
789-
}
790-
auparse_goto_record_num(au, 1);
791-
auparse_first_field(au);
792-
f = auparse_find_field(au, "saddr");
793-
if (f) {
794-
D.thing.primary = set_record(0,
795-
auparse_get_record_num(au));
796-
D.thing.primary = set_field(D.thing.primary,
797-
auparse_get_field_num(au));
798810
}
799811
break;
812+
}
800813
case NORM_MAC_LOAD:
801814
act = normalize_record_map_i2s(ttype);
802815
// FIXME: What is the object?

0 commit comments

Comments
 (0)