Skip to content

Commit

Permalink
DFIQ fixes (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchop authored May 24, 2024
1 parent 6b02208 commit 8a70ff8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/components/DirectNeighbors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@

<template v-slot:item.relevant_node.tags="{ item }">
<v-chip
v-if="item.relevant_node.tags"
v-for="tag in Object.keys(item.relevant_node.tags)"
:key="tag"
class="mr-2"
Expand Down
34 changes: 21 additions & 13 deletions src/components/EntitySelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import axios from "axios";
import { ENTITY_TYPES } from "@/definitions/entityDefinitions.js";
import { INDICATOR_TYPES } from "@/definitions/indicatorDefinitions.js";
import { DFIQ_TYPES } from "@/definitions/dfiqDefinitions.js";
import _ from "lodash";
</script>
Expand Down Expand Up @@ -93,14 +94,18 @@ export default {
const params = { query: { name: searchQuery }, count: 20 };
const entities = (await axios.post("/api/v2/entities/search", params)).data.entities;
const indicators = (await axios.post("/api/v2/indicators/search", params)).data.indicators;
let items = entities.concat(indicators).map(item => {
return {
id: item.id,
root_type: item.root_type,
name: item.name,
type: item.type
};
});
const dfiq = (await axios.post("/api/v2/dfiq/search", params)).data.dfiq;
let items = entities
.concat(indicators)
.concat(dfiq)
.map(item => {
return {
id: item.id,
root_type: item.root_type,
name: item.name,
type: item.type
};
});
if (this.typeFilter.length > 0) {
items = items.filter(item => this.typeFilter.includes(item.type) || this.typeFilter.includes(item.root_type));
}
Expand All @@ -113,16 +118,19 @@ export default {
this.$emit("selected-object", this.selectedEntity);
},
getIconForType(type) {
return (ENTITY_TYPES.find(t => t.type === type) || INDICATOR_TYPES.find(t => t.type === type)).icon;
},
return (
ENTITY_TYPES.find(t => t.type === type) ||
INDICATOR_TYPES.find(t => t.type === type) ||
DFIQ_TYPES.find(t => t.type === type)
).icon;
}
},
computed: {
getHintForTypes() {
if (this.typeFilter.length > 0) {
return 'Filtering for ' + this.typeFilter.join(", ");
return "Filtering for " + this.typeFilter.join(", ");
} else {
return 'Filtering for all object types';
return "Filtering for all object types";
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/components/LinkObject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import axios from "axios";
import { ENTITY_TYPES } from "@/definitions/entityDefinitions.js";
import { INDICATOR_TYPES } from "@/definitions/indicatorDefinitions.js";
import { OBSERVABLE_TYPES } from "@/definitions/observableDefinitions.js";
import { DFIQ_TYPES } from "@/definitions/dfiqDefinitions.js";
import { LINK_SUGGESTIONS } from "@/definitions/linkSuggestions.js";
import EntitySelector from "@/components/EntitySelector.vue";
Expand Down Expand Up @@ -159,7 +160,8 @@ export default {
return (
ENTITY_TYPES.find(t => t.type === type) ||
INDICATOR_TYPES.find(t => t.type === type) ||
OBSERVABLE_TYPES.find(t => t.type === type)
OBSERVABLE_TYPES.find(t => t.type === type) ||
DFIQ_TYPES.find(t => t.type === type)
).icon;
}
},
Expand Down Expand Up @@ -187,14 +189,15 @@ export default {
return (LINK_SUGGESTIONS[this.object.type] || LINK_SUGGESTIONS[this.object.root_type])
.filter(
suggestion =>
suggestion.targets.includes(this.linkTarget.type) || suggestion.targets.includes(this.linkTarget.type)
suggestion.targets.includes(this.linkTarget.type) || suggestion.targets.includes(this.linkTarget.root_type)
)
.map(suggestion => suggestion.verb);
},
getIncomingLinkTypeSuggestions() {
return (LINK_SUGGESTIONS[this.linkTarget.type] || LINK_SUGGESTIONS[this.linkTarget.root_type])
.filter(
suggestion => suggestion.targets.includes(this.object.type) || suggestion.targets.includes(this.object.type)
suggestion =>
suggestion.targets.includes(this.object.type) || suggestion.targets.includes(this.object.root_type)
)
.map(suggestion => suggestion.verb);
},
Expand Down
7 changes: 6 additions & 1 deletion src/definitions/linkSuggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,10 @@ export const LINK_SUGGESTIONS = {
},
{ verb: "uses", targets: ["infrastructure"] }
],
vulnerability: []
vulnerability: [],
// DFIQ
scenario: [{ verb: "Uses DFIQ facet", targets: ["facet"] }],
facet: [{ verb: "Uses DFIQ question", targets: ["question"] }],
question: [{ verb: "Uses DFIQ approach", targets: ["approach"] }],
approach: [{ verb: "Uses indicator", targets: ["indicator"] }]
};

0 comments on commit 8a70ff8

Please sign in to comment.