Skip to content

Fix false positive non-superuser errors #190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix false positive non-superuser errors
Regex matching solely against the word "insufficient" means that it's trivial to cause this to alert unnecessarily by merely including the string "insufficient" in one's real query. Instead verify that we don't actually have a real query and know for certain this is an error condition.
  • Loading branch information
jcoleman authored and jcoleman committed Feb 2, 2022
commit 7fe3c1e10aa70aefcaf92f093e8fa899d5a5e914
2 changes: 1 addition & 1 deletion check_postgres.pl
Original file line number Diff line number Diff line change
Expand Up @@ -8737,7 +8737,7 @@ sub check_txn_idle {
my $st = defined($r->{state}) ? $r->{state} : '';

## Return unknown if we cannot see because we are a non-superuser
if ($cq =~ /insufficient/) {
if ($cq eq '<insufficient privilege>') {
add_unknown msg('psa-nosuper');
return;
}
Expand Down
24 changes: 23 additions & 1 deletion t/02_query_time.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use 5.008;
use strict;
use warnings;
use Data::Dumper;
use Test::More tests => 14;
use Test::More tests => 15;
use lib 't','.';
use CP_Testing;

Expand Down Expand Up @@ -102,4 +102,26 @@ $dbh->disconnect();

waitpid $child, 0;

# Test that a query using the word insufficient doesn't trigger the unknown data alert.

$child = fork();
if (0 == $child) {
my $kiddbh = $cp->test_database_handle();
$kiddbh->do(qq{SELECT pg_sleep(3) AS insufficient});
$kiddbh->rollback();
$kiddbh->disconnect();
exit;
}

my $dbh = $cp->test_database_handle();
sleep 1;
$t = qq{$S non-superuser access isn't fooled by the word insufficient};
like ($cp->run(q{-w 1 -vv}), qr{$label WARNING}, $t);
$dbh->rollback();
$dbh->disconnect();

$dbh->disconnect();

waitpid $child, 0;

exit;
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy