Skip to content

Commit

Permalink
fix viewmodelservice
Browse files Browse the repository at this point in the history
  • Loading branch information
clemiller committed Feb 2, 2024
1 parent e842cc6 commit 153440c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 54 deletions.
41 changes: 0 additions & 41 deletions nav-app/src/app/services/viewmodels.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 0 additions & 13 deletions nav-app/src/app/tabs/tabs.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 153440c

Please sign in to comment.