Skip to content

Commit

Permalink
Fix code style and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pablosnt committed Oct 7, 2024
1 parent cf08dee commit 921fcfa
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 66 deletions.
1 change: 0 additions & 1 deletion src/backend/findings/framework/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class Meta:


class TriageFindingFilter(FindingFilter):

class Meta:
model = OSINT
fields = {
Expand Down
1 change: 0 additions & 1 deletion src/backend/findings/queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def consume(execution: Execution, findings: list[Finding]) -> None:
Vulnerability,
Exploit,
]:

finding_type.objects.fix(
finding_type.objects.filter(
executions__in=completed_executions
Expand Down
1 change: 0 additions & 1 deletion src/backend/tests/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ def _setup_findings(self, execution: Execution) -> None:
"data": "admin",
"data_type": OSINTDataType.USER,
"source": "Google",
"reference": "https://any.com",
},
Host: {
"address": "10.10.10.10",
Expand Down
30 changes: 18 additions & 12 deletions src/frontend/components/finding/component/assets.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<template></template>
<template>
<v-container fluid>
<v-row dense>
<v-col v-for="finding in findings" :key="finding.id" cols="6" />
</v-row>
</v-container>
</template>

<!--
TODO:
Expand All @@ -12,14 +18,14 @@
Check all findings have the relationships needed on creation
-->

<script setup lang="ts">
defineProps({
api: Object,
findings: Array,
defectdojo: Object,
defectdojoSettings: Object,
hacktricks: Object,
});
defineEmits(["reload"]);
const enums = useEnums();
</script>
<script setup lang="ts">
defineProps({
api: Object,
findings: Array,
defectdojo: Object,
defectdojoSettings: Object,
hacktricks: Object,
});
defineEmits(["reload"]);
// const enums = useEnums();
</script>
14 changes: 10 additions & 4 deletions src/frontend/components/finding/component/vulnerabilities.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<template></template>
<template>
<v-container fluid>
<v-row dense>
<v-col v-for="finding in findings" :key="finding.id" cols="6" />
</v-row>
</v-container>
</template>

<!-- TODO:
Vulnerability (per Port or Technology) (new page)
Expand All @@ -7,7 +13,7 @@
Check all findings have the relationships needed on creation
-->

<script setup lang="ts">
<script setup lang="ts">
defineProps({
api: Object,
findings: Array,
Expand All @@ -16,5 +22,5 @@ defineProps({
hacktricks: Object,
});
defineEmits(["reload"]);
const enums = useEnums();
</script>
// const enums = useEnums();
</script>
98 changes: 55 additions & 43 deletions src/frontend/components/finding/page.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<template>
<v-tabs
v-model="tab"
align-tabs="center"
fixed-tabs
@update:model-value="tabChange()"
>
<v-tab
value="osint"
text="OSINT"
:prepend-icon="enums.findings.OSINT.icon"
color="red-darken-2"
/>
<v-tab
value="assets"
text="Assets"
:prepend-icon="enums.findings.Host.icon"
color="red-darken-2"
/>
<v-tab
value="vulnerabilities"
text="Vulnerabilities"
:prepend-icon="enums.findings.Vulnerability.icon"
color="red-darken-2"
/>
</v-tabs>
v-model="tab"
align-tabs="center"
fixed-tabs
@update:model-value="tabChange()"
>
<v-tab
value="osint"
text="OSINT"
:prepend-icon="enums.findings.OSINT.icon"
color="red-darken-2"
/>
<v-tab
value="assets"
text="Assets"
:prepend-icon="enums.findings.Host.icon"
color="red-darken-2"
/>
<v-tab
value="vulnerabilities"
text="Vulnerabilities"
:prepend-icon="enums.findings.Vulnerability.icon"
color="red-darken-2"
/>
</v-tabs>
<Dataset
v-if="api"
ref="dataset"
Expand All @@ -36,7 +36,7 @@
:emtpy-text="tabs[tab].emptyText"
@load-data="(data) => (findings = data)"
>
<template #data>
<template #data>
<v-tabs-window v-model="tab">
<v-tabs-window-item value="osint">
<FindingComponentOsint
Expand Down Expand Up @@ -89,40 +89,52 @@ const props = defineProps({
const route = useRoute();
const router = useRouter();
const enums = useEnums();
const dataset = ref(null);
const findings = ref([]);
// TODO: Filtering
const tabs = ref({
"osint": {
osint: {
endpoint: "/api/osint/",
icon: enums.findings.OSINT.icon,
emptyHead: "No OSINT findings",
emptyText: "Run some OSINT tool to identify some OSINT information about your targets",
filtering: []
emptyText:
"Run some OSINT tool to identify some OSINT information about your targets",
filtering: [],
},
"assets": {
assets: {
endpoint: "/api/osint/",
icon: enums.findings.Host.icon,
emptyHead: "No assets found",
emptyText: "Run some enumeration tool to identify some assets exposed by your targets",
filtering: []
emptyText:
"Run some enumeration tool to identify some assets exposed by your targets",
filtering: [],
},
"vulnerabilities": {
vulnerabilities: {
endpoint: "/api/osint/",
icon: enums.findings.Vulnerability.icon,
emptyHead: "No vulnerabilities found",
emptyText: "Run some vulnerability scan to identify some in your assets",
filtering: []
}
})
const tab = ref(route.query.tab && ['osint', 'assets', 'vulnerabilities'].includes(route.query.tab.toString().toLowerCase()) ? route.query.tab.toString().toLowerCase() : 'osint');
const dataset = ref(null);
const findings = ref([]);
filtering: [],
},
});
// TODO
const globalFiltering = [];
const api = computed(() => { return useApi(tabs.value[tab.value].endpoint, true) });
const filtering = computed(() => { return globalFiltering.concat(tabs.value[tab.value].filtering)});
const tab = ref(
route.query.tab &&
["osint", "assets", "vulnerabilities"].includes(
route.query.tab.toString().toLowerCase(),
)
? route.query.tab.toString().toLowerCase()
: "osint",
);
const api = computed(() => {
return useApi(tabs.value[tab.value].endpoint, true);
});
const filtering = computed(() => {
return globalFiltering.concat(tabs.value[tab.value].filtering);
});
const defaultParameters = ref(
props.execution
Expand All @@ -144,9 +156,9 @@ useApi("/api/defect-dojo/settings/", true)
function tabChange() {
if (props.matchPath) {
router.replace({ query: { tab: tab.value }})
router.replace({ query: { tab: tab.value } });
}
findings.value = []
findings.value = [];
dataset.value.loadData(true);
}
</script>
2 changes: 0 additions & 2 deletions src/frontend/components/finding/tool-counter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const props = defineProps({ finding: Object });
const tools = ref([]);
const counters = ref({});
for (let i = 0; i < props.finding.executions.length; i++) {
if (counters.value[props.finding.executions[i].configuration.tool.name]) {
counters.value[props.finding.executions[i].configuration.tool.name].count++;
Expand All @@ -50,5 +49,4 @@ for (let i = 0; i < props.finding.executions.length; i++) {
}
tools.value = Object.keys(counters.value);
</script>
2 changes: 0 additions & 2 deletions src/frontend/composables/enums.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type Link from "~/components/note/link.vue";

export function useEnums() {
const stages = {
OSINT: {
Expand Down

0 comments on commit 921fcfa

Please sign in to comment.