ensure obfuscation only affects rendered values

The results to render may come from an in-memory cache, or from the database.
If they came from the in-memory cache, it's possible that obscurring the device
field could actually change the values in memory.  When obscurring, the device
field, this patch copies all of the values in order to ensure that the
in-memory copies are unaffected.  With this patch, cached objects should not be
affected.
This commit is contained in:
Ben West
2021-12-15 10:10:51 -08:00
parent a2f27514f1
commit 6b98e012bb
+5 -2
View File
@@ -1,10 +1,13 @@
var _ = require('lodash');
module.exports = function create_device_obscurity (env) {
function obscure_device (req, res, next) {
if (res.entries && env.settings.obscureDeviceProvenance) {
for (var i = 0; i < res.entries.length; i++) {
res.entries[i].device = env.settings.obscureDeviceProvenance;
var entries = _.cloneDeep(res.entries);
for (var i = 0; i < entries.length; i++) {
entries[i].device = env.settings.obscureDeviceProvenance;
}
res.entries = entries;
}
next( );
}