realrolfje/anonimatron

Please provide 'mask' with a digit mask in the form 111******

Closed this issue · 6 comments

Hi,
I am replacing an integer column with RANDOMDIGITS in MySQL database, I have an error, can you help me? Many thanks.

Anonymizing table 'lastnames', total progress [57%, ETA 9:05:59 AM]Exception in thread "main" java.lang.RuntimeException: java.lang.UnsupportedOperationException: Please provide 'mask' with a digit mask in the form 111******, where only stars are replaced with random characters.
at com.rolfje.anonimatron.jdbc.JdbcAnonymizerService.processTableColumns(JdbcAnonymizerService.java:242)
at com.rolfje.anonimatron.jdbc.JdbcAnonymizerService.anonymizeTableInPlace(JdbcAnonymizerService.java:152)
at com.rolfje.anonimatron.jdbc.JdbcAnonymizerService.anonymize(JdbcAnonymizerService.java:92)
at com.rolfje.anonimatron.Anonimatron.anonymize(Anonimatron.java:94)
at com.rolfje.anonimatron.Anonimatron.main(Anonimatron.java:48)
Caused by: java.lang.UnsupportedOperationException: Please provide 'mask' with a digit mask in the form 111******, where only stars are replaced with random characters.
at com.rolfje.anonimatron.anonymizer.DigitStringAnonymizer.anonymize(DigitStringAnonymizer.java:20)
at com.rolfje.anonimatron.anonymizer.AnonymizerService.anonymize(AnonymizerService.java:92)
at com.rolfje.anonimatron.jdbc.JdbcAnonymizerService$2.processColumn(JdbcAnonymizerService.java:138)
at com.rolfje.anonimatron.jdbc.JdbcAnonymizerService.processTableColumns(JdbcAnonymizerService.java:213)
... 4 more

Can you provide the configuration you are using to anynmize the table?

I'm following this link: https://realrolfje.github.io/anonimatron/documentation/
Datatype of 'creditcardbr' column in Mysql is Varchar(20) like your documentation.
In config.xml file, I also set column name="creditcardnr" type="RANDOMDIGITS" like your documentation.
But I have this error:
Anonymizing table 'userdata', total progress [0%, ETA 9:50:31 AM]Exception in thread "main" java.lang.RuntimeException: java.lang.UnsupportedOperationException: Please provide 'mask' with a digit mask in the form 111******, where only stars are replaced with random characters.
at com.rolfje.anonimatron.jdbc.JdbcAnonymizerService.processTableColumns(JdbcAnonymizerService.java:242)
......

I have tried to change datatype of 'creditcardbr' column in Mysql from Varchar(20) to Int(11) but nothing changed :(

The datatype of the table should be varchar. I can try to reproduce your problem later today, it feels like there is a problem with your configuration, or the way defaults are handled in Anonimatron.

It took a bit of time, sorry. It turns out that this is a bug in the configuration code of Anonimatron. There was a check for the newly added mask parameter, but it assumes that this configuration is always there. The workaround would be to add a "mask" configuration parameter to the column, like so:

<column name="creditcardnr" type="RANDOMDIGITS">
  <parameter id="mask">*</parameter>
</column>

Sorry for the inconvenience, I am working on a solution and a unittest to prevent this from happening in the next release.

Solved in develop branch, will be part of release 1.14