Commit ee8e5825 authored by Hubert depesz Lubaczewski's avatar Hubert depesz Lubaczewski
Browse files

Fix bug in anonymizing queries

parent 56221ed5
Revision history for Pg-Explain
1.02 2020/07/27
- Fix bug with preserving whitespace in anonymized queries
1.01 2020/07/27
- Make it possible to anonymize queries using the same anonymization
engine that is used to anonymize plan.
......
......@@ -42,39 +42,39 @@
"provides" : {
"Pg::Explain" : {
"file" : "lib/Pg/Explain.pm",
"version" : "1.01"
"version" : "1.02"
},
"Pg::Explain::Analyzer" : {
"file" : "lib/Pg/Explain/Analyzer.pm",
"version" : "1.01"
"version" : "1.02"
},
"Pg::Explain::From" : {
"file" : "lib/Pg/Explain/From.pm",
"version" : "1.01"
"version" : "1.02"
},
"Pg::Explain::FromJSON" : {
"file" : "lib/Pg/Explain/FromJSON.pm",
"version" : "1.01"
"version" : "1.02"
},
"Pg::Explain::FromText" : {
"file" : "lib/Pg/Explain/FromText.pm",
"version" : "1.01"
"version" : "1.02"
},
"Pg::Explain::FromXML" : {
"file" : "lib/Pg/Explain/FromXML.pm",
"version" : "1.01"
"version" : "1.02"
},
"Pg::Explain::FromYAML" : {
"file" : "lib/Pg/Explain/FromYAML.pm",
"version" : "1.01"
"version" : "1.02"
},
"Pg::Explain::Node" : {
"file" : "lib/Pg/Explain/Node.pm",
"version" : "1.01"
"version" : "1.02"
},
"Pg::Explain::StringAnonymizer" : {
"file" : "lib/Pg/Explain/StringAnonymizer.pm",
"version" : "1.01"
"version" : "1.02"
}
},
"release_status" : "stable",
......@@ -88,6 +88,6 @@
"web" : "https://gitlab.com/depesz/Pg--Explain"
}
},
"version" : "1.01",
"version" : "1.02",
"x_serialization_backend" : "JSON::PP version 4.02"
}
......@@ -19,31 +19,31 @@ name: Pg-Explain
provides:
Pg::Explain:
file: lib/Pg/Explain.pm
version: '1.01'
version: '1.02'
Pg::Explain::Analyzer:
file: lib/Pg/Explain/Analyzer.pm
version: '1.01'
version: '1.02'
Pg::Explain::From:
file: lib/Pg/Explain/From.pm
version: '1.01'
version: '1.02'
Pg::Explain::FromJSON:
file: lib/Pg/Explain/FromJSON.pm
version: '1.01'
version: '1.02'
Pg::Explain::FromText:
file: lib/Pg/Explain/FromText.pm
version: '1.01'
version: '1.02'
Pg::Explain::FromXML:
file: lib/Pg/Explain/FromXML.pm
version: '1.01'
version: '1.02'
Pg::Explain::FromYAML:
file: lib/Pg/Explain/FromYAML.pm
version: '1.01'
version: '1.02'
Pg::Explain::Node:
file: lib/Pg/Explain/Node.pm
version: '1.01'
version: '1.02'
Pg::Explain::StringAnonymizer:
file: lib/Pg/Explain/StringAnonymizer.pm
version: '1.01'
version: '1.02'
requires:
Clone: '0'
Digest::SHA: '0'
......@@ -55,5 +55,5 @@ requires:
resources:
license: http://dev.perl.org/licenses/
repository: https://gitlab.com/depesz/Pg--Explain.git
version: '1.01'
version: '1.02'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
......@@ -32,11 +32,11 @@ Pg::Explain - Object approach at reading explain analyze output
=head1 VERSION
Version 1.01
Version 1.02
=cut
our $VERSION = '1.01';
our $VERSION = '1.02';
=head1 SYNOPSIS
......
......@@ -26,11 +26,11 @@ Pg::Explain::Analyzer - Some helper methods to analyze explains
=head1 VERSION
Version 1.01
Version 1.02
=cut
our $VERSION = '1.01';
our $VERSION = '1.02';
=head1 SYNOPSIS
......
......@@ -26,11 +26,11 @@ Pg::Explain::From - Base class for parsers of non-text explain formats.
=head1 VERSION
Version 1.01
Version 1.02
=cut
our $VERSION = '1.01';
our $VERSION = '1.02';
=head1 SYNOPSIS
......
......@@ -27,11 +27,11 @@ Pg::Explain::FromJSON - Parser for explains in JSON format
=head1 VERSION
Version 1.01
Version 1.02
=cut
our $VERSION = '1.01';
our $VERSION = '1.02';
=head1 SYNOPSIS
......
......@@ -26,11 +26,11 @@ Pg::Explain::FromText - Parser for text based explains
=head1 VERSION
Version 1.01
Version 1.02
=cut
our $VERSION = '1.01';
our $VERSION = '1.02';
=head1 SYNOPSIS
......
......@@ -27,11 +27,11 @@ Pg::Explain::FromXML - Parser for explains in XML format
=head1 VERSION
Version 1.01
Version 1.02
=cut
our $VERSION = '1.01';
our $VERSION = '1.02';
=head1 SYNOPSIS
......
......@@ -27,11 +27,11 @@ Pg::Explain::FromYAML - Parser for explains in YAML format
=head1 VERSION
Version 1.01
Version 1.02
=cut
our $VERSION = '1.01';
our $VERSION = '1.02';
=head1 SYNOPSIS
......
......@@ -27,11 +27,11 @@ Pg::Explain::Node - Class representing single node from query plan
=head1 VERSION
Version 1.01
Version 1.02
=cut
our $VERSION = '1.01';
our $VERSION = '1.02';
=head1 SYNOPSIS
......
......@@ -26,11 +26,11 @@ Pg::Explain::StringAnonymizer - Class to anonymize sets of strings
=head1 VERSION
Version 1.01
Version 1.02
=cut
our $VERSION = '1.01';
our $VERSION = '1.02';
=head1 SYNOPSIS
......@@ -157,7 +157,7 @@ sub anonymize_text {
my $self = shift;
my $text = shift;
my $re = $self->{ 'keys_re' };
$text =~ s{(?:\b|\s)($re)(?:\b|\s)}{ $self->{'strings'}->{$1} }mge;
$text =~ s{(\b|\s)($re)(\b|\s)}{ $1 . $self->{'strings'}->{$2} . $3 }mge;
return $text;
}
......
......@@ -4,7 +4,7 @@ use Test::More;
use Test::Deep;
use Test::Exception;
use autodie;
plan 'tests' => 14;
plan 'tests' => 15;
use Pg::Explain;
......@@ -66,6 +66,7 @@ ok( $anonymized_query !~ /'pg_catalog'/, 'anonymize() hides string literal
ok( $anonymized_query !~ /nspname/, 'anonymize() hides column names in query.' );
ok( $anonymized_query !~ /pg_class/, 'anonymize() hides relation names in query.' );
ok( $anonymized_query !~ /\{r,p,v,m,S,f,""\}/, 'anonymize() hides complex things in query.' );
ok( $anonymized_query !~ /WHERE[a-z]/, 'anonymize() preserves whitespace in query.' );
exit;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment