Skip to content

Commit 45c6779

Browse files
author
Mark Stemm
authored
Add a filtercheck for process tty. (draios#847)
This allows it to be used in falco rules.
1 parent 186eefe commit 45c6779

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

userspace/libsinsp/filterchecks.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,8 @@ const filtercheck_field_info sinsp_filter_check_thread_fields[] =
13401340
{PT_UINT64, EPF_TABLE_ONLY, PF_DEC, "thread.vmsize.b", "For the process main thread, this is the total virtual memory for the process (in bytes). For the other threads, this field is zero."},
13411341
{PT_UINT64, EPF_TABLE_ONLY, PF_DEC, "thread.vmrss.b", "For the process main thread, this is the resident non-swapped memory for the process (in bytes). For the other threads, this field is zero."},
13421342
{PT_INT64, EPF_NONE, PF_ID, "proc.sid", "the session id of the process generating the event."},
1343-
{PT_CHARBUF, EPF_NONE, PF_NA, "proc.sname", "the name of the current process's session leader. This is either the process with pid=proc.sid or the eldest ancestor that has the same sid as the current process."}
1343+
{PT_CHARBUF, EPF_NONE, PF_NA, "proc.sname", "the name of the current process's session leader. This is either the process with pid=proc.sid or the eldest ancestor that has the same sid as the current process."},
1344+
{PT_INT32, EPF_NONE, PF_ID, "proc.tty", "The controlling terminal of the process. 0 for processes without a terminal."}
13441345
};
13451346

13461347
sinsp_filter_check_thread::sinsp_filter_check_thread()
@@ -1661,6 +1662,8 @@ uint8_t* sinsp_filter_check_thread::extract(sinsp_evt *evt, OUT uint32_t* len, b
16611662
return (uint8_t*)m_tstr.c_str();
16621663
}
16631664
}
1665+
case TYPE_TTY:
1666+
return (uint8_t*)&tinfo->m_tty;
16641667
case TYPE_NAME:
16651668
m_tstr = tinfo->get_comm();
16661669
*len = m_tstr.size();

userspace/libsinsp/filterchecks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ class sinsp_filter_check_thread : public sinsp_filter_check
370370
TYPE_THREAD_VMRSS_B = 39,
371371
TYPE_SID = 40,
372372
TYPE_SNAME = 41,
373+
TYPE_TTY = 42,
373374
};
374375

375376
sinsp_filter_check_thread();

0 commit comments

Comments
 (0)