Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Bulk Show/Hide feature #129

Merged
merged 59 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
a27798d
Blue team test updates (#123)
ccarpenter28 Apr 11, 2023
c47f3a7
beacon bulk setup
sharplessHQ Mar 3, 2023
986e43f
host bulk setup
sharplessHQ Mar 4, 2023
b148432
bulk edit popover
sharplessHQ Mar 4, 2023
c61c1b9
remove popover modifier
sharplessHQ Mar 4, 2023
99ef326
only showAll when toggle on
sharplessHQ Mar 6, 2023
0823a4e
toggleBeaconHidden resolver update
sharplessHQ Mar 9, 2023
e4f5c88
bulk show/hide beacons initial path done
sharplessHQ Mar 9, 2023
a0b34c1
bulk hide host only done
sharplessHQ Mar 10, 2023
e1be3a2
Host store change to distinguish host/server
sharplessHQ Mar 10, 2023
2f4acc3
take care of server in host from FE
sharplessHQ Mar 10, 2023
f2ee28e
bulk hide hostServer done
sharplessHQ Mar 10, 2023
c30eb02
useEffect to clear host/beacon groups
sharplessHQ Mar 10, 2023
f381732
backend beacon update from map to forLoop, cleanup
sharplessHQ Mar 14, 2023
cfd55d2
backend map to forLoop update
sharplessHQ Mar 15, 2023
a16107a
reused bulkEditBtn component for beacon/host
sharplessHQ Mar 15, 2023
8929766
multi command comment component out of Explore
sharplessHQ Mar 15, 2023
72ce986
resolver setHidden update the whole tree as a temp solution
sharplessHQ Mar 15, 2023
56e2e39
buld show/hide go through dialog
sharplessHQ Mar 15, 2023
b18fdfe
hook up dialog
sharplessHQ Mar 21, 2023
c8aba9b
refactor bulkEditPopover to use popoverBtn
sharplessHQ Mar 23, 2023
dd659ea
Add non-hideable entities endpoint
GoldingAustin Mar 29, 2023
5a7f698
query name update/regenerate
sharplessHQ Mar 29, 2023
8e7cba2
quickMeta beacon check ifCanHide
sharplessHQ Mar 31, 2023
ed35599
quickMeta host check ifCanHide
sharplessHQ Mar 31, 2023
4f95e97
rename last, beaconMeta check ifCanHide
sharplessHQ Mar 31, 2023
ec6f8c4
quickMeta, Server/Host/Beacon MetaTab all done
sharplessHQ Mar 31, 2023
c3834cf
take out bulkHandleClick
sharplessHQ Apr 1, 2023
e3075b7
bulk edit using queries
sharplessHQ Apr 3, 2023
9be022c
refactor hooks, still promise in meta...
sharplessHQ Apr 3, 2023
8d3322c
auto close bulkMeta menu when dialog onClose
sharplessHQ Apr 3, 2023
f69f815
dialog plurals update for bulkMeta count
sharplessHQ Apr 4, 2023
5277d3c
use checkNonHidden hooks for all meta tabs
sharplessHQ Apr 4, 2023
867d933
change typeName to beacons/hosts to match with backend
sharplessHQ Apr 5, 2023
8616d98
omg indeterminate state finally done for beacon/host checkbox...
sharplessHQ Apr 5, 2023
c392ef1
take out handleCheckbox to useMemo
sharplessHQ Apr 5, 2023
0fe045a
fixed retaining indeterminate state after hitting cancel
sharplessHQ Apr 5, 2023
f0e98da
fix bulk menuitem names
sharplessHQ Apr 5, 2023
80e2442
disable bulkShow/bulkHide when all unhidden/hidden
sharplessHQ Apr 7, 2023
8ad9573
Update checking hidden items
GoldingAustin Apr 7, 2023
d0c2d2e
remove bulkEdit status planned for spinner
sharplessHQ Apr 11, 2023
1e38f2d
fix blueteam quickmeta bug
sharplessHQ Apr 11, 2023
80867fe
clean up hooks
sharplessHQ Apr 11, 2023
079e7a3
TESTS: Hide last item; timeline updates; presentation mode nav (#115)
ccarpenter28 Mar 31, 2023
5df0323
Delete .moon cache files (#119)
arniebradfo Apr 6, 2023
c5a24b3
Fix non-hidable entities endpoint to handle tree paths
GoldingAustin Apr 12, 2023
8f009b4
Fix beacon hide check
GoldingAustin Apr 14, 2023
44cff93
fix beacon-resolver hidden
sharplessHQ Apr 14, 2023
c7a32c7
Fix host hide/show beacons when changing beacons
GoldingAustin Apr 14, 2023
fed07fa
Fix hiding beacons that are all destination beacons in host
GoldingAustin Apr 19, 2023
91cd9bd
Fix beacon host check for hiding
GoldingAustin Apr 19, 2023
05b1eaf
Fix beacon hidden host check
GoldingAustin Apr 19, 2023
d7c818a
Fix duplicate beacon ids in hidden check
GoldingAustin Apr 19, 2023
094d3e0
Only check destination of links that aren't hidden
GoldingAustin Apr 19, 2023
3a5b4c9
beacon route change for bulk
sharplessHQ Apr 20, 2023
660ce91
fix all resolvers return type of array
sharplessHQ Apr 21, 2023
071668f
Merge remote-tracking branch 'origin' into bulk-meta-feature-update
sharplessHQ Apr 21, 2023
33ff297
Merge remote-tracking branch 'origin' into bulk-meta-feature-update
sharplessHQ Apr 24, 2023
8aa3325
Updates to hide beacon tests to address new changes.
ccarpenter28 Apr 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion applications/client/src/store/campaign/campaign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { ExtendedModel, model, modelAction, modelClass, modelFlow, objectMap, pr
import { isDefined } from '../../components';
import type { CurrentItem } from '../../types';
import { CampaignViews } from '../../types';
// import type { BeaconModel, CommandGroupModel, LinkModel, SortOption, SortType } from '../graphql';
// import { CommandModel, SortDirection } from '../graphql';
import type { BeaconModel, CommandGroupModel, LinkModel } from '../graphql';
import { CommandModel, SortDirection, SortOption, SortType } from '../graphql';
import { disposeList } from '../util';
Expand Down Expand Up @@ -46,7 +48,20 @@ export class CampaignStore extends ExtendedModel(() => ({
fetchEnabled: prop<boolean>(true).withSetter(),
isLoading: prop<string>('').withSetter().withSetter(),
error: prop<string>('').withSetter(),
isLoadingCommands: prop<boolean>(false).withSetter(),

// Bulk Selection
hostGroupSelect: prop<{
groupSelect: boolean;
selectedHosts: string[];
selectedServers: string[];
hiddenCount: number;
}>(() => ({ groupSelect: false, selectedHosts: [], selectedServers: [], hiddenCount: 0 })).withSetter(),
beaconGroupSelect: prop<{
groupSelect: boolean;
selectedBeacons: string[];
hiddenCount: number;
}>(() => ({ groupSelect: false, selectedBeacons: [], hiddenCount: 0 })).withSetter(),
bulkSelectCantHideEntityIds: prop<string[]>(() => []).withSetter(),
},
})) {
@observable sortMemory: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* This is a mk-gql generated file, don't modify it manually */
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck

import { types, prop, tProp, Model, Ref, idProp } from 'mobx-keystone';
import { QueryBuilder } from 'mk-gql';

/**
* NonHidableEntitiesBase
* auto generated base class for the model NonHidableEntitiesModel.
*/
export class NonHidableEntitiesModelBase extends Model({
__typename: tProp('NonHidableEntities'),
beacons: prop<string[] | null>().withSetter(),
hosts: prop<string[] | null>().withSetter(),
servers: prop<string[] | null>().withSetter(),
}) {}

export class NonHidableEntitiesModelSelector extends QueryBuilder {
get beacons() {
return this.__attr(`beacons`);
}
get hosts() {
return this.__attr(`hosts`);
}
get servers() {
return this.__attr(`servers`);
}
}
export function selectFromNonHidableEntities() {
return new NonHidableEntitiesModelSelector();
}

export const nonHidableEntitiesModelPrimitives = selectFromNonHidableEntities().beacons.hosts.servers;
15 changes: 15 additions & 0 deletions applications/client/src/store/graphql/NonHidableEntitiesModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ExtendedModel, model } from 'mobx-keystone';
import { NonHidableEntitiesModelBase } from './NonHidableEntitiesModel.base';

/* A graphql query fragment builders for NonHidableEntitiesModel */
export {
selectFromNonHidableEntities,
nonHidableEntitiesModelPrimitives,
NonHidableEntitiesModelSelector,
} from './NonHidableEntitiesModel.base';

/**
* NonHidableEntitiesModel
*/
@model('NonHidableEntities')
export class NonHidableEntitiesModel extends ExtendedModel(NonHidableEntitiesModelBase, {}) {}
42 changes: 36 additions & 6 deletions applications/client/src/store/graphql/RootStore.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ import { HostMetaModel, hostMetaModelPrimitives, HostMetaModelSelector } from '.
import { ImageModel, imageModelPrimitives, ImageModelSelector } from './ImageModel';
import { LinkModel, linkModelPrimitives, LinkModelSelector } from './LinkModel';
import { LogEntryModel, logEntryModelPrimitives, LogEntryModelSelector } from './LogEntryModel';
import {
NonHidableEntitiesModel,
nonHidableEntitiesModelPrimitives,
NonHidableEntitiesModelSelector,
} from './NonHidableEntitiesModel';
import { OperatorModel, operatorModelPrimitives, OperatorModelSelector } from './OperatorModel';
import {
ParsingProgressModel,
Expand Down Expand Up @@ -152,6 +157,7 @@ export enum RootStoreBaseQueries {
queryLinks = 'queryLinks',
queryLogs = 'queryLogs',
queryLogsByBeaconId = 'queryLogsByBeaconId',
queryNonHidableEntities = 'queryNonHidableEntities',
queryOperators = 'queryOperators',
queryParsingProgress = 'queryParsingProgress',
queryPresentationItems = 'queryPresentationItems',
Expand Down Expand Up @@ -205,6 +211,7 @@ export class RootStoreBase extends ExtendedModel(
['Image', () => ImageModel],
['Link', () => LinkModel],
['LogEntry', () => LogEntryModel],
['NonHidableEntities', () => NonHidableEntitiesModel],
['Operator', () => OperatorModel],
['ParsingProgress', () => ParsingProgressModel],
['PresentationCommandGroup', () => PresentationCommandGroupModel],
Expand Down Expand Up @@ -627,6 +634,29 @@ export class RootStoreBase extends ExtendedModel(
return this.query<{ logsByBeaconId: LogEntryModel[] }>(
`query logsByBeaconId($beaconId: String!, $campaignId: String!) { logsByBeaconId(beaconId: $beaconId, campaignId: $campaignId) {
${typeof resultSelector === 'function' ? resultSelector(LogEntryModelSelector).toString() : resultSelector}
} }`,
variables,
options,
!!clean
);
}
@modelAction queryNonHidableEntities(
variables: { beaconIds?: string[]; campaignId: string; hostIds?: string[] },
resultSelector:
| string
| ((
qb: typeof NonHidableEntitiesModelSelector
) => typeof NonHidableEntitiesModelSelector) = nonHidableEntitiesModelPrimitives.toString(),
options: QueryOptions = {},
clean?: boolean
) {
return this.query<{ nonHidableEntities: NonHidableEntitiesModel }>(
`query nonHidableEntities($beaconIds: [String!], $campaignId: String!, $hostIds: [String!]) { nonHidableEntities(beaconIds: $beaconIds, campaignId: $campaignId, hostIds: $hostIds) {
${
typeof resultSelector === 'function'
? resultSelector(NonHidableEntitiesModelSelector).toString()
: resultSelector
}
} }`,
variables,
options,
Expand Down Expand Up @@ -1025,14 +1055,14 @@ export class RootStoreBase extends ExtendedModel(
}
// Toggle beacon hidden state
@modelAction mutateToggleBeaconHidden(
variables: { beaconId: string; campaignId: string },
variables: { beaconId?: string; beaconIds?: string[]; campaignId: string; setHidden?: boolean },
resultSelector:
| string
| ((qb: typeof BeaconModelSelector) => typeof BeaconModelSelector) = beaconModelPrimitives.toString(),
optimisticUpdate?: () => void
) {
return this.mutate<{ toggleBeaconHidden: BeaconModel }>(
`mutation toggleBeaconHidden($beaconId: String!, $campaignId: String!) { toggleBeaconHidden(beaconId: $beaconId, campaignId: $campaignId) {
`mutation toggleBeaconHidden($beaconId: String, $beaconIds: [String!], $campaignId: String!, $setHidden: Boolean) { toggleBeaconHidden(beaconId: $beaconId, beaconIds: $beaconIds, campaignId: $campaignId, setHidden: $setHidden) {
${typeof resultSelector === 'function' ? resultSelector(BeaconModelSelector).toString() : resultSelector}
} }`,
variables,
Expand All @@ -1041,14 +1071,14 @@ export class RootStoreBase extends ExtendedModel(
}
// Toggle host hidden state
@modelAction mutateToggleHostHidden(
variables: { campaignId: string; hostId: string },
variables: { campaignId: string; hostId?: string; hostIds?: string[]; setHidden?: boolean },
resultSelector:
| string
| ((qb: typeof HostModelSelector) => typeof HostModelSelector) = hostModelPrimitives.toString(),
optimisticUpdate?: () => void
) {
return this.mutate<{ toggleHostHidden: HostModel }>(
`mutation toggleHostHidden($campaignId: String!, $hostId: String!) { toggleHostHidden(campaignId: $campaignId, hostId: $hostId) {
`mutation toggleHostHidden($campaignId: String!, $hostId: String, $hostIds: [String!], $setHidden: Boolean) { toggleHostHidden(campaignId: $campaignId, hostId: $hostId, hostIds: $hostIds, setHidden: $setHidden) {
${typeof resultSelector === 'function' ? resultSelector(HostModelSelector).toString() : resultSelector}
} }`,
variables,
Expand All @@ -1057,14 +1087,14 @@ export class RootStoreBase extends ExtendedModel(
}
// Toggle server hidden state
@modelAction mutateToggleServerHidden(
variables: { campaignId: string; serverId: string },
variables: { campaignId: string; serverId?: string; serverIds?: string[]; setHidden?: boolean },
resultSelector:
| string
| ((qb: typeof ServerModelSelector) => typeof ServerModelSelector) = serverModelPrimitives.toString(),
optimisticUpdate?: () => void
) {
return this.mutate<{ toggleServerHidden: ServerModel }>(
`mutation toggleServerHidden($campaignId: String!, $serverId: String!) { toggleServerHidden(campaignId: $campaignId, serverId: $serverId) {
`mutation toggleServerHidden($campaignId: String!, $serverId: String, $serverIds: [String!], $setHidden: Boolean) { toggleServerHidden(campaignId: $campaignId, serverId: $serverId, serverIds: $serverIds, setHidden: $setHidden) {
${typeof resultSelector === 'function' ? resultSelector(ServerModelSelector).toString() : resultSelector}
} }`,
variables,
Expand Down
1 change: 1 addition & 0 deletions applications/client/src/store/graphql/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export * from './LinkModel';
export * from './LogEntryModel';
export * from './LogTypeEnum';
export * from './MitreTechniquesEnum';
export * from './NonHidableEntitiesModel';
export * from './OperatorModel';
export * from './ParsingProgressModel';
export * from './ParsingStatusEnum';
Expand Down
Loading