Todd Drinkwater
Todd Drinkwater

Reputation: 447

How can I query what security labels exist on a table?

Using the postgresql-anonymizer Postgres extension I've set security labels for masking on a number of columns.

e.g.

SECURITY LABEL FOR anon ON COLUMN "Customer"."firstName" IS 'MASKED WITH FUNCTION anon.fake_first_name()

I want a way to query if it's been added, and see what the label is. How do I do this?

Upvotes: 1

Views: 956

Answers (2)

daamien
daamien

Reputation: 111

To display all the masking rules declared in the current database, check out the anon.pg_masking_rules:

SELECT * FROM anon.pg_masking_rules;

https://postgresql-anonymizer.readthedocs.io/en/latest/declare_masking_rules/#listing-masking-rules

Upvotes: 0

Todd Drinkwater
Todd Drinkwater

Reputation: 447

Query pg_seclabels to find the table and columns the labels are assigned to.

objname will contain the table and column e.g. "Users"."firstName", label, as the name gives away, will contain the label. e.g. 'MASKED WITH FUNCTION anon.fake_first_name()

  SELECT objname, label
  FROM pg_seclabels
  WHERE provider = 'anon';

Upvotes: 1

Related Questions