Skip to content

fix(protect-dynamodb): Fixed bug when handling schema definitions #158

Merged
calvinbrewer merged 5 commits intomainfrom
bug/dynamo-missing-fields
Jun 12, 2025
Merged

fix(protect-dynamodb): Fixed bug when handling schema definitions #158
calvinbrewer merged 5 commits intomainfrom
bug/dynamo-missing-fields

Conversation

@calvinbrewer
Copy link
Contributor

@calvinbrewer calvinbrewer commented Jun 11, 2025

Fixed bug when handling schema definitions without an equality flag.

--- Original report

I think I found a bug, where phoneNumber is csColumn but no .equality, it is missing after encryptModel

{
  input: {
    id: '01ABCDEFGHIJKLMNOPQRSTUVWX',
    email: 'test.user@example.com', 
    address: '123 Main Street',
    createdAt: '2024-08-15T22:14:49.948Z',
    firstName: 'John',
    lastName: 'Smith',
    phoneNumber: '555-555-5555',
    companyName: 'Acme Corp',
    batteryBrands: ['Brand1', 'Brand2'],
    metadata: { role: 'admin' }
  },
  protectTable: {
    email: { cast_as: 'text', indexes: [Object] },
    firstName: { cast_as: 'text', indexes: [Object] },
    lastName: { cast_as: 'text', indexes: [Object] },
    phoneNumber: { cast_as: 'text', indexes: {} }
  },
  result: {
    data: {
      id: '01ABCDEFGHIJKLMNOPQRSTUVWX',
      email__hmac: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
      email__source: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
      address: '123 Main Street',
      createdAt: '2024-08-15T22:14:49.948Z',
      firstName__hmac: 'ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc',
      firstName__source: 'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd',
      lastName__hmac: 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
      lastName__source: 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
      companyName: 'Acme Corp',
      batteryBrands: [Array],
      metadata: [Object]
    }
  }
}

My schema

const dynamoCipherstashTestSchema = csTable('dynamo_cipherstash_test', {
  email: csColumn('email').equality(),
  firstName: csColumn('firstName').equality(),
  lastName: csColumn('lastName').equality(),
  phoneNumber: csColumn('phoneNumber'),
})

@calvinbrewer calvinbrewer changed the title fix(protect-dynamodb): Fixed bug when handling schema definitions wit… fix(protect-dynamodb): Fixed bug when handling schema definitions Jun 11, 2025
@calvinbrewer calvinbrewer merged commit 517253d into main Jun 12, 2025
1 check passed
@calvinbrewer calvinbrewer deleted the bug/dynamo-missing-fields branch June 12, 2025 02:06
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