Last active
February 11, 2021 21:20
-
-
Save tkh44/199295c10327aa46c2412b5130caebe8 to your computer and use it in GitHub Desktop.
Revisions
-
tkh44 revised this gist
Feb 11, 2021 . 1 changed file with 4 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -38,19 +38,11 @@ const createAttackMachine = Machine({ }, attackTypeSelection: { on: { SELECT_HOST: 'hostTarget', SELECT_CONTAINER: 'containerTarget', SELECT_KUBERNETES: "kubernetesTarget" } }, hostTarget: { on: { SUBMIT: { @@ -106,7 +98,7 @@ const createAttackMachine = Machine({ review: { on: { SUBMIT: "saving", OPEN_TARGET: "attackTypeSelection", OPEN_IMPACT: "impact", OPEN_SCHEDULE: "schedule" } -
tkh44 revised this gist
Feb 11, 2021 . 1 changed file with 36 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,14 +39,30 @@ const createAttackMachine = Machine({ attackTypeSelection: { on: { SELECTION: { target: "targetTypeSelected", actions: assign({ targetType: (_, event) => event.value }) } } }, targetTypeSelected: { always: [{ target: "host", cond: "isHostTarget" }, { target: "container", cond: "isContainerTarget" }, { target: "kubernetes", cond: "isKubernetesTarget" }] }, hostTarget: { on: { SUBMIT: { target: "impact", actions: assign({ target: (_, event) => event.value }) } } }, containerTarget: { on: { SUBMIT: { target: "impact", @@ -57,10 +73,20 @@ const createAttackMachine = Machine({ } }, kubernetesTarget: { on: { SUBMIT: { target: "impact", actions: assign({ target: (_, event) => event.value }) } } }, impact: { on: { SUBMIT: { target: "review", actions: assign({ impact: (_, event) => event.value }) @@ -70,7 +96,7 @@ const createAttackMachine = Machine({ schedule: { on: { SUBMIT: { target: "review", actions: assign({ schedule: (_, event) => event.value }) @@ -79,19 +105,19 @@ const createAttackMachine = Machine({ }, review: { on: { SUBMIT: "saving", OPEN_TARGET: "targetTypeSelected", OPEN_IMPACT: "impact", OPEN_SCHEDULE: "schedule" } }, saving: { on: { SUCCESS: { target: "attackTypeSelection" }, ERROR: { target: "review" } } } -
tkh44 revised this gist
Feb 11, 2021 . 1 changed file with 17 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,23 +39,23 @@ const createAttackMachine = Machine({ attackTypeSelection: { on: { SELECTION: { target: "target", actions: assign({ targetType: (_, event) => event.value }) } } }, target: { on: { SUBMIT: { target: "impact", actions: assign({ target: (_, event) => event.value }) } } }, impact: { on: { @@ -79,9 +79,10 @@ const createAttackMachine = Machine({ }, review: { on: { SUBMIT: 'saving', OPEN_TARGET: 'target', OPEN_IMPACT: 'impact', OPEN_SCHEDULE: 'schedule' } }, saving: { @@ -107,13 +108,13 @@ const createAttackMachine = Machine({ isKubernetesTarget: (context) => { return context.targetType === "KUBERNETES"; }, verifyHostTarget: (context) => { return context.targetType === "HOST"; }, verifyContainerTarget: (context) => { return context.targetType === "CONTAINER"; }, verifyKubernetesTarget: (context) => { return context.targetType === "KUBERNETES"; } } -
tkh44 revised this gist
Feb 11, 2021 . 1 changed file with 2 additions and 28 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -47,41 +47,15 @@ const createAttackMachine = Machine({ } }, targeting: { on: { SUBMIT: { target: "impact", actions: assign({ target: (_, event) => event.value }) } } }, impact: { on: { -
tkh44 revised this gist
Feb 11, 2021 . 1 changed file with 12 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -55,21 +55,30 @@ const createAttackMachine = Machine({ host: { on: { SUBMIT: { target: "impact", actions: assign({ target: (_, event) => event.value }) } } }, container: { on: { SUBMIT: { target: "impact", actions: assign({ target: (_, event) => event.value }) } } }, kubernetes: { on: { SUBMIT: { target: "impact", actions: assign({ target: (_, event) => event.value }) } } } -
tkh44 revised this gist
Feb 11, 2021 . 1 changed file with 3 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -55,24 +55,21 @@ const createAttackMachine = Machine({ host: { on: { SUBMIT: { target: "impact" } } }, container: { on: { SUBMIT: { target: "impact" } } }, kubernetes: { on: { SUBMIT: { target: "impact" } } } -
tkh44 revised this gist
Feb 11, 2021 . 1 changed file with 47 additions and 32 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -55,49 +55,64 @@ const createAttackMachine = Machine({ host: { on: { SUBMIT: { target: "impact", cond: "verifyHostTargeting" } } }, container: { on: { SUBMIT: { target: "impact", cond: "verifyContainerTargeting" } } }, kubernetes: { on: { SUBMIT: { target: "impact", cond: "verifyKubernetesTargeting" } } } }, impact: { on: { SUBMIT: { target: 'review', actions: assign({ impact: (_, event) => event.value }) } } }, schedule: { on: { SUBMIT: { target: 'review', actions: assign({ schedule: (_, event) => event.value }) } } }, review: { on: { SUBMIT: { target: 'saving' } } }, saving: { on: { SUCCESS: { target: 'attackTypeSelection' }, ERROR: { target: 'review' } } } } }, @@ -122,4 +137,4 @@ const createAttackMachine = Machine({ return context.targetType === "KUBERNETES"; } } }); -
tkh44 revised this gist
Feb 11, 2021 . No changes.There are no files selected for viewing
-
tkh44 revised this gist
Feb 11, 2021 . 1 changed file with 102 additions and 21 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,20 +1,19 @@ // Available variables: // - Machine // - interpret // - assign // - send // - sendParent // - spawn // - raise // - actions // - XState (all XState exports) const createAttackMachine = Machine({ id: "create-attack", initial: "loading", context: { targetType: "HOST", target: {}, impact: {}, schedule: {}, @@ -24,7 +23,7 @@ error: { on: { RETRY: { target: "loading", actions: assign({ retries: (context, event) => context.retries + 1 }) @@ -33,12 +32,94 @@ }, loading: { on: { SUCCESS: "attackTypeSelection", ERROR: "error" } }, attackTypeSelection: { on: { SELECTION: { target: "targeting", actions: assign({ targetType: (_, event) => event.value }) } } }, targeting: { always: [ { target: "host", cond: "isHostTarget" }, { target: "container", cond: "isContainerTarget" }, { target: "kubernetes", cond: "isKubernetesTarget" } ], host: { on: { SUBMIT: { target: 'impact', cond: 'verifyHostTargeting' } } }, container: { on: { SUBMIT: { target: 'impact', cond: 'verifyContainerTargeting' } } }, kubernetes: { on: { SUBMIT: { target: 'impact', cond: 'verifyKubernetesTargeting' } } } }, impact: { on: { always: '.categorySelection' }, state: { categorySelection: { on: { SELECT_CATEGORY: { target: '.attackSelection' } } }, categorySelection: { on: { SELECT_ATTACK: { target: '.attackSelection' } } } }, host: { type: "final" }, container: { type: "final" }, kubernetes: { type: "final" } } } }, { guards: { isHostTarget: (context) => { return context.targetType === "HOST"; }, isContainerTarget: (context) => { return context.targetType === "CONTAINER"; }, isKubernetesTarget: (context) => { return context.targetType === "KUBERNETES"; }, verifyHostTargeting: (context) => { return context.targetType === "HOST"; }, verifyContainerTargeting: (context) => { return context.targetType === "CONTAINER"; }, verifyKubernetesTargeting: (context) => { return context.targetType === "KUBERNETES"; } } }); -
tkh44 revised this gist
Feb 11, 2021 . 1 changed file with 14 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,34 +12,32 @@ const createAttackMachine = Machine({ id: 'create-attack', initial: 'loading', context: { targetType: 'hosts', target: {}, impact: {}, schedule: {}, retries: 0 }, states: { error: { on: { RETRY: { target: 'loading', actions: assign({ retries: (context, event) => context.retries + 1 }) } } }, loading: { on: { ERROR: 'error' } }, success: { type: 'final' } } }); -
tkh44 created this gist
Feb 11, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ // Available variables: // - Machine // - interpret // - assign // - send // - sendParent // - spawn // - raise // - actions // - XState (all XState exports) const createAttackMachine = Machine({ id: 'create-attack', initial: 'idle', context: { targetType: 'hosts' }, states: { idle: { on: { FETCH: 'loading' } }, loading: { on: { RESOLVE: 'success', REJECT: 'failure' } }, success: { type: 'final' }, failure: { on: { RETRY: { target: 'loading', actions: assign({ retries: (context, event) => context.retries + 1 }) } } } } });