This section contains a text replacement implementation that is fast and scalable. More...
Typedefs | |
typedef void * | ruCleaner |
typedef rusize_s(* | rcWriteFn) (perm_ptr ctx, trans_ptr buf, rusize len) |
typedef rusize_s(* | rcReadFn) (perm_ptr ctx, ptr buf, rusize len) |
typedef void(* | ruCleanerCb) (perm_ptr user_data, trans_chars key, trans_chars subst) |
Functions | |
RUAPI ruCleaner | ruCleanNew (rusize chunkSize) |
Creates a new ruCleaner object. To be freed with ruCleanFree. More... | |
RUAPI ruCleaner | ruCleanFree (ruCleaner rc) |
RUAPI int32_t | ruCleanDump (ruCleaner cp, ruCleanerCb lf, perm_ptr user_data) |
RUAPI int32_t | ruCleanAdd (ruCleaner rc, trans_chars instr, trans_chars substitute) |
RUAPI int32_t | ruCleanRemove (ruCleaner rc, trans_chars instr) |
RUAPI int32_t | ruCleanIo (ruCleaner rc, rcReadFn reader, perm_ptr readCtx, rcWriteFn writer, perm_ptr writeCtx) |
Does replacements using the given I/O functions. More... | |
RUAPI int32_t | ruCleanToWriter (ruCleaner rc, trans_chars in, rusize len, rcWriteFn writer, perm_ptr writeCtx) |
Does replacements on given string using the given Output function. More... | |
RUAPI int32_t | ruCleanToString (ruCleaner rc, trans_chars in, rusize len, ruString *out) |
Does replacements in given string and returns out in given String Object. More... | |
This section contains a text replacement implementation that is fast and scalable.
It is meant to be used to clean credentials out of large files in a minimum amount of time.
Example:
The type function for the read operation when cleaning a data stream.
The type function for the write operation when cleaning a data stream.
typedef void* ruCleaner |
Opaque pointer to cleaner object. See Data Cleaning Utility
typedef void(* ruCleanerCb) (perm_ptr user_data, trans_chars key, trans_chars subst) |
A callback for the ruCleanDump function. The given key and subst parameters belong to the cleaner and must not be freed.
user_data | The optional context that was given to ruCleanDump. |
key | The secret key to clean. |
subst | The placeholder to substitute the secret with. |
RUAPI int32_t ruCleanAdd | ( | ruCleaner | rc, |
trans_chars | instr, | ||
trans_chars | substitute | ||
) |
Adds a new string to be replaced.
rc | The relevant ruCleaner object |
instr | The string to be replaced. Will be copied. |
substitute | The string to replace instr with. Will be copied. |
RUAPI int32_t ruCleanDump | ( | ruCleaner | cp, |
ruCleanerCb | lf, | ||
perm_ptr | user_data | ||
) |
Iterates over the cleaner database and calls given ruCleanerCb with each secret and substitute. This function is mainly used for debugging.
cp | The relevant ruCleaner object |
lf | The ruCleanerCb to call with each entry |
user_data | An optional context that will be given to the callbacks user_data parameter. |
Frees the given ruCleaner object.
rc | list to free. |
RUAPI int32_t ruCleanIo | ( | ruCleaner | rc, |
rcReadFn | reader, | ||
perm_ptr | readCtx, | ||
rcWriteFn | writer, | ||
perm_ptr | writeCtx | ||
) |
Does replacements using the given I/O functions.
This can be an opened file with the corresponding file handle as context. This function may be called multiple times and interchangeably with the ruCleanTo* functions.
rc | The relevant ruCleaner object |
reader | The read function to be called for data input. |
readCtx | The context to be passed to the read function. |
writer | The write function to be called for data output. |
writeCtx | The context to be passed to the write function. |
Creates a new ruCleaner object. To be freed with ruCleanFree.
Unless the ruCleaner comes from a pwcleaner library which lacks the remaining regify-util functionality, it is made thread safe by the internal use of a mutex. pwcleaner users need to do their own locking in multi threaded use cases.
chunkSize | Size of chunk to process at a time. Will be allocated twice. Will be increased to the largest item to clean if that is bigger. Defaults to 1M if set to 0. |
RUAPI int32_t ruCleanRemove | ( | ruCleaner | rc, |
trans_chars | instr | ||
) |
Removes a string entry from the database.
rc | The relevant ruCleaner object |
instr | The string to be removed |
RUAPI int32_t ruCleanToString | ( | ruCleaner | rc, |
trans_chars | in, | ||
rusize | len, | ||
ruString * | out | ||
) |
Does replacements in given string and returns out in given String Object.
This function may be called multiple times and interchangeably with the ruCleanTo*, ruCleanIo functions. This function is thread safe but locks allow only one thread at time.
rc | The relevant ruCleaner object |
in | String to replace tokens in. |
len | Length of the string or 0 to use the null terminator for length detection. |
out | Where the String Object containing the result will be stored. Caller must free with ruStringFree after use. |
RUAPI int32_t ruCleanToWriter | ( | ruCleaner | rc, |
trans_chars | in, | ||
rusize | len, | ||
rcWriteFn | writer, | ||
perm_ptr | writeCtx | ||
) |
Does replacements on given string using the given Output function.
This can be an opened file with the corresponding file handle as context. This function may be called multiple times and interchangeably with the ruCleanTo*, ruCleanIo functions. This function is thread safe but locks allow only one thread at time.
rc | The relevant ruCleaner object |
in | String to replace tokens in. |
len | Length of the string or 0 to use the null terminator for length detection. |
writer | The write function to be called for data output. |
writeCtx | The context to be passed to the write function. |