Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null ponter exception if there's a discriminator without a corresponding top level column #86

Closed
pajtai opened this issue Mar 14, 2020 · 3 comments

Comments

@pajtai
Copy link
Contributor

pajtai commented Mar 14, 2020

Describe the bug
The config below produces a java.lang.NullPointerException

    <table name="wp_usermeta">
        <discriminator columnname="meta_key" value="first_name">
            <column name="meta_value" type="ROMAN_NAME"/>
        </discriminator>
   </table>

The config below does not, but then it anonymizes every meta_value entry:

    <table name="wp_usermeta">
        <column name="meta_value"/>
        <discriminator columnname="meta_key" value="first_name">
            <column name="meta_value" type="ROMAN_NAME"/>
        </discriminator>
    </table>

To Reproduce
Steps to reproduce the behavior:

  1. Create a database with the following contents:
wp_usermeta

meta_key: test, meta_value: don't anonymize
meta_key:first_name, meta_value: Bob A. Nonymizeme
  1. Configure Anonimatron as follows:
<?xml version="1.0" encoding="UTF-8"?>
<configuration jdbcurl="jdbc:mysql://localhost:3306/anon" userid="anon_user" password="1q2w3e4r">
    <table name="wp_usermeta">
        <discriminator columnname="meta_key" value="first_name">
            <column name="meta_value" type="ROMAN_NAME"/>
        </discriminator>
    </table>
</configuration>
  1. Start with the following command:
./anonimatron.sh -config config.xml -synonyms synonyms.xml
  1. See error in log:
Reading Synonyms from /vagrant/anonimatron-1.12/synonyms.xml ...[done].

Anonymization process started

Jdbc url      : jdbc:mysql://localhost:3306/anon
Database user : anon_user
To do         : 1 tables.

Pre-scanning table 'wp_usermeta', total progress  [6%, ETA 1:30:20 AM]Exception in thread "main" java.lang.RuntimeException: java.lang.NullPointerException
	at com.rolfje.anonimatron.jdbc.JdbcAnonymizerService.processTableColumns(JdbcAnonymizerService.java:227)
	at com.rolfje.anonimatron.jdbc.JdbcAnonymizerService.preScanTable(JdbcAnonymizerService.java:118)
	at com.rolfje.anonimatron.jdbc.JdbcAnonymizerService.anonymize(JdbcAnonymizerService.java:72)
	at com.rolfje.anonimatron.Anonimatron.anonymize(Anonimatron.java:90)
	at com.rolfje.anonimatron.Anonimatron.main(Anonimatron.java:44)
Caused by: java.lang.NullPointerException
	at com.rolfje.anonimatron.jdbc.JdbcAnonymizerService.getSelectStatement(JdbcAnonymizerService.java:321)
	at com.rolfje.anonimatron.jdbc.JdbcAnonymizerService.processTableColumns(JdbcAnonymizerService.java:158)
	... 4 more
/vagrant/anonimatron-1.12

Expected behavior
Only alters rows with a meta_key of first_name. Leaves all other rows unchanged.

Desktop (please complete the following information):

  • OS: macOS 10.15.3
  • Java version
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1, mixed mode, sharing)
@realrolfje
Copy link
Owner

That is a very detailed bug report, thank you for that! I'll look into this.

realrolfje pushed a commit that referenced this issue Jul 26, 2020
@realrolfje
Copy link
Owner

This was an interesting bug. It turned out that column definitions which are in the discriminator, but not in the table configuration cause anonimatron to not process that column, and when fixed, it would not anonimyze any of the columns in the discriminator configuration.
I added a test and a fix, this should solve the problem.
From release 1.14, you will be able to have a table configuration with just a descriminator containing column definitions.

realrolfje added a commit that referenced this issue Jul 26, 2020
@realrolfje
Copy link
Owner

Merged a fix for this issue to the develop branch, and should be part of release 1.14 of anonimatron.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants