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

Pg_query integration #691

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Pg_query integration #691

wants to merge 14 commits into from

Conversation

Zhaars
Copy link
Contributor

@Zhaars Zhaars commented Nov 10, 2023

Integration of pg_query PostgreSQL parser into QueryDataEncryptor component. Split encryptor into PostgreSQL and MySQL components

Checklist

@Zhaars Zhaars requested a review from Lagovas November 10, 2023 17:01
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.

okay, read all changes, actually 3 files. see, that here we have new pg_query coder/decoder that handles a_const

tag me and specify files that should be reviewed, please, due to a lot of files have only import path changes

encryptor/postgresql/dbDataCoder.go Show resolved Hide resolved
# Conflicts:
#	cmd/acra-server/common/config.go
#	cmd/redis.go
#	encryptor/base/config_loader/config_loader.go
#	encryptor/base/config_loader/consul/storage.go
#	encryptor/base/config_loader/filesystem/storage.go
Fixed failing tests
@Zhaars Zhaars marked this pull request as ready for review December 5, 2023 16:00
@Zhaars Zhaars requested a review from Lagovas December 5, 2023 16:08
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.

i didn't finished review and stopped on 106/120 files, but I feeling that started reading diagonally *( will continue tomorrow

decryptor/postgresql/pg_decryptor.go Show resolved Hide resolved
decryptor/postgresql/pg_decryptor_test.go Show resolved Hide resolved
decryptor/postgresql/pg_decryptor_test.go Show resolved Hide resolved
encryptor/postgresql/queryDataEncryptor.go Outdated Show resolved Hide resolved
encryptor/postgresql/queryDataEncryptor.go Show resolved Hide resolved
encryptor/postgresql/queryDataEncryptor.go Outdated Show resolved Hide resolved
encryptor/postgresql/queryDataEncryptor.go Show resolved Hide resolved
encryptor/postgresql/queryDataEncryptor.go Outdated Show resolved Hide resolved
func (filter *SearchableQueryFilter) ChangeSearchableOperator(expr *pg_query.A_Expr) {
switch expr.Name[0].GetString_().GetSval() {
// sqlparser.NullSafeEqualStr, sqlparser.LikeStr, sqlparser.ILikeStr
case "=":
Copy link
Collaborator

Choose a reason for hiding this comment

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

we handle here only = operator? and stopped handling !=/<>? and ignore like/ilike?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice you found it. It can affect the EE part.

encryptor/postgresql/searchable_query_filter.go Outdated Show resolved Hide resolved

if expr.Rexpr.GetAConst() != nil || expr.Rexpr.GetParamRef() != nil || expr.Rexpr.GetTypeCast() != nil {
if len(expr.Name) == 1 {
if val := expr.Name[0].GetString_(); val != nil && (val.GetSval() == "=" || val.GetSval() == "<>") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we handle !=? as I remember, postgres accepts it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it accepts it but the parser represents it as <>. != is an alias of <>

https://www.postgresql.org/docs/current/functions-comparison.html

Copy link
Collaborator

Choose a reason for hiding this comment

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

I remember that for pgsql it's the same but not sure should we handle it explicitly here or parser converts != -> <>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the parser converts it to <>

examples/golang/src/example/example.go Outdated Show resolved Hide resolved
hmac/decryptor/mysql/hashQuery.go Show resolved Hide resolved
hmac/decryptor/mysql/hashQuery_test.go Show resolved Hide resolved
hmac/decryptor/mysql/hashQuery_test.go Outdated Show resolved Hide resolved
hmac/decryptor/postgresql/hashQuery_test.go Outdated Show resolved Hide resolved
@Zhaars Zhaars requested a review from Lagovas December 13, 2023 17:47
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.

None yet

2 participants