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

Commit8625c1a

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

File tree

3 files changed

+51
-7
lines changed

3 files changed

+51
-7
lines changed

‎Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/conf.add
2020
DATA = aqo--1.0.sql aqo--1.0--1.1.sql
2121
DATA_built = aqo--1.1.sql
2222

23+
TAP_TESTS = 1
24+
2325
MODULE_big = aqo
2426
ifdefUSE_PGXS
2527
PG_CONFIG = pg_config

‎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);

‎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