Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
504f0c5d
Commit
504f0c5d
authored
Jan 17, 2012
by
Robert Haas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Regression tests for security_barrier views.
KaiGai Kohei
parent
4b496a35
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
636 additions
and
0 deletions
+636
-0
src/test/regress/expected/select_views.out
src/test/regress/expected/select_views.out
+255
-0
src/test/regress/expected/select_views_1.out
src/test/regress/expected/select_views_1.out
+255
-0
src/test/regress/sql/select_views.sql
src/test/regress/sql/select_views.sql
+126
-0
No files found.
src/test/regress/expected/select_views.out
View file @
504f0c5d
This diff is collapsed.
Click to expand it.
src/test/regress/expected/select_views_1.out
View file @
504f0c5d
This diff is collapsed.
Click to expand it.
src/test/regress/sql/select_views.sql
View file @
504f0c5d
...
...
@@ -8,3 +8,129 @@ SELECT * FROM street;
SELECT
name
,
#
thepath
FROM
iexit
ORDER
BY
1
,
2
;
SELECT
*
FROM
toyemp
WHERE
name
=
'sharon'
;
--
-- Test for Leaky view scenario
--
CREATE
USER
alice
;
CREATE
FUNCTION
f_leak
(
text
)
RETURNS
bool
LANGUAGE
'plpgsql'
COST
0
.
0000001
AS
'BEGIN RAISE NOTICE
''
f_leak => %
''
, $1; RETURN true; END'
;
CREATE
TABLE
customer
(
cid
int
primary
key
,
name
text
not
null
,
tel
text
,
passwd
text
);
CREATE
TABLE
credit_card
(
cid
int
references
customer
(
cid
),
cnum
text
,
climit
int
);
CREATE
TABLE
credit_usage
(
cid
int
references
customer
(
cid
),
ymd
date
,
usage
int
);
INSERT
INTO
customer
VALUES
(
101
,
'alice'
,
'+81-12-3456-7890'
,
'passwd123'
),
(
102
,
'bob'
,
'+01-234-567-8901'
,
'beafsteak'
),
(
103
,
'eve'
,
'+49-8765-43210'
,
'hamburger'
);
INSERT
INTO
credit_card
VALUES
(
101
,
'1111-2222-3333-4444'
,
4000
),
(
102
,
'5555-6666-7777-8888'
,
3000
),
(
103
,
'9801-2345-6789-0123'
,
2000
);
INSERT
INTO
credit_usage
VALUES
(
101
,
'2011-09-15'
,
120
),
(
101
,
'2011-10-05'
,
90
),
(
101
,
'2011-10-18'
,
110
),
(
101
,
'2011-10-21'
,
200
),
(
101
,
'2011-11-10'
,
80
),
(
102
,
'2011-09-22'
,
300
),
(
102
,
'2011-10-12'
,
120
),
(
102
,
'2011-10-28'
,
200
),
(
103
,
'2011-10-15'
,
480
);
CREATE
VIEW
my_property_normal
AS
SELECT
*
FROM
customer
WHERE
name
=
current_user
;
CREATE
VIEW
my_property_secure
WITH
(
security_barrier
)
AS
SELECT
*
FROM
customer
WHERE
name
=
current_user
;
CREATE
VIEW
my_credit_card_normal
AS
SELECT
*
FROM
customer
l
NATURAL
JOIN
credit_card
r
WHERE
l
.
name
=
current_user
;
CREATE
VIEW
my_credit_card_secure
WITH
(
security_barrier
)
AS
SELECT
*
FROM
customer
l
NATURAL
JOIN
credit_card
r
WHERE
l
.
name
=
current_user
;
CREATE
VIEW
my_credit_card_usage_normal
AS
SELECT
*
FROM
my_credit_card_secure
l
NATURAL
JOIN
credit_usage
r
;
CREATE
VIEW
my_credit_card_usage_secure
WITH
(
security_barrier
)
AS
SELECT
*
FROM
my_credit_card_secure
l
NATURAL
JOIN
credit_usage
r
;
GRANT
SELECT
ON
my_property_normal
TO
public
;
GRANT
SELECT
ON
my_property_secure
TO
public
;
GRANT
SELECT
ON
my_credit_card_normal
TO
public
;
GRANT
SELECT
ON
my_credit_card_secure
TO
public
;
GRANT
SELECT
ON
my_credit_card_usage_normal
TO
public
;
GRANT
SELECT
ON
my_credit_card_usage_secure
TO
public
;
--
-- Run leaky view scenarios
--
SET
SESSION
AUTHORIZATION
alice
;
--
-- scenario: if a qualifier with tiny-cost is given, it shall be launched
-- prior to the security policy of the view.
--
SELECT
*
FROM
my_property_normal
WHERE
f_leak
(
passwd
);
EXPLAIN
(
COSTS
OFF
)
SELECT
*
FROM
my_property_normal
WHERE
f_leak
(
passwd
);
SELECT
*
FROM
my_property_secure
WHERE
f_leak
(
passwd
);
EXPLAIN
(
COSTS
OFF
)
SELECT
*
FROM
my_property_secure
WHERE
f_leak
(
passwd
);
--
-- scenario: if a qualifier references only one-side of a particular join-
-- tree, it shall be distributed to the most deep scan plan as
-- possible as we can.
--
SELECT
*
FROM
my_credit_card_normal
WHERE
f_leak
(
cnum
);
EXPLAIN
(
COSTS
OFF
)
SELECT
*
FROM
my_credit_card_normal
WHERE
f_leak
(
cnum
);
SELECT
*
FROM
my_credit_card_secure
WHERE
f_leak
(
cnum
);
EXPLAIN
(
COSTS
OFF
)
SELECT
*
FROM
my_credit_card_secure
WHERE
f_leak
(
cnum
);
--
-- scenario: an external qualifier can be pushed-down by in-front-of the
-- views with "security_barrier" attribute
--
SELECT
*
FROM
my_credit_card_usage_normal
WHERE
f_leak
(
cnum
)
AND
ymd
>=
'2011-10-01'
AND
ymd
<
'2011-11-01'
;
EXPLAIN
(
COSTS
OFF
)
SELECT
*
FROM
my_credit_card_usage_normal
WHERE
f_leak
(
cnum
)
AND
ymd
>=
'2011-10-01'
AND
ymd
<
'2011-11-01'
;
SELECT
*
FROM
my_credit_card_usage_secure
WHERE
f_leak
(
cnum
)
AND
ymd
>=
'2011-10-01'
AND
ymd
<
'2011-11-01'
;
EXPLAIN
(
COSTS
OFF
)
SELECT
*
FROM
my_credit_card_usage_secure
WHERE
f_leak
(
cnum
)
AND
ymd
>=
'2011-10-01'
AND
ymd
<
'2011-11-01'
;
--
-- Test for the case when security_barrier gets changed between rewriter
-- and planner stage.
--
PREPARE
p1
AS
SELECT
*
FROM
my_property_normal
WHERE
f_leak
(
passwd
);
PREPARE
p2
AS
SELECT
*
FROM
my_property_secure
WHERE
f_leak
(
passwd
);
EXECUTE
p1
;
EXECUTE
p2
;
RESET
SESSION
AUTHORIZATION
;
ALTER
VIEW
my_property_normal
SET
(
security_barrier
=
true
);
ALTER
VIEW
my_property_secure
SET
(
security_barrier
=
false
);
SET
SESSION
AUTHORIZATION
alice
;
EXECUTE
p1
;
-- To be perform as a view with security-barrier
EXECUTE
p2
;
-- To be perform as a view without security-barrier
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment