From 153440c5553cd3d26ebb5fb35f51697484646ecf Mon Sep 17 00:00:00 2001 From: Charissa Miller <48832936+clemiller@users.noreply.github.com> Date: Fri, 2 Feb 2024 16:27:26 -0500 Subject: [PATCH] fix viewmodelservice --- .../src/app/services/viewmodels.service.ts | 41 ------------------- nav-app/src/app/tabs/tabs.component.spec.ts | 13 ------ 2 files changed, 54 deletions(-) diff --git a/nav-app/src/app/services/viewmodels.service.ts b/nav-app/src/app/services/viewmodels.service.ts index bbd6f1b6f..1c30d6755 100755 --- a/nav-app/src/app/services/viewmodels.service.ts +++ b/nav-app/src/app/services/viewmodels.service.ts @@ -106,47 +106,6 @@ export class ViewModelsService { // unexpected user input throw Error('math result ( ' + result + ' ) is not a number'); } - techniqueIDs.forEach((techniqueID) => { - let newTechniqueVM = new TechniqueVM(techniqueID); - let scope = {}; - let misses = 0; // number of times a VM is missing the value - scoreVariables.forEach(function (vm, key) { - let scoreValue: number; - if (!vm.hasTechniqueVM_id(techniqueID)) { - // missing technique - scoreValue = 0; - misses++; - } else { - // technique exists - let score = vm.getTechniqueVM_id(techniqueID).score; - if (score == '' || isNaN(Number(score))) { - scoreValue = 0; - misses++; - } else { - scoreValue = Number(score); - } - } - scope[key] = scoreValue; - }); - - // did at least one technique have a score for this technique? - if (misses < scoreVariables.size) { - let mathResult = evaluate(opSettings.scoreExpression, scope); - if (is.boolean(mathResult)) { - // boolean to binary - mathResult = mathResult ? '1' : '0'; - } else if (is.not.number(mathResult)) { - // unexpected user input - throw Error('math result ( ' + mathResult + ' ) is not a number'); - } - - newTechniqueVM.score = String(mathResult); - newViewModel.techniqueVMs.set(techniqueID, newTechniqueVM); - minScore = Math.min(minScore, mathResult); - maxScore = Math.max(maxScore, mathResult); - } - // don't record a result if none of VMs had a score for this technique - }); // apply result to all techniques newViewModel.initializeScoresTo = String(result); diff --git a/nav-app/src/app/tabs/tabs.component.spec.ts b/nav-app/src/app/tabs/tabs.component.spec.ts index 74e40e35b..db66dbb18 100755 --- a/nav-app/src/app/tabs/tabs.component.spec.ts +++ b/nav-app/src/app/tabs/tabs.component.spec.ts @@ -36,19 +36,6 @@ describe('TabsComponent', () => { "modified": "2001-01-01T01:01:00.000Z", "x_mitre_version": "1.0", } - let tacticSDO = { - "id": "tactic-0", - ...stixSDO, - "name": "Reconnaissance", - "type": "x-mitre-tactic", - "x_mitre_shortname": "reconnaissance", - "external_references": [ - { - "external_id": "TA0043", - "url": "https://attack.mitre.org/tactics/TA0043" - } - ] - } let templateSDO = { ...stixSDO, "type": "attack-pattern",