UI: Remove duplicate credentials from report

This commit is contained in:
vakaris_zilius 2022-09-02 12:46:11 +00:00
parent 9cc11f6a09
commit 7dba3c4fed
1 changed files with 8 additions and 8 deletions

View File

@ -1,10 +1,10 @@
import {CredentialTypes, SecretTypes} from '../utils/CredentialTypes.js'; import {CredentialTypes, SecretTypes} from '../utils/CredentialTypes.js';
export function getAllUsernames(stolen, configured) { export function getAllUsernames(stolen, configured) {
let usernames = []; let usernames = new Set();
usernames.push(...getCredentialsUsernames(stolen)); usernames.add(...getCredentialsUsernames(stolen));
usernames.push(...getCredentialsUsernames(configured)); usernames.add(...getCredentialsUsernames(configured));
return usernames; return Array.from(usernames);
} }
export function getCredentialsUsernames(credentials) { export function getCredentialsUsernames(credentials) {
@ -19,20 +19,20 @@ export function getCredentialsUsernames(credentials) {
} }
export function getAllSecrets(stolen, configured) { export function getAllSecrets(stolen, configured) {
let secrets = []; let secrets = new Set();
for (let i = 0; i < stolen.length; i++) { for (let i = 0; i < stolen.length; i++) {
let secret = stolen[i]['secret']; let secret = stolen[i]['secret'];
if (secret !== null) { if (secret !== null) {
secrets.push(reformatSecret(secret)); secrets.add(reformatSecret(secret));
} }
} }
for (let i = 0; i < configured.length; i++) { for (let i = 0; i < configured.length; i++) {
let secret = configured[i]['secret']; let secret = configured[i]['secret'];
if (secret !== null) { if (secret !== null) {
secrets.push(reformatSecret(secret)); secrets.add(reformatSecret(secret));
} }
} }
return secrets; return Array.from(secrets);
} }
function reformatSecret(secret) { function reformatSecret(secret) {