-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat(keystone): DOMA-10642 custom field for encrypted text #5450
base: main
Are you sure you want to change the base?
Conversation
packages/keystone/fields/SymmetricEncryptedText/Implementation.js
Outdated
Show resolved
Hide resolved
packages/keystone/fields/SymmetricEncryptedText/Implementation.js
Outdated
Show resolved
Hide resolved
…ypted by manager; Do not encrypt field before database, if it is encrypted; Enhance script; Rename field;
packages/keystone/fields/SymmetricEncryptedText/utils/decryptInfo.js
Outdated
Show resolved
Hide resolved
packages/keystone/fields/SymmetricEncryptedText/utils/decryptInfo.js
Outdated
Show resolved
Hide resolved
const errorStart = _getErrorStart(listKey, path) | ||
const encryptionManager = _getEncryptionManager(errorStart, options) | ||
set(options, 'encryptionManager', encryptionManager) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's hard to understand whats going on here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just need to provide EncryptionManager for fieldAdapter. FieldAdapter parses options before we can do something in constructor here, so must update "options" before super()
Quality Gate passedIssues Measures |
|
||
const compressors = { | ||
'noop': noop, | ||
'open-condo_brotli': require('./brotli'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An imports should be at the top
/** @type {Record<string, KeyDeriver>} */ | ||
const keyDerivers = { | ||
'noop': noop, | ||
'open-condo_pbkdf2-sha512': require('./pbkdf2'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imports should be at the top
throw new Error(`Algorithm ${algorithm} is not supported right now at ${versionId}.algorithm`) | ||
} | ||
if (SUGGESTIONS[cipherInfo.mode]) { | ||
console.warn(`${SUGGESTIONS[cipherInfo.mode]} at ${versionId}.algorithm`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s better to throw an error …
|
||
const keyLength = cipherInfo.keyLength | ||
|
||
if ((typeof secret !== 'string' && !(secret instanceof Buffer)) || isEmpty(secret)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please also check the length of the secret … And check it by bad password list (same as password).
|
||
const conf = require('@open-condo/config') | ||
|
||
const { compressors } = require('./compressors') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like a global const {[name]: function} it’s better to use consts like naming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s better to use this global cost for EncryptionVersion. I know too many cases and usually I need to write own EncryptionVersion …
|
||
const { compressors } = require('./compressors') | ||
const { EncryptionVersion } = require('./EncryptionVersion') | ||
const { keyDerivers } = require('./keyDerivers') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, looks like global consts mapping (like MESSAGE_META or any other)
Simplify work with encrypted data, remove 'keyField's, support different algorithms and secrets on same table
See README.md