| Goal | Find views that do not have the security barrier option. |
|---|---|
| Notes | The query considers possibility that the security_barrier boolean value can be represented with literal "true", "on" or "1". |
| Type | Problem detection Each row in the result could represent a flaw in the design |
| Reliability | High Few or no false-positive results |
| License | MIT (opens in new tab) |
| Fixing Suggestion | Alter the view by adding the security_barrier option. |
| Data Source | INFORMATION_SCHEMA+system catalog |
| SQL Query |
|
SQL statements that help generate fixes for the identified problem.
Fix Action #1
WITH missing_barrier AS (SELECT
pg_namespace.nspname AS view_schema,
pg_class.relname AS view_name
FROM
pg_catalog.pg_class,
pg_catalog.pg_namespace
WHERE pg_catalog.pg_class.relnamespace=pg_catalog.pg_namespace.oid
AND relkind='v'
AND nspname NOT IN (SELECT schema_name
FROM information_schema.schemata
WHERE schema_name<>'public' AND
schema_owner='postgres' AND schema_name IS NOT NULL)
AND (pg_catalog.pg_class.reloptions::text!~*'security_barrier=(true|on|1)'
OR pg_catalog.pg_class.reloptions IS NULL))
SELECT format('ALTER VIEW %1$I.%2$I SET (security_barrier);', view_schema, view_name) AS statements
FROM missing_barrier
ORDER BY view_schema, view_name;Alter the view.
| SQL Query to Generate Fix | Description |
|---|---|
| Alter the view. |
Collections
This query belongs to the following collections:
Find problems automatically
Queries, that results point to problems in the database. Each query in the collection produces an initial assessment. However, a human reviewer has the final say as to whether there is a problem or not .
| Name | Description |
|---|---|
| Find problems automatically | Queries, that results point to problems in the database. Each query in the collection produces an initial assessment. However, a human reviewer has the final say as to whether there is a problem or not . |
Categories
This query is classified under the following categories:
Derived tables
Queries of this category provide information about the derived tables (views, materialized views), which are used to implement virtual data layer.
Security
Queries of this category provide information about the security measures.
| Name | Description |
|---|---|
| Derived tables | Queries of this category provide information about the derived tables (views, materialized views), which are used to implement virtual data layer. |
| Security | Queries of this category provide information about the security measures. |
Further reading and related materials: