Skip to content

Commit

Permalink
Introduce UI changes for ForensicArtifacts indicator type (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchop authored Feb 8, 2024
1 parent 0a99819 commit 2260de6
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 28 deletions.
6 changes: 2 additions & 4 deletions src/components/EditObject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { INDICATOR_TYPES } from "@/definitions/indicatorDefinitions.js";
import { OBSERVABLE_TYPES } from "@/definitions/observableDefinitions.js";
import { DFIQ_TYPES } from "@/definitions/dfiqDefinitions.js";
import ObjectFields from "@/components/ObjectFields.vue";
import { objectTypeAnnotation } from "@babel/types";
</script>

<script lang="ts">
Expand Down Expand Up @@ -84,11 +83,10 @@ export default {
this.isActive.value = false;
})
.catch(error => {
console.log(error);
this.errors = error.response.data.detail
.filter(detail => detail.loc[1] !== "type")
.filter(detail => detail["loc"][2].toLowerCase() === this.typeDefinition.type)
.map(detail => {
return { field: detail.loc[1], message: detail.msg };
return { field: detail["loc"][3], message: detail.msg };
});
})
.finally();
Expand Down
18 changes: 15 additions & 3 deletions src/components/ObjectList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
<template v-slot:item.relevant_tags="{ item }">
<v-chip v-for="name in item.relevant_tags" :text="name" class="mr-1" size="small"></v-chip>
</template>
<template v-slot:item.supported_os="{ item }">
<v-chip v-for="name in item.supported_os" :text="name" class="mr-1" size="small"></v-chip>
</template>
<template v-slot:item.dfiq_tags="{ item }">
<v-chip v-for="name in item.dfiq_tags" :text="name" class="mr-1" size="small"></v-chip>
</template>
Expand Down Expand Up @@ -142,11 +145,20 @@ export default {
}
return resultObj;
},
loadOjects({ page, itemsPerPage, sortBy }: { page: number; itemsPerPage: number; sortBy: string }) {
loadOjects({
page,
itemsPerPage,
sortBy
}: {
page: number;
itemsPerPage: number;
sortBy: Array<{ key: string; order: string }>;
}) {
let params = {
page: page - 1,
count: itemsPerPage,
query: this.extractParamsFromSearchQuery(this.searchQuery, "name")
count: itemsPerPage === -1 ? 0 : itemsPerPage,
query: this.extractParamsFromSearchQuery(this.searchQuery, "name"),
sorting: sortBy.map(sort => [sort.key, sort.order === "desc"])
};
if (this.searchSubtype != "") {
params["type"] = this.searchSubtype;
Expand Down
18 changes: 7 additions & 11 deletions src/components/RelatedObjects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default {
const souceType = data.source.type;
const targetType = data.target.type;
if (this.targetTypes.includes(targetType) || this.targetTypes.includes(souceType)) {
this.fetchNeighbors();
this.fetchNeighbors({ page: this.page, itemsPerPage: this.perPage });
}
});
},
Expand All @@ -159,7 +159,7 @@ export default {
fieldName = fieldName.replace(/_/g, " ");
return fieldName;
},
fetchNeighbors() {
fetchNeighbors({ page, itemsPerPage }: { page: number; itemsPerPage: number }) {
this.loading = true;
let graphSearchRequest = {
source: `${this.sourceType}/${this.id}`,
Expand All @@ -168,8 +168,8 @@ export default {
hops: this.hops,
direction: "any",
include_original: true,
count: this.perPage,
page: this.page - 1
count: itemsPerPage === -1 ? 0 : itemsPerPage,
page: page - 1
};
axios
Expand All @@ -189,18 +189,14 @@ export default {
axios
.delete(`/api/v2/graph/${id}`)
.then(() => {
this.fetchNeighbors();
this.fetchNeighbors({ page: this.page, itemsPerPage: this.perPage });
})
.catch(error => {
console.log(error);
});
},
getIconForType(type) {
return this.objectTypes.find(objectType => objectType.type === type).icon;
},
onPageChange(page) {
this.page = page;
this.fetchNeighbors();
}
},
computed: {
Expand Down Expand Up @@ -246,8 +242,8 @@ export default {
watch: {
id: function () {
this.page = 1;
this.total = 500;
this.fetchNeighbors();
this.perPage = 20;
this.fetchNeighbors({ page: this.page, itemsPerPage: this.perPage });
}
}
};
Expand Down
37 changes: 31 additions & 6 deletions src/definitions/indicatorDefinitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,47 @@ export const DIAMOND_MODEL = ["adversary", "capability", "infrastructure", "vict
export const QUERY_TYPES = ["opensearch", "osquery", "sql", "splunk", "censys", "shodan"];

export const INDICATOR_TYPES = [
{
name: "Forensic artifact",
type: "forensicartifact",
fields: [
{ field: "created", type: "date", label: "Created", displayList: true, editable: false, width: "170px" },
{ field: "name", type: "text", label: "Name", displayList: true, editable: true },
{ field: "pattern", type: "code", label: "Pattern", displayList: false, editable: true },
{ field: "relevant_tags", type: "list", label: "Relevant tags", displayList: true, editable: true },
{ field: "aliases", type: "list", label: "Aliases", displayList: false, editable: true },
{ field: "supported_os", type: "list", label: "Supported OS", displayList: true, editable: true, width: "140px" },
{ field: "location", type: "text", label: "Location", displayList: false, editable: true },
{
field: "diamond",
type: "option",
choices: DIAMOND_MODEL,
label: "Diamond model",
displayList: true,
editable: true,
width: "160px"
},
{ field: "description", type: "longtext", label: "Description", displayList: false, editable: true }
],
icon: "mdi-script-text-outline"
},
{
name: "Regular expression",
type: "regex",
fields: [
{ field: "created", type: "date", label: "Created", displayList: true, editable: false, width: "200px" },
{ field: "created", type: "date", label: "Created", displayList: true, editable: false, width: "170px" },
{ field: "name", type: "text", label: "Name", displayList: true, editable: true },
{ field: "pattern", type: "code", label: "Pattern", displayList: false, editable: true },
{ field: "relevant_tags", type: "list", label: "Relevant tags", displayList: true, editable: true },
{ field: "location", type: "text", label: "Location", displayList: true, editable: true },
{ field: "location", type: "text", label: "Location", displayList: false, editable: true },
{
field: "diamond",
type: "option",
choices: DIAMOND_MODEL,
label: "Diamond model",
displayList: true,
editable: true
editable: true,
width: "160px"
},
{ field: "description", type: "longtext", label: "Description", displayList: false, editable: true }
],
Expand All @@ -40,7 +65,7 @@ export const INDICATOR_TYPES = [
editable: true
},
{ field: "target_systems", type: "list", label: "Target systems", displayList: true, editable: true },
{ field: "location", type: "text", label: "Location", displayList: true, editable: true },
{ field: "location", type: "text", label: "Location", displayList: false, editable: true },
{
field: "diamond",
type: "option",
Expand All @@ -61,7 +86,7 @@ export const INDICATOR_TYPES = [
{ field: "name", type: "text", label: "Name", displayList: true, editable: true },
{ field: "pattern", type: "code", label: "Rule text", displayList: false, editable: true },
{ field: "relevant_tags", type: "list", label: "Relevant tags", displayList: true, editable: true },
{ field: "location", type: "text", label: "Location", displayList: true, editable: true },
{ field: "location", type: "text", label: "Location", displayList: false, editable: true },
{
field: "diamond",
type: "option",
Expand All @@ -82,7 +107,7 @@ export const INDICATOR_TYPES = [
{ field: "name", type: "text", label: "Name", displayList: true, editable: true },
{ field: "pattern", type: "code", label: "Rule text", displayList: false, editable: true },
{ field: "relevant_tags", type: "list", label: "Relevant tags", displayList: true, editable: true },
{ field: "location", type: "text", label: "Location", displayList: true, editable: true },
{ field: "location", type: "text", label: "Location", displayList: false, editable: true },
{
field: "diamond",
type: "option",
Expand Down
8 changes: 4 additions & 4 deletions src/views/ObjectDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
</v-card>
<v-card v-if="object?.pattern" class="ma-2" variant="flat">
<v-card-title>Pattern</v-card-title>
<v-card-text class="yeti-pattern-code"
><code>{{ object.pattern }}</code></v-card-text
></v-card
<v-card-text class="yeti-pattern-code">
<pre>{{ object.pattern }}</pre>
</v-card-text></v-card
>
</v-col>
<v-col cols="4">
Expand Down Expand Up @@ -264,7 +264,7 @@ export default {
.then(response => {
let tagNames: string[] = [];
this.object = response.data;
this.objectTags = Object.keys(this.object.tags);
this.objectTags = this.object.tags ? Object.keys(this.object.tags) : [];
})
.catch(error => {
console.log(error);
Expand Down

0 comments on commit 2260de6

Please sign in to comment.