From d02710d6e2c88a5d03dc9dff2a269450e5c2fd7a Mon Sep 17 00:00:00 2001 From: David Date: Wed, 3 Aug 2022 19:15:01 -0700 Subject: [PATCH] Obfuscate instance & add SHA256 tooltip --- .../mrf_transparency_panel.js | 18 ++++++++++++++++-- .../mrf_transparency_panel.vue | 5 ++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/components/mrf_transparency_panel/mrf_transparency_panel.js b/src/components/mrf_transparency_panel/mrf_transparency_panel.js index 3fde8106..5f021541 100644 --- a/src/components/mrf_transparency_panel/mrf_transparency_panel.js +++ b/src/components/mrf_transparency_panel/mrf_transparency_panel.js @@ -1,5 +1,17 @@ import { mapState } from 'vuex' import { get } from 'lodash' +import sha256 from 'crypto-js/sha256' + +/** Haven't checked admin-fe sorry */ +const OBFUSCATE = true + +const obfuscate = (instance) => { + const half = Math.floor(instance.length / 2) + const fourth = Math.ceil(half / 2) + const slices = instance.match(new RegExp(`(.{${fourth}})(.{${half}})(.*)`)) + slices[2] = slices[2].replace(/[^.]/g, '*') + return slices.slice(1, 4).join('') +} /** * This is for backwards compatibility. We originally didn't recieve @@ -9,10 +21,12 @@ import { get } from 'lodash' */ const toInstanceReasonObject = (instances, info, key) => { return instances.map(instance => { + const censored = OBFUSCATE ? obfuscate(instance) : instance + const crypt = sha256(instance).toString() if (info[key] && info[key][instance] && info[key][instance]['reason']) { - return { instance: instance, reason: info[key][instance]['reason'] } + return { instance: censored, reason: info[key][instance]['reason'], sha256: crypt } } - return { instance: instance, reason: '' } + return { instance: censored, reason: '', sha256: crypt } }) } diff --git a/src/components/mrf_transparency_panel/mrf_transparency_panel.vue b/src/components/mrf_transparency_panel/mrf_transparency_panel.vue index 1787fa07..c5342917 100644 --- a/src/components/mrf_transparency_panel/mrf_transparency_panel.vue +++ b/src/components/mrf_transparency_panel/mrf_transparency_panel.vue @@ -65,7 +65,10 @@ v-for="entry in rejectInstances" :key="entry.instance + '_reject'" > - {{ entry.instance }} + {{ entry.instance }} {{ $t("about.mrf.simple.not_applicable") }}