question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

encrypt mutilple tables association table not use encrypt

See original GitHub issue

encrypt mutiple table association table not use encrypt .

version 4.1.0

Question: Multi-table query only encrypt process first table, other table’s encrypt fields ignored。

Want to: i want to query and return all encrypted fields in all tables not just first table in sql;

it’s ok : tableA email is encrypt field

ShardingSphere-SQL - Logic SQL:  select A.email as email from tableA as A cross join tableB as B where A.key = B.key;
// query and return  A.email_encrypt , because tableA is left (first) side in sql;
ShardingSphere-SQL - Actual SQL: select A.email_encrypt as email from tableA as A cross join tableB as B where A.key = B.key;

it’s not:

ShardingSphere-SQL - Logic SQL:  select A.email as email from tableB as B cross join tableA as A where A.key = B.key;
// not query and return A.email_encrypt , because tableA is right side in sql;
ShardingSphere-SQL - Actual SQL: select A.email as email from tableB as B cross join tableA as A where A.key = B.key;

because this:

// EncryptProjectionTokenGenerator.java

@Override
    public Collection<SubstitutableColumnNameToken> generateSQLTokens(final SelectStatementContext selectStatementContext) {
        ProjectionsSegment projectionsSegment = selectStatementContext.getSqlStatement().getProjections();
        // TODO process multiple tables
        String tableName = selectStatementContext.getSqlStatement().getSimpleTableSegments().iterator().next().getTableName().getIdentifier().getValue();
        return getEncryptRule().findEncryptTable(tableName).map(
            encryptTable -> generateSQLTokens(projectionsSegment, tableName, selectStatementContext, encryptTable)).orElseGet(Collections::emptyList);
    }

Qustion:

if i just use ss’ encrypt feature, and single data point , may i rewrite to this ? rewrite all fields in all tables , not just left (first) table;

after:

@Override
    public Collection<SubstitutableColumnNameToken> generateSQLTokens(final SelectStatementContext selectStatementContext) {
        ProjectionsSegment projectionsSegment = selectStatementContext.getSqlStatement().getProjections();
        Iterator<SimpleTableSegment> simpleTableSegmentIterator = selectStatementContext.getSqlStatement().getSimpleTableSegments().iterator();
        Collection<SubstitutableColumnNameToken> results = new LinkedList<>();
        while (simpleTableSegmentIterator.hasNext()) {
            String tableName = simpleTableSegmentIterator.next().getTableName().getIdentifier().getValue();
            results.addAll(getEncryptRule().findEncryptTable(tableName).map(encryptTable ->
                generateSQLTokens(projectionsSegment, tableName, selectStatementContext, encryptTable)).orElseGet(Collections::emptyList));
        }
        return results;
    }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cheese8commented, Sep 24, 2021

#12504 #12462 It’s will be fixed util this pr merged.

0reactions
cheese8commented, Oct 27, 2021

merged and supported, it could be closed now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Encrypting the relationship between two database tables
Does there exist a common encryption scheme that securely encrypts client_id and lawyer_id without rendering the Join Table useless? encryption ...
Read more >
Always Encrypted - SQL Server - Microsoft Learn
Always Encrypted supports two encryption types: ... which aren't grouped with other records and aren't used to join tables.
Read more >
c# - Sql 2016 Always Encrypted - Join operation with ...
If you REALLY must join the two tables, you should encrypt both columns with deterministic encryption.
Read more >
How to Encrypt Specific Database Tables with CockroachDB
Find the table ranges; Find the encrypted and unencrypted store IDs; Confirm that the ranges from the tables are mapped to the correct...
Read more >
An overview of the column level SQL Server encryption
It is recommended to use the symmetric key for data encryption since we get excellent performance in it. For column encryption, we use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found