Skip to content

Commit e320a0f

Browse files
authored
fix(dblinter/S001-rule):skip scan for schema named public (#31)
1 parent c9a0c69 commit e320a0f

5 files changed

Lines changed: 18 additions & 13 deletions

File tree

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ repos:
44
rev: v4.3.0
55
hooks:
66
- id: check-yaml # Validates YAML files
7+
exclude: 'tests/data/config_file_syntax_error\.yaml'
78
- repo: local
89
hooks:
910
- id: isort
@@ -25,7 +26,7 @@ repos:
2526
stages: [commit]
2627
language: system
2728
types: [python]
28-
entry: poetry run ruff .
29+
entry: poetry run ruff check .
2930

3031
- id: pylint
3132
name: pylint

dblinter/default_config.yaml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ base:
5353
coef: 5
5454
resource_gain: Primary keys ensure no duplicates are present in the table.
5555
risk_impact: Duplicate rows possible, breaking data integrity. Replication failures, inefficient updates requiring full table scans. Severe performance degradation on large tables and logical replication issues.
56-
- name: HowManyRedudantIndex
56+
- name: HowManyRedundantIndex
5757
ruleid: B002
5858
enabled: True
5959
params:
@@ -77,9 +77,9 @@ base:
7777
desc: Count number of tables without index on foreign key.
7878
message: "{0} table without index on foreign key exceed the warning threshold: {1}%. Object list [{2}]"
7979
fixes:
80-
- Create a index on foreign key
80+
- Create an index on foreign key
8181
coef: 3
82-
resource_gain: Foreign keys indexes improve JOIN performance and enable efficient cascade operations.
82+
resource_gain: Foreign key indexes improve JOIN performance and enable efficient cascade operations.
8383
risk_impact: Extremely slow JOIN queries and cascade operations. DELETE/UPDATE on parent tables can lock child tables for extended periods, causing application timeouts and severe performance issues.
8484
- name: HowManyUnusedIndex
8585
ruleid: B004
@@ -216,8 +216,8 @@ table:
216216
ruleid: T010
217217
enabled: True
218218
context:
219-
desc: A table, his column or indexes use reserved keywords.
220-
message: "{0} {1}.{2}.{3}.{4} violate retricted keyword rule."
219+
desc: A table, its columns or indexes use reserved keywords.
220+
message: "{0} {1}.{2}.{3}.{4} violate restricted keyword rule."
221221
fixes:
222222
- Rename the object to use a non reserved keyword
223223
coef: 1
@@ -234,7 +234,7 @@ table:
234234
fixes:
235235
- Ask a DBA
236236
coef: 1
237-
resource_gain: Adding appropriate indexes to high-seqscan tables will improve query performance and reduces I/O load, freeing resources for other queries.
237+
resource_gain: Adding appropriate indexes to high-seqscan tables improves query performance and reduces I/O load, freeing resources for other queries.
238238
risk_impact: High sequential scan rates indicate missing indexes, causing severe performance issues. Full table scans consume excessive memory and I/O, potentially causing OOM errors and impacting all database users.
239239
- name: TableWithSensibleColumn
240240
ruleid: T012
@@ -246,13 +246,13 @@ table:
246246
- Install extension PostgreSQL Anonymizer, and create some masking rules on
247247
coef: 1
248248
resource_gain: Proper data classification and masking reduces compliance audit time. Enables safe data sharing for development and testing environments.
249-
risk_impact: GDPR/CCPA compliance violations risk with fines. Unprotected PII exposure in logs, backups, and non-production environments. Severe reputational damage risk.
249+
risk_impact: Risk of GDPR/CCPA compliance violations with fines. Unprotected PII exposure in logs, backups, and non-production environments. Severe reputational damage risk.
250250
schema:
251251
- name: SchemaWithDefaultRoleNotGranted
252252
ruleid: S001
253253
enabled: True
254254
context:
255-
desc: The schema ha no default role. Means that futur table will not be granted through a role. So you will have to re-execute grants on it.
255+
desc: The schema has no default role. Means that future tables will not be granted through a role. So you will have to re-execute grants on it.
256256
message: "No default role granted on schema {0}.{1}. It means that each time a table is created, you must grant it to roles."
257257
fixes:
258258
- "Add a default privilege=> ALTER DEFAULT PRIVILEGES IN SCHEMA <schema> for user <schema's owner>"
@@ -270,4 +270,3 @@ schema:
270270
coef: 2
271271
resource_gain: Environment-neutral naming simplifies refresh operations. Eliminates complex rename scripts.
272272
risk_impact: Complex and error-prone environment refresh procedures. Risk of broken references, failed migrations, and extended downtime during refresh operations. Potential data integrity issues.
273-

dblinter/rules/C003/PasswordEncryptionIsMd5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
def password_encryption_is_md5(
9-
self, db: DatabaseConnection, param, context, sarif_document
9+
self, db: DatabaseConnection, _param, context, sarif_document
1010
):
1111
LOGGER.debug("password_encryption_is_md5")
1212
password_encryption = db.query(

dblinter/rules/S001/SchemaWithDefaultRoleNotGranted.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ def schema_with_default_role_not_granted(
1212
LOGGER.debug(
1313
"schema_with_default_role_not_granted for %s in db %s", schema[0], db.database
1414
)
15+
16+
# Ignore the 'public' schema
17+
if schema[0] == "public":
18+
LOGGER.debug("Skipping 'public' schema")
19+
return
20+
1521
SCHEMA_WITH_ROLE_NOT_GRANTED = f"""SELECT count(*)
1622
FROM pg_catalog.pg_default_acl d
1723
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = d.defaclnamespace

dblinter/scan.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
from dblinter.configuration import Configuration
1212
from dblinter.configuration_model import ConfigurationModel
1313
from dblinter.database_connection import DatabaseConnection
14-
from dblinter.function_library import FunctionLibrary
14+
from dblinter.function_library import EXCLUDED_SCHEMAS_STR, FunctionLibrary
1515
from dblinter.sarif_document import SarifDocument
16-
from dblinter.function_library import EXCLUDED_SCHEMAS_STR
1716

1817
DEFAULT_CONFIG_FILE_NAME = "default_config.yaml"
1918
PATH = "dblinter"

0 commit comments

Comments
 (0)