Exception: Can not anonymize objects of type class org.postgresql.util.PGobject
Opened this issue · 0 comments
halostatue commented
I received the exception Can not anonymize objects of type class org.postgresql.util.PGobject
when trying to use Anonimatron on a database. I expected no exception, and it feels like Anonimatron is trying to anonymize a column that isn’t in the configuration, since the jsonb
column isn’t part of the configuration.
Unfortunately, the error message isn’t specific enough as to which column is problematic.
Steps to reproduce the behaviour:
- I‘m using a PostgreSQL (9.6) database with the following table definition:
CREATE TABLE public.users (
id uuid NOT NULL,
username public.citext NOT NULL,
email public.citext NOT NULL,
encrypted_password text NOT NULL,
first_name text NOT NULL,
last_name text NOT NULL,
phone_number text,
phone_number_extension text,
data jsonb DEFAULT '{}'::jsonb NOT NULL,
type public.user_type NOT NULL,
status public.status NOT NULL,
creator_id uuid,
inserted_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
access jsonb DEFAULT '{}'::jsonb NOT NULL,
permissions text[] DEFAULT '{}'::text[] NOT NULL,
roles text[] DEFAULT '{}'::text[] NOT NULL,
last_purchase_date date,
total_savings integer DEFAULT 0 NOT NULL,
email_hash public.citext NOT NULL,
password_change_required boolean DEFAULT false NOT NULL,
password_set boolean DEFAULT false NOT NULL,
signup_type public.signup_type,
temporary_password text,
total_spending integer DEFAULT 0 NOT NULL,
purchase_count integer DEFAULT 0 NOT NULL,
deactivation_type public.deactivation_type,
deactivated_at timestamp without time zone,
deactivated_by_id uuid,
deactivated_in_id uuid,
customer_flags public.customer_flags[],
locale text DEFAULT 'en-CA'::text NOT NULL,
email_status public.email_status,
segment_id integer,
subsegment_id integer
);
I have omitted certain enum definitions, but they can be replaced with text
for testing purposes.
- I have the following
config.xml
file for Anonimatron:
<?xml version="1.0" encoding="UTF-8"?>
<configuration salt="examplesalt"
jdbcurl="jdbc:postgresql://HOST/DB" userid="postgres" password="postgres">
<anonymizerclass>my.demo.java.SmurfAnonymizer</anonymizerclass>
<anonymizerclass>org.sf.anonimatron.CommunityAnonymizer</anonymizerclass>
<table name="users">
<column name="username" type="RANDOMCHARACTERS" size="7">
<parameter id="characters">1234567890</parameter>
<discriminator columname="type" value="customer">
<column name="username" type="EMAIL_ADDRESS" />
</discriminator>
</column>
<column name="email" type="EMAIL_ADDRESS" />
<column name="first_name" type="ROMAN_NAME" />
<column name="last_name" type="ELVEN_NAME" />
<column name="phone_number" type="RANDOMCHARACTERS" size="10">
<parameter id="characters">1234567890</parameter>
</column>
</table>
</configuration>
- Start with
./anonimatron.sh -config config.xml -dryrun
- See error in log:
Anonymization process started
Jdbc url : jdbc:postgresql://localhost/lowes_loyalty_web_dev_prod
Database user : postgres
To do : 1 tables.
Anonymizing table 'users', total progress [0%, ETA 9:32:25 a.m.]Exception in thread "main" java.lang.RuntimeException: java.lang.UnsupportedOperationException: Can not anonymize objects of type class org.postgresql.util.PGobject
at com.rolfje.anonimatron.jdbc.JdbcAnonymizerService.processTableColumns(JdbcAnonymizerService.java:221)
at com.rolfje.anonimatron.jdbc.JdbcAnonymizerService.anonymizeTableInPlace(JdbcAnonymizerService.java:128)
at com.rolfje.anonimatron.jdbc.JdbcAnonymizerService.anonymize(JdbcAnonymizerService.java:81)
at com.rolfje.anonimatron.Anonimatron.anonymize(Anonimatron.java:94)
at com.rolfje.anonimatron.Anonimatron.main(Anonimatron.java:48)
Caused by: java.lang.UnsupportedOperationException: Can not anonymize objects of type class org.postgresql.util.PGobject
at com.rolfje.anonimatron.anonymizer.EmailAddressAnonymizer.anonymize(EmailAddressAnonymizer.java:26)
at com.rolfje.anonimatron.anonymizer.Anonymizer.anonymize(Anonymizer.java:57)
at com.rolfje.anonimatron.anonymizer.AnonymizerService.anonymize(AnonymizerService.java:92)
at com.rolfje.anonimatron.jdbc.JdbcAnonymizerService.lambda$anonymizeTableInPlace$2(JdbcAnonymizerService.java:115)
at com.rolfje.anonimatron.jdbc.JdbcAnonymizerService.processTableColumns(JdbcAnonymizerService.java:192)
... 4 more
/Users/austin/mess/2020/50/anonimatron-1.14
OS:
openjdk 13.0.2 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 13.0.2+8)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 13.0.2+8, mixed mode, sharing)