From 1378ba84f5d7e53b8b4985eb9b4cc7fca25829fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lesimple?= Date: Tue, 12 Jan 2021 16:12:43 +0000 Subject: [PATCH] fix: re-introduce the ttyrecfile field This field was mistakenly removed along with the ttyrecsize one by mistake in a479810d83e32ce8805520a9678e8678888446c9. Add tests to ensure this can't break again. --- lib/perl/OVH/Bastion/log.inc | 9 +++++---- tests/functional/tests.d/350-groups.sh | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/perl/OVH/Bastion/log.inc b/lib/perl/OVH/Bastion/log.inc index 951dc12..cd02d60 100644 --- a/lib/perl/OVH/Bastion/log.inc +++ b/lib/perl/OVH/Bastion/log.inc @@ -240,6 +240,7 @@ sub _sql_log_insert_file { my $plugin = $params{'plugin'}; my $params = $params{'params'}; my $comment = $params{'comment'}; + my $ttyrecfile = $params{'ttyrecfile'}; my $timestamp = $params{'timestamp'}; my $timestampusec = $params{'timestampusec'}; my $uniqid = $params{'uniqid'}; @@ -295,11 +296,11 @@ sub _sql_log_insert_file { if ($sqltype eq 'local') { $prepare = "INSERT INTO connections" - . "(uniqid,timestamp,timestampusec,account,cmdtype,allowed,hostfrom,ipfrom,portfrom,bastionip,bastionport,hostto,ipto,portto,user,plugin,params,comment)" - . "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + . "(uniqid,timestamp,timestampusec,account,cmdtype,allowed,hostfrom,ipfrom,portfrom,bastionip,bastionport,hostto,ipto,portto,user,plugin,params,comment,ttyrecfile)" + . "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; @execute = ( - $uniqid, $timestamp, $timestampusec, $account, $cmdtype, $allowed, $hostfrom, $ipfrom, $portfrom, - $bastionip, $bastionport, $hostto, $ipto, $portto, $user, $plugin, $params, $comment + $uniqid, $timestamp, $timestampusec, $account, $cmdtype, $allowed, $hostfrom, $ipfrom, $portfrom, $bastionip, + $bastionport, $hostto, $ipto, $portto, $user, $plugin, $params, $comment, $ttyrecfile ); } elsif ($sqltype eq 'global') { diff --git a/tests/functional/tests.d/350-groups.sh b/tests/functional/tests.d/350-groups.sh index 18f941d..e9c5d4d 100644 --- a/tests/functional/tests.d/350-groups.sh +++ b/tests/functional/tests.d/350-groups.sh @@ -527,6 +527,23 @@ EOS contain "allowed ... log on" contain 'Permission denied (publickey' + # ttyrec: take the opportunity to test selfListSessions/selfPlaySession as we just recorded a ttyrec + success ssh a3_selfListSessions $a3 --osh selfListSessions --host 127.0.0.2 --user g2 --type ssh + json .command selfListSessions .error_code OK .value[0].allowed 1 + local sessionid + sessionid=$(get_json | $jq '.value[0].id') + + plgfail ssh a3_selfPlaySession_nonexisting $a3 --osh selfPlaySession --id 123456 + json .command selfPlaySession .error_code ERR_NOT_FOUND + + script ssh a3_selfPlaySession_existing $a3 --osh selfPlaySession --id $sessionid '< /dev/null' + retvalshouldbe 0 + json .command selfPlaySession .error_code OK + contain 'Total Recall' + contain 'Permission denied (publickey' + nocontain 'n/a' + # /ttyrec + run ssh a3_access_g1_as_member_but_ip_not_in_group $a3 g1@127.0.0.3 retvalshouldbe 107 json .error_code KO_ACCESS_DENIED