Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions dblinter.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -73,50 +73,40 @@ table:
fixes:
- create a primary key.
- name: TableWithRedundantIndex
ruleid: T003
ruleid: T002
enabled: True
context:
desc: table without duplicated index.
message: "{0} redundant(s) index found on {1}.{2} idx {3} column {4}."
fixes:
- remove duplicated index
- name: TableWithFkNotIndexed
ruleid: T004
ruleid: T003
enabled: True
context:
desc: table without index on fk.
message: "unindexed fk {0}.{1}.{2} ddl:{3}."
message: "Unindexed fk {0}.{1}.{2} ddl:{3}."
fixes:
- index foreign key.
- name: TableWithPotentialMissingIdx
ruleid: T005
- name: TableWithUnusedIndex
ruleid: T004
enabled: True
params:
- threshold: 1000000
- size_mo: 25
context:
desc: table with high level of seq scan vs idx scan, base on pg_stat_user_tables.
message: "{0} table with seq scan exceed the threshold: {1}."
desc: Table unused index, base on pg_stat_user_indexes, indexes associated to unique constraints are discard.
message: "Index {0} on {1} size {2} Mo seems to be unused (idx_scan=0)."
fixes:
- ask a dba.
- remove unused index or change warning/error threshold.
- name: TableWithFkOutsideSchema
ruleid: T006
ruleid: T007
enabled: True
context:
desc: table with fk outside its schema
message: "fk {0} on {1} is in schema {2}."
fixes:
- consider rewrite your model.
- ask a dba.
- name: TableWithUnusedIndex
ruleid: T007
enabled: True
params:
- size_mo: 25
context:
desc: Table unused index, base on pg_stat_user_indexes, indexes associated to unique constraints are discard.
message: "Index {0} on {1} size {2} Mo seems to be unused (idx_scan=0)."
fixes:
- remove unused index or change warning/error threshold.
- name: TableWithFkMismatch
ruleid: T008
enabled: True
Expand All @@ -142,6 +132,16 @@ table:
message: "{0} {1}.{2}.{3}.{4} violate retricted keyword rule."
fixes:
- Rename the object to use a non reserved keyword.
- name: TableWithPotentialMissingIdx
ruleid: T011
enabled: True
params:
- threshold: 1000000
context:
desc: table with high level of seq scan vs idx scan, base on pg_stat_user_tables.
message: "{0} table with seq scan exceed the threshold: {1}."
fixes:
- ask a dba.
schema:
- name: SchemaWithDefaultRoleNotGranted
ruleid: S001
Expand Down
48 changes: 24 additions & 24 deletions dblinter/default_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,50 +104,48 @@ table:
fixes:
- create a primary key.
- name: TableWithRedundantIndex
ruleid: T003
ruleid: T002
enabled: True
context:
desc: table without duplicated index.
message: "{0} redundant(s) index found on {1}.{2} idx {3} column {4}."
fixes:
- remove duplicated index
- name: TableWithFkNotIndexed
ruleid: T004
ruleid: T003
enabled: True
context:
desc: table without index on fk.
message: "unindexed fk {0}.{1}.{2}."
message: "Unindexed fk {0}.{1}.{2}."
fixes:
- "{3}."
- name: TableWithPotentialMissingIdx
ruleid: T005
- name: TableWithUnusedIndex
ruleid: T004
enabled: True
params:
- threshold: 1000000
- size_mo: 25
context:
desc: table with high level of seq scan vs idx scan, base on pg_stat_user_tables.
message: "{0} table with seq scan exceed the threshold: {1}."
desc: Table unused index, base on pg_stat_user_indexes, indexes associated to unique constraints are discard.
message: "Index {0} on {1} size {2} Mo seems to be unused (idx_scan=0)."
fixes:
- ask a dba.
- name: TableWithFkOutsideSchema
- remove unused index or change warning/error threshold.
- name: TableWithUppercase
ruleid: T006
enabled: True
context:
desc: table with fk outside its schema
message: "fk {0} on {1} is in schema {2}."
desc: Table with uppercase in name or in columns.
message: "Uppercase used on table {0}.{1}.{2}."
fixes:
- consider rewrite your model.
- ask a dba.
- name: TableWithUnusedIndex
- Do not use uppercase for any database objects
- name: TableWithFkOutsideSchema
ruleid: T007
enabled: True
params:
- size_mo: 25
context:
desc: Table unused index, base on pg_stat_user_indexes, indexes associated to unique constraints are discard.
message: "Index {0} on {1} size {2} Mo seems to be unused (idx_scan=0)."
desc: table with fk outside its schema
message: "fk {0} on {1} is in schema {2}."
fixes:
- remove unused index or change warning/error threshold.
- consider rewrite your model.
- ask a dba.
- name: TableWithFkMismatch
ruleid: T008
enabled: True
Expand All @@ -173,14 +171,16 @@ table:
message: "{0} {1}.{2}.{3}.{4} violate retricted keyword rule."
fixes:
- Rename the object to use a non reserved keyword.
- name: TableWithUppercase
- name: TableWithPotentialMissingIdx
ruleid: T011
enabled: True
params:
- threshold: 1000000
context:
desc: Table with uppercase in name or in columns.
message: "Uppercase used on table {0}.{1}.{2}."
desc: table with high level of seq scan vs idx scan, base on pg_stat_user_tables.
message: "{0} table with seq scan exceed the threshold: {1}."
fixes:
- Do not use uppercase for any database objects
- ask a dba.
- name: TableWithSensibleColumn
ruleid: T012
enabled: True
Expand Down
70 changes: 43 additions & 27 deletions tests/data/good_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,77 +71,93 @@ table:
desc: table without primary key.
message: "No primary key on table {0}.{1}.{2}."
fixes:
- create a primary key.
- create a primary key.
- name: TableWithRedundantIndex
ruleid: T003
ruleid: T002
enabled: True
context:
desc: table without duplicated index.
message: "{0} redundant(s) index found on {1}.{2} idx {3} column {4}."
fixes:
- remove duplicated index
- remove duplicated index
- name: TableWithFkNotIndexed
ruleid: T004
ruleid: T003
enabled: True
context:
desc: table without index on fk.
message: "unindexed fk {0}.{1}.{2} ddl:{3}."
message: "Unindexed fk {0}.{1}.{2}."
fixes:
- index foreign key.
- name: TableWithPotentialMissingIdx
ruleid: T005
- "{3}."
- name: TableWithUnusedIndex
ruleid: T004
enabled: True
params:
- threshold: 1000000
- size_mo: 25
context:
desc: table with high level of seq scan vs idx scan, base on pg_stat_user_tables.
message: "{0} table with seq scan exceed the threshold: {1}."
desc: Table unused index, base on pg_stat_user_indexes, indexes associated to unique constraints are discard.
message: "Index {0} on {1} size {2} Mo seems to be unused (idx_scan=0)."
fixes:
- ask a dba.
- name: TableWithFkOutsideSchema
- remove unused index or change warning/error threshold.
- name: TableWithUppercase
ruleid: T006
enabled: True
context:
desc: table with fk outside its schema
message: "fk {0} on {1} is in schema {2}."
desc: Table with uppercase in name or in columns.
message: "Uppercase used on table {0}.{1}.{2}."
fixes:
- consider rewrite your model.
- ask a dba.
- name: TableWithUnusedIndex
- Do not use uppercase for any database objects
- name: TableWithFkOutsideSchema
ruleid: T007
enabled: True
params:
- size_mo: 25
context:
desc: Table unused index, base on pg_stat_user_indexes, indexes associated to unique constraints are discard.
message: "Index {0} on {1} size {2} Mo seems to be unused (idx_scan=0)."
desc: table with fk outside its schema
message: "fk {0} on {1} is in schema {2}."
fixes:
- remove unused index or change warning/error threshold.
- consider rewrite your model.
- ask a dba.
- name: TableWithFkMismatch
ruleid: T008
enabled: True
context:
desc: table with fk mismatch, ex smallint refer to a bigint
message: "Type constraint mismatch: {0} on {1} column {2} (type {3}/{4}) ref {5} column {6} type ({7}/{8})."
fixes:
- consider rewrite your model.
- ask a dba.
- consider rewrite your model.
- ask a dba.
- name: TableWithRoleNotGranted
ruleid: T009
enabled: True
context:
desc: Table has no roles grantee. Meaning that users will need direct access on it (not through a role).
message: "No role grantee on table {0}.{1}.{2}. It means that except owner. Others will need a direct grant on this table, not through a role (unusual at dkt)."
fixes:
- create roles (myschema_ro & myschema_rw) and grant it on table with appropriate privileges.
- create roles (myschema_ro & myschema_rw) and grant it on table with appropriate privileges.
- name: ReservedKeyWord
ruleid: T010
enabled: True
context:
desc: A table, his column or indexes use reserved keywords.
message: "{0} {1}.{2}.{3}.{4} violate retricted keyword rule."
fixes:
- Rename the object to use a non reserved keyword.
- Rename the object to use a non reserved keyword.
- name: TableWithPotentialMissingIdx
ruleid: T011
enabled: True
params:
- threshold: 1000000
context:
desc: table with high level of seq scan vs idx scan, base on pg_stat_user_tables.
message: "{0} table with seq scan exceed the threshold: {1}."
fixes:
- ask a dba.
- name: TableWithSensibleColumn
ruleid: T012
enabled: True
context:
desc: Base on the extension anon (https://postgresql-anonymizer.readthedocs.io/en/stable/detection), show sensitive column.
message: "{0} have column {1} (category {2}) that can be consider has sensitive. It should be masked for non data-operator users."
fixes:
- Install extension anon, and create some masking rules on.
schema:
- name: SchemaWithDefaultRoleNotGranted
ruleid: S001
Expand Down