Obfuscate instance & add SHA256 tooltip

This commit is contained in:
David 2022-08-03 19:15:01 -07:00
parent 3f65a94be3
commit d02710d6e2
2 changed files with 20 additions and 3 deletions

View file

@ -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 }
})
}

View file

@ -65,7 +65,10 @@
v-for="entry in rejectInstances"
:key="entry.instance + '_reject'"
>
<td>{{ entry.instance }}</td>
<td
:title="entry.sha256"
:aria-label="entry.sha256"
>{{ entry.instance }}</td>
<td v-if="entry.reason === ''">
{{ $t("about.mrf.simple.not_applicable") }}
</td>