From 953e35275ae631a3f3fac7f328fc2dcde8d04173 Mon Sep 17 00:00:00 2001 From: Pierre-Marie Petit Date: Thu, 13 Nov 2025 16:41:49 +0100 Subject: [PATCH] exclude schemas --- dblinter/scan.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dblinter/scan.py b/dblinter/scan.py index 11a7e9f..986848b 100644 --- a/dblinter/scan.py +++ b/dblinter/scan.py @@ -13,6 +13,7 @@ from dblinter.database_connection import DatabaseConnection from dblinter.function_library import FunctionLibrary from dblinter.sarif_document import SarifDocument +from dblinter.function_library import EXCLUDED_SCHEMAS_STR DEFAULT_CONFIG_FILE_NAME = "default_config.yaml" PATH = "dblinter" @@ -98,7 +99,7 @@ def perform_schema_check(function_library, db, config_file, sarif_document, sche ) qry = f"""SELECT schema_name FROM information_schema.schemata pt - WHERE schema_name NOT IN ('pg_toast', 'pg_catalog', 'information_schema','public') + WHERE schema_name NOT IN ('{EXCLUDED_SCHEMAS_STR}') AND (schema_name = '{schema}' or '{schema}'='') AND schema_name not in ('aiven_extras') """ @@ -160,7 +161,7 @@ def perform_table_check( + "]" ) qry = f"""SELECT schemaname, tablename - FROM pg_catalog.pg_tables pt WHERE schemaname NOT IN ('pg_toast', 'pg_catalog', 'information_schema') + FROM pg_catalog.pg_tables pt WHERE schemaname NOT IN ('{EXCLUDED_SCHEMAS_STR}') AND (schemaname = '{schema}' or '{schema}'='') AND ((tablename ilike '{include}' or '{include}'='') AND (tablename not ilike '{exclude}' or '{exclude}'='')) AND (tablename not in ('schema_protection'))"""