mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
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:
@@ -1,10 +1,13 @@
|
|||||||
|
var _ = require('lodash');
|
||||||
|
|
||||||
module.exports = function create_device_obscurity (env) {
|
module.exports = function create_device_obscurity (env) {
|
||||||
function obscure_device (req, res, next) {
|
function obscure_device (req, res, next) {
|
||||||
if (res.entries && env.settings.obscureDeviceProvenance) {
|
if (res.entries && env.settings.obscureDeviceProvenance) {
|
||||||
for (var i = 0; i < res.entries.length; i++) {
|
var entries = _.cloneDeep(res.entries);
|
||||||
res.entries[i].device = env.settings.obscureDeviceProvenance;
|
for (var i = 0; i < entries.length; i++) {
|
||||||
|
entries[i].device = env.settings.obscureDeviceProvenance;
|
||||||
}
|
}
|
||||||
|
res.entries = entries;
|
||||||
}
|
}
|
||||||
next( );
|
next( );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user