Skip to content

Commit

Permalink
fix(dynamic-overview): retrieval data only when behaviorId is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
yassinrais committed May 4, 2024
1 parent fed46a8 commit d588a04
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/routes/(file)/files/[hash]/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fileMenu } from '$lib/data/menu';
import type { Menu, Saferwall } from '$lib/types';
import type { LayoutLoad } from './$types';

export const load = (async ({ parent, params, data, url }) => {
export const load = (async ({ parent, params, url }) => {
const parentData = await parent();

const { hash } = params;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<svelte:fragment slot="header">
<h1 class="text-2xl">Process Tree</h1>
</svelte:fragment>
<ProcessTreeView {behaviorId} {session} trees={processTree} parent={false} />
<ProcessTreeView {behaviorId} {session} trees={processTree} isChild={false} />
</Card>
</section>
</div>
13 changes: 8 additions & 5 deletions src/routes/(file)/files/[hash]/dynamic-overview/+page.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { SaferwallClient } from '$lib/clients/saferwall';
import { redirect } from '@sveltejs/kit';
import type { PageLoad } from '../$types';
import type { Saferwall } from '$lib/types';

export const load: PageLoad = async ({ parent }) => {
const {
session,
file: { default_behavior_id }
file: { default_behavior_id: behaviorId }
} = await parent();

const processArray = await new SaferwallClient(session).getFileProcessTree(default_behavior_id);
if (!behaviorId) {
throw redirect(307, './');
}

const processArray = await new SaferwallClient(session).getFileProcessTree(behaviorId);
return {
processArray,
behaviorId: default_behavior_id
behaviorId,
processArray
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@
}
};
onMount(() => fetchData());
onMount(() => {
if (behaviorId) {
fetchData();
}
});
</script>

<!-- svelte-ignore a11y-click-events-have-key-events -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
export let behaviorId: string;
export let session: Saferwall.Session;
export let parent = true;
export let isChild = true;
export let trees: Saferwall.Behaviors.NestedProcessTree[];
let processTableOpen: number[] = [];
Expand All @@ -21,7 +21,7 @@
};
</script>

<ul class={`flex flex-col divide-y ${parent ? 'border-t border-neutral-100 mt-6' : ''}`}>
<ul class={`flex flex-col divide-y ${isChild ? 'border-t border-neutral-100 mt-6' : ''}`}>
{#each trees as tree, index (tree.path)}
<li class:pl-12={tree.parent_pid === '0x0'} class:ml-12={tree.parent_pid !== '0x0'}>
<Expandable expandable={tree.children.length != 0}>
Expand Down Expand Up @@ -68,6 +68,7 @@
</div>
</svelte:fragment>
<svelte:fragment slot="expanded">
<!-- TODO: fetch children capabilities/events -->
<svelte:self trees={tree.children} />
</svelte:fragment>
</Expandable>
Expand Down

0 comments on commit d588a04

Please sign in to comment.