Skip to content

Commit

Permalink
chore: fix some sql scrubber thingies
Browse files Browse the repository at this point in the history
  • Loading branch information
mrnagydavid committed Jul 18, 2024
1 parent dc974ed commit 11957c3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/scrubbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,9 @@ export const saltedHashSubstringScrubberSQL: SaltedHashSubstringScrubberSQLFn =
_assert(params?.initializationVector, 'Initialization vector is missing')
_assert(params?.regex, 'Substring or regex is missing')

const substringToReplace = `REGEXP_SUBSTR(${sqlValueToReplace}, ${params.regex})`
const substringToReplace = `COALESCE(REGEXP_SUBSTR(${sqlValueToReplace}, '${params.regex}'), '')`
const hashedValue = `SHA2(${substringToReplace} || '${params.initializationVector}', 256)`
const replacedValue = `REGEXP_REPLACE(${sqlValueToReplace}, ${params.regex}, ${hashedValue})`
const replacedValue = `REGEXP_REPLACE(${sqlValueToReplace}, '${params.regex}', ${hashedValue})`

return replacedValue
}
Expand Down

0 comments on commit 11957c3

Please sign in to comment.