include keys typed into audit log

This will help people cross-correlate when the app performs specific
calls.
This commit is contained in:
Kartik K. Agaram 2022-02-01 21:19:51 -08:00
parent 7968134246
commit 664b94f414
3 changed files with 18 additions and 0 deletions

View File

@ -36,6 +36,8 @@
@classmod curses.window
*/
#include <ctype.h>
#include "../teliva.h"
#include "_helpers.c"
#include "chstr.c"
@ -1305,6 +1307,13 @@ Wgetch(lua_State *L)
if (x > COLS-2) x = COLS-2; if (y > LINES-1) y = LINES-1; /* http://gnats.netbsd.org/56664 */
mvaddstr(y, x, "");
int c = wgetch(w);
static char buffer[1024] = {0};
memset(buffer, '\0', 1024);
if (isspace(c))
snprintf(buffer, 1020, "getch() => %s", character_name(c));
else
snprintf(buffer, 1020, "getch() => %c", c);
append_to_audit_log(L, buffer);
if (c == ERR)
return 0;

View File

@ -102,6 +102,13 @@ static void draw_menu(lua_State* L) {
attrset(A_NORMAL);
}
const char* character_name(char c) {
if (c == '\n') return "ENTER";
if (c == '\t') return "TAB";
if (c == ' ') return "SPACE";
return "UNKNOWN";
}
static void render_permissions(lua_State* L) {
attrset(A_NORMAL);
mvaddstr(LINES-1, COLS-12, "");

View File

@ -178,6 +178,8 @@ extern void draw_string_on_menu(const char* s);
extern int menu_column;
extern const char* character_name(char c);
/* Error reporting */
extern const char* Previous_error;