Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6cfbea6

Browse files
committed
Add fix on security bugCVE-2020-14350.
Add A.Lakhin's security TAP-test.
1 parent27ea115 commit6cfbea6

File tree

4 files changed

+56
-11
lines changed

4 files changed

+56
-11
lines changed

‎Makefile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ REGRESS =aqo_disabled \
1717

1818
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/conf.add
1919

20+
TAP_TESTS = 1
21+
2022
DATA = aqo--1.0.sql aqo--1.0--1.1.sql aqo--1.1--1.2.sql
2123
DATA_built = aqo--1.2.sql
2224

‎aqo--1.0--1.1.sql‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ DROP INDEX public.aqo_query_texts_query_hash_idx CASCADE;
66
DROPINDEXpublic.aqo_query_stat_idx CASCADE;
77
DROPINDEXpublic.aqo_fss_access_idx CASCADE;
88

9-
CREATEUNIQUE INDEXaqo_fss_access_idxONpublic.aqo_data (fspace_hash, fsspace_hash);
9+
CREATEUNIQUE INDEXaqo_fss_access_idx
10+
ONpublic.aqo_data (fspace_hash, fsspace_hash);
1011

1112

1213
CREATE OR REPLACEFUNCTIONaqo_migrate_to_1_1_get_pk(rel regclass) RETURNS regclassAS $$
@@ -16,8 +17,7 @@ BEGIN
1617
SELECTi.indexrelidFROMpg_catalog.pg_index iJOIN
1718
pg_catalog.pg_attribute aONa.attrelid=i.indrelidAND
1819
a.attnum= ANY(i.indkey)
19-
WHEREi.indrelid= relAND
20-
i.indisprimary
20+
WHEREi.indrelid= relANDi.indisprimary
2121
INTO idx;
2222

2323
RETURN idx;
@@ -27,19 +27,18 @@ $$ LANGUAGE plpgsql;
2727

2828
DO $$
2929
BEGIN
30-
EXECUTE format('ALTER TABLE %s RENAME to %s',
30+
EXECUTEpg_catalog.format('ALTER TABLE %s RENAME to %s',
3131
aqo_migrate_to_1_1_get_pk('public.aqo_queries'),
3232
'aqo_queries_query_hash_idx');
3333

34-
EXECUTE format('ALTER TABLE %s RENAME to %s',
34+
EXECUTEpg_catalog.format('ALTER TABLE %s RENAME to %s',
3535
aqo_migrate_to_1_1_get_pk('public.aqo_query_texts'),
3636
'aqo_query_texts_query_hash_idx');
3737

38-
EXECUTE format('ALTER TABLE %s RENAME to %s',
38+
EXECUTEpg_catalog.format('ALTER TABLE %s RENAME to %s',
3939
aqo_migrate_to_1_1_get_pk('public.aqo_query_stat'),
4040
'aqo_query_stat_idx');
4141
END
4242
$$;
4343

44-
4544
DROPFUNCTION aqo_migrate_to_1_1_get_pk(regclass);

‎aqo--1.1--1.2.sql‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ DECLARE
33
restext;
44
BEGIN
55
SELECT conname
6-
FROM pg_constraint
6+
FROMpg_catalog.pg_constraint
77
WHERE conrelid= relidAND contype='u'
88
INTO res;
99

@@ -13,9 +13,10 @@ $$ LANGUAGE plpgsql;
1313

1414
DO $$
1515
BEGIN
16-
EXECUTE format('ALTER TABLE public.aqo_data DROP CONSTRAINT %s',
17-
aqo_migrate_to_1_2_get_pk('public.aqo_data'::regclass),
18-
'aqo_queries_query_hash_idx');
16+
EXECUTEpg_catalog.format(
17+
'ALTER TABLE public.aqo_data DROP CONSTRAINT %s',
18+
aqo_migrate_to_1_2_get_pk('public.aqo_data'::regclass),
19+
'aqo_queries_query_hash_idx');
1920
END
2021
$$;
2122

‎t/000_security.pl‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Acquiring superuser privileges
2+
use strict;
3+
use warnings;
4+
use PostgresNode;
5+
use TestLib;
6+
use Test::Moretests=> 1;
7+
8+
my$node;
9+
10+
# Initialize node
11+
$node = get_new_node('node');
12+
$node->init;
13+
$node->start;
14+
15+
my$query;
16+
my$is_su;
17+
18+
print($node->safe_psql("postgres","CREATE USER regress_hacker LOGIN"));
19+
$is_su =$node->safe_psql('postgres',undef,
20+
extra_params=> ['-U','regress_hacker','-c','SHOW is_superuser' ]);
21+
diag("The regress_hacker is superuser:" .$is_su ."\n");
22+
23+
$query =q{
24+
CREATE FUNCTION format(f text, r regclass, t text)
25+
RETURNS text
26+
AS $$
27+
BEGIN
28+
ALTER ROLE regress_hacker SUPERUSER;
29+
RETURN '';
30+
END
31+
$$ LANGUAGE plpgsql RETURNS NULL ON NULL INPUT;
32+
};
33+
34+
print($node->safe_psql('postgres',undef,
35+
extra_params=> ['-U','regress_hacker','-c',$query ]) ."\n");
36+
37+
$node->psql("postgres","CREATE EXTENSION aqo");
38+
39+
$is_su =$node->safe_psql('postgres',undef,
40+
extra_params=> ['-U','regress_hacker','-c','SHOW is_superuser' ]);
41+
42+
diag("The regress_hacker is superuser:" .$is_su ."\n");
43+
ok($is_sueq'off');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp