chore: more readable version of sql statements

Signed-off-by: Stéphane Lesimple <stephane.lesimple+bastion@ovhcloud.com>
This commit is contained in:
Stéphane Lesimple 2021-01-26 16:18:42 +00:00 committed by Stéphane Lesimple
parent d9d77f5e71
commit 3b37242317

View file

@ -294,18 +294,19 @@ sub _sql_log_insert_file {
my $prepare; my $prepare;
my @execute; my @execute;
if ($sqltype eq 'local') { 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,ttyrecfile)"
. "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
@execute = ( @execute = (
$uniqid, $timestamp, $timestampusec, $account, $cmdtype, $allowed, $hostfrom, $ipfrom, $portfrom, $bastionip, $uniqid, $timestamp, $timestampusec, $account, $cmdtype, $allowed, $hostfrom, $ipfrom, $portfrom, $bastionip,
$bastionport, $hostto, $ipto, $portto, $user, $plugin, $params, $comment, $ttyrecfile $bastionport, $hostto, $ipto, $portto, $user, $plugin, $params, $comment, $ttyrecfile
); );
$prepare =
"INSERT INTO connections"
. "(uniqid,timestamp,timestampusec,account,cmdtype,allowed,hostfrom,ipfrom,portfrom,bastionip,bastionport,hostto,ipto,portto,user,plugin,params,comment,ttyrecfile)"
. 'VALUES ('
. ('?,' x (@execute - 1)) . '?)';
} }
elsif ($sqltype eq 'global') { elsif ($sqltype eq 'global') {
$prepare = "INSERT INTO connections_summary (uniqid,timestamp,account,cmdtype,allowed,ipfrom,ipto,portto,user,plugin)" . "VALUES (?,?,?,?,?,?,?,?,?,?)";
@execute = ($uniqid, $timestamp, $account, $cmdtype, $allowed, $ipfrom, $ipto, $portto, $user, $plugin); @execute = ($uniqid, $timestamp, $account, $cmdtype, $allowed, $ipfrom, $ipto, $portto, $user, $plugin);
$prepare = "INSERT INTO connections_summary (uniqid,timestamp,account,cmdtype,allowed,ipfrom,ipto,portto,user,plugin)" . 'VALUES (' . ('?,' x (@execute - 1)) . '?)';
} }
# prepare insertion on db # prepare insertion on db