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

Add db-specific error #521

Merged
merged 30 commits into from
Apr 12, 2022
Merged

Conversation

G1gg1L3s
Copy link
Contributor

@G1gg1L3s G1gg1L3s commented Apr 7, 2022

One of the last PRs added support for type awareness. That allows defining types on values, which would be decrypted and returned from Acra, like string or int. It also added default values field in configs, which allows to specify which value to return, if some error (possibly decryption error) occurs.

This PR adds ability to chose, which action should be performed on (decryption) failure: either to return client specific error, like acra censor already can, or return default value.

Default action, if type awareness is enabled, is "error". The user can specify the "default" case together with a default value.

Checklist

decryptor/postgresql/data_encoder.go Outdated Show resolved Hide resolved
decryptor/postgresql/data_encoder.go Show resolved Hide resolved
decryptor/postgresql/data_encoder.go Outdated Show resolved Hide resolved
decryptor/postgresql/pg_decryptor.go Outdated Show resolved Hide resolved
decryptor/postgresql/pg_decryptor.go Outdated Show resolved Hide resolved
tests/test.py Outdated Show resolved Hide resolved
encryptor/config/common/encryptedTypes.go Outdated Show resolved Hide resolved
decryptor/postgresql/data_encoder.go Outdated Show resolved Hide resolved
decryptor/postgresql/data_encoder.go Outdated Show resolved Hide resolved
tests/test.py Outdated Show resolved Hide resolved
@G1gg1L3s G1gg1L3s requested a review from Lagovas April 11, 2022 16:16
Copy link
Collaborator

@Lagovas Lagovas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

finally lgtm. except... can we recognize error message in the python driver's exceptions in integration tests?

// `GetResponseOnFail`
ResponseOnFailEmpty ResponseOnFail = ""

// ResponseOnFailCiphertext indicates that raw cip value should be returned
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never saw cip as short form of ciphertext )) did you see somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, a lil typo :)

setting: &config.BasicColumnEncryptionSetting{
Tokenized: false,
DataType: "int32",
ResponseOnFail: "default_value",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, if you added own type for that with constants, maybe we should use them instead of hardcoded values?

Copy link
Contributor Author

@G1gg1L3s G1gg1L3s Apr 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard coded values are more readable, imho. Good tests should be readable - because review from the person is the only way to verify correctness of the tests.
But on the other hand, use of constants makes introducing changes (renames) easier. So, it makes sense. I'll do it

tests/test.py Outdated
self.engine2.execute(
sa.select([self.test_table])
.where(self.test_table.c.id == data['id']))
self.assertIn("encoding error", str(ex))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.assertIn("encoding error", str(ex))
self.assertIn("encoding error", str(ex))

this check doesn't call) because exception raised on previous row)
plus, better to check self.assertEqual(r'encoding error in column "value_str"\n', ex.exception.args[0])

Co-authored-by: Lagovas <lagovas.lagovas@gmail.com>
Copy link
Collaborator

@Lagovas Lagovas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@G1gg1L3s G1gg1L3s merged commit d9450f7 into master Apr 12, 2022
@G1gg1L3s G1gg1L3s deleted the G1gg1L3s/T2515-return-db-specific-error branch April 12, 2022 18:31
@G1gg1L3s G1gg1L3s mentioned this pull request May 4, 2022
7 tasks
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

Successfully merging this pull request may close these issues.

2 participants