From 630612b4c02ec3ad097920d074373be10c016d5f Mon Sep 17 00:00:00 2001 From: Samuel Hassine Date: Thu, 16 May 2024 22:47:35 +0200 Subject: [PATCH] [backend] Finish the Tanium executor --- .../injectors/caldera/CalderaExecutor.java | 7 +- .../injectors/caldera/CalderaInjector.java | 8 +- .../src/main/resources/application.properties | 3 +- .../service/CalderaExecutorService.java | 7 +- .../tanium/config/TaniumExecutorConfig.java | 6 +- .../tanium/openbas-tanium-packages.json | 1 + .../service/TaniumExecutorContextService.java | 8 +- .../tanium/service/TaniumExecutorService.java | 12 +- .../src/actions/assets/asset-helper.d.ts | 2 +- openbas-front/src/actions/helper.d.ts | 10 +- .../asset_groups/AssetGroupManagement.tsx | 6 +- .../assets/asset_groups/AssetGroups.tsx | 6 +- .../components/assets/endpoints/Endpoint.d.ts | 3 +- .../components/assets/endpoints/Endpoints.tsx | 114 +++++++++++------- .../endpoints/EndpointsDialogAdding.tsx | 4 +- .../atomic_testings/AtomicTestings.tsx | 4 +- .../atomic_testing/AtomicTestingDetail.tsx | 4 +- .../components/common/articles/Articles.tsx | 4 +- .../common/entreprise_edition/EEChip.tsx | 4 +- .../common/entreprise_edition/EETooltip.tsx | 4 +- .../EnterpriseEditionButton.tsx | 4 +- .../common/injects/InjectAddChallenges.tsx | 4 +- .../common/injects/InjectAddDocuments.tsx | 4 +- .../admin/components/common/tags/TagChip.tsx | 4 +- .../components/channels/Channels.tsx | 4 +- .../components/components/teams/AddTeams.tsx | 4 +- .../components/teams/ContextualTeams.tsx | 4 +- .../components/teams/TeamAddPlayers.tsx | 4 +- .../components/teams/TeamPlayers.tsx | 4 +- .../components/teams/TeamPopover.tsx | 4 +- .../components/components/teams/Teams.tsx | 6 +- .../components/lessons/LessonsTemplate.tsx | 4 +- .../src/admin/components/nav/LeftBar.tsx | 4 +- .../admin/components/scenarios/Scenarios.tsx | 4 +- .../challenges/ScenarioChallenges.tsx | 4 +- .../scenario/injects/ScenarioInjects.tsx | 4 +- .../components/simulations/ExerciseList.tsx | 4 +- .../components/simulations/Exercises.tsx | 4 +- .../challenges/ExerciseChallenges.tsx | 4 +- .../simulation/controls/CreateControl.tsx | 4 +- .../simulation/injects/ExerciseInjects.tsx | 4 +- .../mails/MailDistributionByPlayer.tsx | 4 +- ...xerciseDistributionScoreByOrganization.tsx | 4 +- .../ExerciseDistributionScoreByPlayer.tsx | 4 +- .../validation/common/TeamOrAssetLine.tsx | 6 +- .../TechnicalExpectationAssetGroup.tsx | 4 +- .../variables/AvailableVariablesDialog.tsx | 4 +- .../admin/components/teams/Organizations.tsx | 4 +- .../src/admin/components/teams/Players.tsx | 4 +- .../src/admin/components/teams/Teams.tsx | 4 +- .../teams/players/PlayerPopover.tsx | 4 +- .../src/components/common/ExportButton.tsx | 4 +- .../src/components/common/ImportUploader.tsx | 4 +- .../src/components/fields/TagField.tsx | 4 +- openbas-front/src/utils/Scenario.tsx | 4 +- openbas-front/src/utils/api-types.d.ts | 24 ++-- 56 files changed, 208 insertions(+), 177 deletions(-) create mode 100644 openbas-framework/src/main/java/io/openbas/executors/tanium/openbas-tanium-packages.json diff --git a/openbas-api/src/main/java/io/openbas/injectors/caldera/CalderaExecutor.java b/openbas-api/src/main/java/io/openbas/injectors/caldera/CalderaExecutor.java index b483cc884e..8ee2447e08 100644 --- a/openbas-api/src/main/java/io/openbas/injectors/caldera/CalderaExecutor.java +++ b/openbas-api/src/main/java/io/openbas/injectors/caldera/CalderaExecutor.java @@ -120,7 +120,12 @@ private Endpoint findAndRegisterAssetForExecution(@NotNull final Inject inject, count++; // Find an executor agent matching the asset log.log(Level.INFO, "Listing agents..."); - List agents = this.calderaService.agents().stream().filter(agent -> agent.getExe_name().contains("executor") && (now().toEpochMilli() - Time.toInstant(agent.getCreated()).toEpochMilli()) < Asset.ACTIVE_THRESHOLD && agent.getHost().equals(assetEndpoint.getHostname()) && Arrays.stream(assetEndpoint.getIps()).anyMatch(s -> Arrays.stream(agent.getHost_ip_addrs()).toList().contains(s))).toList(); + List agents = this.calderaService.agents().stream().filter(agent -> + agent.getExe_name().contains("executor") + && (now().toEpochMilli() - Time.toInstant(agent.getCreated()).toEpochMilli()) < Asset.ACTIVE_THRESHOLD + && (agent.getHost().equals(assetEndpoint.getHostname()) || agent.getHost().split("\\.")[0].equals(assetEndpoint.getHostname().split("\\.")[0])) + && Arrays.stream(assetEndpoint.getIps()).anyMatch(s -> Arrays.stream(agent.getHost_ip_addrs()).toList().contains(s)) + ).toList(); log.log(Level.INFO, "List return with " + agents.size() + " agents"); if (!agents.isEmpty()) { for (int i = 0; i < agents.size(); i++) { diff --git a/openbas-api/src/main/java/io/openbas/injectors/caldera/CalderaInjector.java b/openbas-api/src/main/java/io/openbas/injectors/caldera/CalderaInjector.java index 875b5d642d..e4c303253c 100644 --- a/openbas-api/src/main/java/io/openbas/injectors/caldera/CalderaInjector.java +++ b/openbas-api/src/main/java/io/openbas/injectors/caldera/CalderaInjector.java @@ -21,12 +21,12 @@ public class CalderaInjector { public CalderaInjector(InjectorService injectorService, CalderaContract contract, CalderaInjectorConfig calderaInjectorConfig) { Map executorCommands = new HashMap<>(); executorCommands.put(Endpoint.PLATFORM_TYPE.Windows.name(), "$x=\"#{location}\";$location=$x.Replace(\"\\obas.exe\", \"\");[Environment]::CurrentDirectory = $location;$random=-join ((65..90) + (97..122) | Get-Random -Count 5 | % {[char]$_});$filename=\"obas-executor-$random.exe\";$server=\"" + calderaInjectorConfig.getPublicUrl() + "\";$url=\"$server/file/download\";$wc=New-Object System.Net.WebClient;$wc.Headers.add(\"platform\",\"windows\");$wc.Headers.add(\"file\",\"sandcat.go\");$data=$wc.DownloadData($url);[io.file]::WriteAllBytes($filename,$data) | Out-Null;New-NetFirewallRule -DisplayName \"Allow OpenBAS\" -Direction Inbound -Program \"$location\\$filename\" -Action Allow | Out-Null;New-NetFirewallRule -DisplayName \"Allow OpenBAS\" -Direction Outbound -Program \"$location\\$filename\" -Action Allow | Out-Null;Start-Process -FilePath \"$location\\$filename\" -ArgumentList \"-server $server -group red\" -WindowStyle hidden;"); - executorCommands.put(Endpoint.PLATFORM_TYPE.Linux.name(), "x=\"#{location}\";location=$(echo \"$location\" | sed \"s#/obas##\");filename=obas-executor-$(tr -dc A-Za-z0-9 $location/$filename;chmod +x $location/$filename;nohup $location/$filename -server $server -group red &"); - executorCommands.put(Endpoint.PLATFORM_TYPE.MacOS.name(), "x=\"#{location}\";location=$(echo \"$location\" | sed \"s#/obas##\");filename=obas-executor-$(tr -dc A-Za-z0-9 $location/$filename;chmod +x $location/$filename;nohup $location/$filename -server $server -group red &"); + executorCommands.put(Endpoint.PLATFORM_TYPE.Linux.name(), "x=\"#{location}\";location=$(echo \"$x\" | sed \"s#/obas##\");filename=obas-executor-$(tr -dc A-Za-z0-9 $location/$filename;chmod +x $location/$filename;$location/$filename -server $server -group red &"); + executorCommands.put(Endpoint.PLATFORM_TYPE.MacOS.name(), "x=\"#{location}\";location=$(echo \"$x\" | sed \"s#/obas##\");filename=obas-executor-$(tr -dc A-Za-z0-9 $location/$filename;chmod +x $location/$filename;$location/$filename -server $server -group red &"); Map executorClearCommands = new HashMap<>(); executorClearCommands.put(Endpoint.PLATFORM_TYPE.Windows.name(), "$x=\"#{location}\";$location=$x.Replace(\"\\obas.exe\", \"\");[Environment]::CurrentDirectory = $location;cd \"$location\";Get-ChildItem -Recurse -Filter *executor* | Remove-Item"); - executorClearCommands.put(Endpoint.PLATFORM_TYPE.Linux.name(), "x=\"#{location}\";location=$(echo \"$location\" | sed \"s#/obas##\");cd \"$location\"; rm *executor*"); - executorClearCommands.put(Endpoint.PLATFORM_TYPE.MacOS.name(), "x=\"#{location}\";location=$(echo \"$location\" | sed \"s#/obas##\");cd \"$location\"; rm *executor*"); + executorClearCommands.put(Endpoint.PLATFORM_TYPE.Linux.name(), "x=\"#{location}\";location=$(echo \"$x\" | sed \"s#/obas##\");cd \"$location\"; rm *executor*"); + executorClearCommands.put(Endpoint.PLATFORM_TYPE.MacOS.name(), "x=\"#{location}\";location=$(echo \"$x\" | sed \"s#/obas##\");cd \"$location\"; rm *executor*"); try { injectorService.register( calderaInjectorConfig.getId(), diff --git a/openbas-api/src/main/resources/application.properties b/openbas-api/src/main/resources/application.properties index eda38b3d10..68f9f0604c 100644 --- a/openbas-api/src/main/resources/application.properties +++ b/openbas-api/src/main/resources/application.properties @@ -145,8 +145,7 @@ executor.tanium.api-key= executor.tanium.computer-group-id=1 executor.tanium.action-group-id=4 executor.tanium.windows-package-id= -executor.tanium.linux-package-id= -executor.tanium.mac-os-package-id= +executor.tanium.unix-package-id= ############# # INJECTORS # diff --git a/openbas-framework/src/main/java/io/openbas/executors/caldera/service/CalderaExecutorService.java b/openbas-framework/src/main/java/io/openbas/executors/caldera/service/CalderaExecutorService.java index 515207d8f0..d9072dd85a 100644 --- a/openbas-framework/src/main/java/io/openbas/executors/caldera/service/CalderaExecutorService.java +++ b/openbas-framework/src/main/java/io/openbas/executors/caldera/service/CalderaExecutorService.java @@ -95,7 +95,12 @@ public void run() { endpoints.forEach(endpoint -> { List existingEndpoints = this.endpointService.findAssetsForInjectionByHostname(endpoint.getHostname()).stream().filter(endpoint1 -> Arrays.stream(endpoint1.getIps()).anyMatch(s -> Arrays.stream(endpoint.getIps()).toList().contains(s))).toList(); if (existingEndpoints.isEmpty()) { - this.endpointService.createEndpoint(endpoint); + Optional endpointByExternalReference = endpointService.findByExternalReference(endpoint.getExternalReference()); + if( endpointByExternalReference.isPresent() ) { + this.updateEndpoint(endpoint, List.of(endpointByExternalReference.get())); + } else { + this.endpointService.createEndpoint(endpoint); + } } else { this.updateEndpoint(endpoint, existingEndpoints); } diff --git a/openbas-framework/src/main/java/io/openbas/executors/tanium/config/TaniumExecutorConfig.java b/openbas-framework/src/main/java/io/openbas/executors/tanium/config/TaniumExecutorConfig.java index a765c05619..7111594471 100644 --- a/openbas-framework/src/main/java/io/openbas/executors/tanium/config/TaniumExecutorConfig.java +++ b/openbas-framework/src/main/java/io/openbas/executors/tanium/config/TaniumExecutorConfig.java @@ -42,11 +42,7 @@ public class TaniumExecutorConfig { @Getter @NotBlank - private Integer linuxPackageId; - - @Getter - @NotBlank - private Integer macOsPackageId; + private Integer unixPackageId; public String getGatewayUrl() { return url + GATEWAY_URI; diff --git a/openbas-framework/src/main/java/io/openbas/executors/tanium/openbas-tanium-packages.json b/openbas-framework/src/main/java/io/openbas/executors/tanium/openbas-tanium-packages.json new file mode 100644 index 0000000000..ba221d57ee --- /dev/null +++ b/openbas-framework/src/main/java/io/openbas/executors/tanium/openbas-tanium-packages.json @@ -0,0 +1 @@ +{"comment":"Exported from Tanium Server 7.6.1.6540 at 2024-05-16T20:24:14","version":2,"object_list":{"package_specs":[{"content_set":{"name":"Base"},"name":"OpenBAS Subprocessor (Unix)","display_name":"OpenBAS Subprocessor (Unix)","files":[],"file_templates":[],"command":"/bin/sh -c \"/bin/echo $1 | base64 -d | sh\"","command_timeout":60,"expire_seconds":660,"hidden_flag":0,"process_group_flag":0,"verify_group":{"name":"","and_flag":0,"not_flag":0,"type":0},"verify_expire_seconds":600,"skip_lock_flag":0,"parameter_definition":"{\"parameters\":[{\"defaultValue\":\"\",\"helpString\":\"\",\"label\":\"command\",\"maxChars\":\"\",\"promptText\":\"\",\"validationExpressions\":[{\"expression\":\".*\",\"helpString\":\"\",\"model\":\"com.tanium.models::ValidationExpression\",\"parameterType\":\"com.tanium.models::ValidationExpression\"}],\"parameterType\":\"com.tanium.components.parameters::TextInputParameter\",\"key\":\"$1\"}]}","metadata":[]},{"content_set":{"name":"Base"},"name":"OpenBAS Subprocessor (Windows)","display_name":"OpenBAS Subprocessor (Windows)","files":[],"file_templates":[],"command":"cmd.exe /d /c powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -NonInteractive -NoProfile -Command \"Invoke-Expression ([System.Text.Encoding]::UTF8.GetString([convert]::FromBase64String('$1')))\"","command_timeout":60,"expire_seconds":660,"hidden_flag":0,"process_group_flag":0,"verify_group":{"name":"","and_flag":0,"not_flag":0,"type":0},"verify_expire_seconds":600,"skip_lock_flag":0,"parameter_definition":"{\"parameters\":[{\"defaultValue\":\"\",\"helpString\":\"\",\"label\":\"command\",\"maxChars\":\"\",\"promptText\":\"\",\"validationExpressions\":[{\"expression\":\".*\",\"helpString\":\"\",\"model\":\"com.tanium.models::ValidationExpression\",\"parameterType\":\"com.tanium.models::ValidationExpression\"}],\"parameterType\":\"com.tanium.components.parameters::TextInputParameter\",\"key\":\"$1\"}]}","metadata":[]}]}} \ No newline at end of file diff --git a/openbas-framework/src/main/java/io/openbas/executors/tanium/service/TaniumExecutorContextService.java b/openbas-framework/src/main/java/io/openbas/executors/tanium/service/TaniumExecutorContextService.java index 4237ec8a94..e2dfb31617 100644 --- a/openbas-framework/src/main/java/io/openbas/executors/tanium/service/TaniumExecutorContextService.java +++ b/openbas-framework/src/main/java/io/openbas/executors/tanium/service/TaniumExecutorContextService.java @@ -42,12 +42,12 @@ public void launchExecutorSubprocess(@NotNull final Injector injector, @NotNull this.taniumExecutorClient.executeAction(asset.getExternalReference(), this.taniumExecutorConfig.getWindowsPackageId(), Base64.getEncoder().encodeToString(command.getBytes())); } case Endpoint.PLATFORM_TYPE.Linux -> { - String command = injector.getExecutorCommands().get(Endpoint.PLATFORM_TYPE.Linux.name()).replace("\"#{location}\"", "$PWD.Path"); - this.taniumExecutorClient.executeAction(asset.getExternalReference(), this.taniumExecutorConfig.getLinuxPackageId(), Base64.getEncoder().encodeToString(command.getBytes())); + String command = injector.getExecutorCommands().get(Endpoint.PLATFORM_TYPE.Linux.name()).replace("\"#{location}\"", "$(pwd)"); + this.taniumExecutorClient.executeAction(asset.getExternalReference(), this.taniumExecutorConfig.getUnixPackageId(), Base64.getEncoder().encodeToString(command.getBytes())); } case Endpoint.PLATFORM_TYPE.MacOS -> { - String command = injector.getExecutorCommands().get(Endpoint.PLATFORM_TYPE.MacOS.name()).replace("\"#{location}\"", "$PWD.Path"); - this.taniumExecutorClient.executeAction(asset.getExternalReference(), this.taniumExecutorConfig.getMacOsPackageId(), injector.getExecutorCommands().get(Endpoint.PLATFORM_TYPE.MacOS.name())); + String command = injector.getExecutorCommands().get(Endpoint.PLATFORM_TYPE.MacOS.name()).replace("\"#{location}\"", "$(pwd)"); + this.taniumExecutorClient.executeAction(asset.getExternalReference(), this.taniumExecutorConfig.getUnixPackageId(), Base64.getEncoder().encodeToString(command.getBytes())); } default -> throw new RuntimeException("Unsupported platform: " + platform); }; diff --git a/openbas-framework/src/main/java/io/openbas/executors/tanium/service/TaniumExecutorService.java b/openbas-framework/src/main/java/io/openbas/executors/tanium/service/TaniumExecutorService.java index 17250acac3..0ccfbbb999 100644 --- a/openbas-framework/src/main/java/io/openbas/executors/tanium/service/TaniumExecutorService.java +++ b/openbas-framework/src/main/java/io/openbas/executors/tanium/service/TaniumExecutorService.java @@ -24,10 +24,7 @@ import java.time.LocalDateTime; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; -import java.util.Optional; +import java.util.*; import java.util.logging.Level; import static java.time.Instant.now; @@ -90,7 +87,12 @@ public void run() { endpoints.forEach(endpoint -> { List existingEndpoints = this.endpointService.findAssetsForInjectionByHostname(endpoint.getHostname()).stream().filter(endpoint1 -> Arrays.stream(endpoint1.getIps()).anyMatch(s -> Arrays.stream(endpoint.getIps()).toList().contains(s))).toList(); if (existingEndpoints.isEmpty()) { - this.endpointService.createEndpoint(endpoint); + Optional endpointByExternalReference = endpointService.findByExternalReference(endpoint.getExternalReference()); + if( endpointByExternalReference.isPresent() ) { + this.updateEndpoint(endpoint, List.of(endpointByExternalReference.get())); + } else { + this.endpointService.createEndpoint(endpoint); + } } else { this.updateEndpoint(endpoint, existingEndpoints); } diff --git a/openbas-front/src/actions/assets/asset-helper.d.ts b/openbas-front/src/actions/assets/asset-helper.d.ts index dc238770a8..c24aceef7d 100644 --- a/openbas-front/src/actions/assets/asset-helper.d.ts +++ b/openbas-front/src/actions/assets/asset-helper.d.ts @@ -1,6 +1,6 @@ import type { EndpointStore } from '../../admin/components/assets/endpoints/Endpoint'; -export interface EndpointsHelper { +export interface EndpointHelper { getEndpoints: () => EndpointStore[]; getEndpointsMap: () => Record; } diff --git a/openbas-front/src/actions/helper.d.ts b/openbas-front/src/actions/helper.d.ts index b1b08b145a..75fb6f25b8 100644 --- a/openbas-front/src/actions/helper.d.ts +++ b/openbas-front/src/actions/helper.d.ts @@ -1,17 +1,17 @@ import type { Challenge, Exercise, Organization, PlatformSettings, Tag, User } from '../utils/api-types'; import type { ScenarioStore } from './scenarios/Scenario'; -export interface UsersHelper { +export interface UserHelper { getMe: () => User; getUsersMap: () => Record; } -export interface OrganizationsHelper { +export interface OrganizationHelper { getOrganizations: () => Organization[]; getOrganizationsMap: () => Record; } -export interface TagsHelper { +export interface TagHelper { getTag: (tagId: Tag['tag_id']) => Tag; getTags: () => Tag[]; getTagsMap: () => Record; @@ -26,13 +26,13 @@ export interface LoggedHelper { getPlatformSettings: () => PlatformSettings; } -export interface ChallengesHelper { +export interface ChallengeHelper { getChallengesMap: () => Record; getChallenges: () => Challenge[]; getExerciseChallenges: (exerciseId: Exercise['exercise_id']) => Challenge[]; getScenarioChallenges: (scenarioId: ScenarioStore['scenario_id']) => Challenge[]; } -export interface DocumentsHelper { +export interface DocumentHelper { getDocumentsMap: () => Record } diff --git a/openbas-front/src/admin/components/assets/asset_groups/AssetGroupManagement.tsx b/openbas-front/src/admin/components/assets/asset_groups/AssetGroupManagement.tsx index 3fe5499192..1cf38e4e80 100644 --- a/openbas-front/src/admin/components/assets/asset_groups/AssetGroupManagement.tsx +++ b/openbas-front/src/admin/components/assets/asset_groups/AssetGroupManagement.tsx @@ -7,7 +7,7 @@ import TagsFilter from '../../common/filters/TagsFilter'; import SearchFilter from '../../../../components/SearchFilter'; import AssetGroupAddEndpoints from './AssetGroupAddEndpoints'; import { useHelper } from '../../../../store'; -import type { UsersHelper } from '../../../../actions/helper'; +import type { UserHelper } from '../../../../actions/helper'; import useDataLoader from '../../../../utils/hooks/useDataLoader'; import { fetchEndpoints } from '../../../../actions/assets/endpoint-actions'; import { useAppDispatch } from '../../../../utils/hooks'; @@ -16,7 +16,7 @@ import type { AssetGroupsHelper } from '../../../../actions/asset_groups/assetgr import EndpointsList, { EndpointStoreWithType } from '../endpoints/EndpointsList'; import EndpointPopover from '../endpoints/EndpointPopover'; import useSearchAnFilter from '../../../../utils/SortingFiltering'; -import type { EndpointsHelper } from '../../../../actions/assets/asset-helper'; +import type { EndpointHelper } from '../../../../actions/assets/asset-helper'; import type { AssetGroupStore } from './AssetGroup'; const useStyles = makeStyles((theme: Theme) => ({ @@ -65,7 +65,7 @@ const AssetGroupManagement: FunctionComponent = ({ const dispatch = useAppDispatch(); // Fetching data - const { assetGroup, endpointsMap, userAdmin } = useHelper((helper: AssetGroupsHelper & EndpointsHelper & UsersHelper) => ({ + const { assetGroup, endpointsMap, userAdmin } = useHelper((helper: AssetGroupsHelper & EndpointHelper & UserHelper) => ({ assetGroup: helper.getAssetGroup(assetGroupId), endpointsMap: helper.getEndpointsMap(), userAdmin: helper.getMe()?.user_admin ?? false, diff --git a/openbas-front/src/admin/components/assets/asset_groups/AssetGroups.tsx b/openbas-front/src/admin/components/assets/asset_groups/AssetGroups.tsx index 62110b8825..93c6d45aaa 100644 --- a/openbas-front/src/admin/components/assets/asset_groups/AssetGroups.tsx +++ b/openbas-front/src/admin/components/assets/asset_groups/AssetGroups.tsx @@ -5,7 +5,7 @@ import { SelectGroup } from 'mdi-material-ui'; import { useSearchParams } from 'react-router-dom'; import { useFormatter } from '../../../../components/i18n'; import { useHelper } from '../../../../store'; -import type { TagsHelper, UsersHelper } from '../../../../actions/helper'; +import type { TagHelper, UserHelper } from '../../../../actions/helper'; import type { AssetGroupStore } from './AssetGroup'; import ItemTags from '../../../../components/ItemTags'; import AssetGroupPopover from './AssetGroupPopover'; @@ -14,7 +14,7 @@ import { searchAssetGroups } from '../../../../actions/asset_groups/assetgroup-a import AssetGroupManagement from './AssetGroupManagement'; import Breadcrumbs from '../../../../components/Breadcrumbs'; import PaginationComponent from '../../../../components/common/pagination/PaginationComponent'; -import type { EndpointsHelper } from '../../../../actions/assets/asset-helper'; +import type { EndpointHelper } from '../../../../actions/assets/asset-helper'; import type { SearchPaginationInput } from '../../../../utils/api-types'; import { initSorting } from '../../../../components/common/pagination/Page'; import SortHeadersComponent from '../../../../components/common/pagination/SortHeadersComponent'; @@ -80,7 +80,7 @@ const AssetGroups = () => { const [searchId] = searchParams.getAll('id'); // Fetching data - const { userAdmin } = useHelper((helper: EndpointsHelper & UsersHelper & TagsHelper) => ({ + const { userAdmin } = useHelper((helper: EndpointHelper & UserHelper & TagHelper) => ({ userAdmin: helper.getMe()?.user_admin ?? false, })); diff --git a/openbas-front/src/admin/components/assets/endpoints/Endpoint.d.ts b/openbas-front/src/admin/components/assets/endpoints/Endpoint.d.ts index 9f6d92424a..b207385aee 100644 --- a/openbas-front/src/admin/components/assets/endpoints/Endpoint.d.ts +++ b/openbas-front/src/admin/components/assets/endpoints/Endpoint.d.ts @@ -1,5 +1,6 @@ import type { Endpoint } from '../../../../utils/api-types'; -export type EndpointStore = Omit & { +export type EndpointStore = Omit & { asset_tags: string[] | undefined; + asset_executor: string | undefined; }; diff --git a/openbas-front/src/admin/components/assets/endpoints/Endpoints.tsx b/openbas-front/src/admin/components/assets/endpoints/Endpoints.tsx index 0851694951..dceab20016 100644 --- a/openbas-front/src/admin/components/assets/endpoints/Endpoints.tsx +++ b/openbas-front/src/admin/components/assets/endpoints/Endpoints.tsx @@ -3,12 +3,12 @@ import { makeStyles } from '@mui/styles'; import { List, ListItem, ListItemIcon, ListItemSecondaryAction, ListItemText } from '@mui/material'; import { DevicesOtherOutlined } from '@mui/icons-material'; import { useSearchParams } from 'react-router-dom'; +import { useAppDispatch } from '../../../../utils/hooks'; import EndpointCreation from './EndpointCreation'; import EndpointPopover from './EndpointPopover'; import { useHelper } from '../../../../store'; import { useFormatter } from '../../../../components/i18n'; -import type { TagsHelper, UsersHelper } from '../../../../actions/helper'; -import type { EndpointsHelper } from '../../../../actions/assets/asset-helper'; +import type { UserHelper } from '../../../../actions/helper'; import type { EndpointStore } from './Endpoint'; import ItemTags from '../../../../components/ItemTags'; import AssetStatus from '../AssetStatus'; @@ -19,6 +19,9 @@ import { initSorting } from '../../../../components/common/pagination/Page'; import type { SearchPaginationInput } from '../../../../utils/api-types'; import { searchEndpoints } from '../../../../actions/assets/endpoint-actions'; import PlatformIcon from '../../../../components/PlatformIcon'; +import type { ExecutorHelper } from '../../../../actions/executors/executor-helper'; +import useDataLoader from '../../../../utils/hooks/useDataLoader'; +import { fetchExecutors } from '../../../../actions/Executor'; const useStyles = makeStyles(() => ({ itemHead: { @@ -45,16 +48,18 @@ const useStyles = makeStyles(() => ({ const inlineStyles: Record = { asset_name: { - width: '25%', - }, - endpoint_hostname: { - width: '25%', + width: '30%', }, endpoint_platform: { width: '15%', display: 'flex', alignItems: 'center', }, + endpoint_executor: { + width: '20%', + display: 'flex', + alignItems: 'center', + }, asset_tags: { width: '20%', }, @@ -67,6 +72,7 @@ const inlineStyles: Record = { const Endpoints = () => { // Standard hooks const classes = useStyles(); + const dispatch = useAppDispatch(); const { t } = useFormatter(); // Query param @@ -75,15 +81,19 @@ const Endpoints = () => { const [searchId] = searchParams.getAll('id'); // Fetching data - const { userAdmin } = useHelper((helper: EndpointsHelper & UsersHelper & TagsHelper) => ({ + const { userAdmin, executorsMap } = useHelper((helper: ExecutorHelper & UserHelper) => ({ userAdmin: helper.getMe()?.user_admin ?? false, + executorsMap: helper.getExecutorsMap(), })); + useDataLoader(() => { + dispatch(fetchExecutors()); + }); // Headers const headers = [ { field: 'asset_name', label: 'Name', isSortable: true }, - { field: 'endpoint_hostname', label: 'Hostname', isSortable: true }, { field: 'endpoint_platform', label: 'Platform', isSortable: true }, + { field: 'endpoint_executor', label: 'Executor', isSortable: true }, { field: 'asset_tags', label: 'Tags', isSortable: true }, { field: 'asset_status', label: 'Status', isSortable: false }, ]; @@ -149,46 +159,58 @@ const Endpoints = () => { />   - {endpoints.map((endpoint) => ( - - - - - -
- {endpoint.asset_name} -
-
- {endpoint.endpoint_hostname} -
-
- {endpoint.endpoint_platform} -
-
- -
-
- + {endpoints.map((endpoint: EndpointStore) => { + const executor = executorsMap[endpoint.asset_executor ?? 'Unknown']; + return ( + + + + + +
+ {endpoint.asset_name} +
+
+ {endpoint.endpoint_platform} +
+
+ {executor && ( + {executor.executor_type} + )} + {executor?.executor_name ?? t('Unknown')} +
+
+ +
+
+ +
- - } - /> - - setEndpoints(endpoints.map((e) => (e.asset_id !== result.asset_id ? e : result)))} - onDelete={(result) => setEndpoints(endpoints.filter((e) => (e.asset_id !== result)))} - openEditOnInit={endpoint.asset_id === searchId} + } /> - -
- ))} + + setEndpoints(endpoints.map((e) => (e.asset_id !== result.asset_id ? e : result)))} + onDelete={(result) => setEndpoints(endpoints.filter((e) => (e.asset_id !== result)))} + openEditOnInit={endpoint.asset_id === searchId} + /> + + + ); + })} {userAdmin && setEndpoints([result, ...endpoints])} />} diff --git a/openbas-front/src/admin/components/assets/endpoints/EndpointsDialogAdding.tsx b/openbas-front/src/admin/components/assets/endpoints/EndpointsDialogAdding.tsx index a2402b9047..91c29750a8 100644 --- a/openbas-front/src/admin/components/assets/endpoints/EndpointsDialogAdding.tsx +++ b/openbas-front/src/admin/components/assets/endpoints/EndpointsDialogAdding.tsx @@ -28,7 +28,7 @@ import { truncate } from '../../../../utils/String'; import { useAppDispatch } from '../../../../utils/hooks'; import { useFormatter } from '../../../../components/i18n'; import { useHelper } from '../../../../store'; -import type { EndpointsHelper } from '../../../../actions/assets/asset-helper'; +import type { EndpointHelper } from '../../../../actions/assets/asset-helper'; import useDataLoader from '../../../../utils/hooks/useDataLoader'; import { fetchEndpoints } from '../../../../actions/assets/endpoint-actions'; import useSearchAnFilter from '../../../../utils/SortingFiltering'; @@ -71,7 +71,7 @@ const EndpointsDialogAdding: FunctionComponent = ({ const filtering = useSearchAnFilter('asset', 'name', ['name']); // Fetching data - const { endpointsMap } = useHelper((helper: EndpointsHelper) => ({ + const { endpointsMap } = useHelper((helper: EndpointHelper) => ({ endpointsMap: helper.getEndpointsMap(), })); useDataLoader(() => { diff --git a/openbas-front/src/admin/components/atomic_testings/AtomicTestings.tsx b/openbas-front/src/admin/components/atomic_testings/AtomicTestings.tsx index e22a035d2a..a9578156fd 100644 --- a/openbas-front/src/admin/components/atomic_testings/AtomicTestings.tsx +++ b/openbas-front/src/admin/components/atomic_testings/AtomicTestings.tsx @@ -4,7 +4,7 @@ import * as R from 'ramda'; import { useFormatter } from '../../../components/i18n'; import { useHelper } from '../../../store'; import Breadcrumbs from '../../../components/Breadcrumbs'; -import type { UsersHelper } from '../../../actions/helper'; +import type { UserHelper } from '../../../actions/helper'; import type { Inject, InjectResultDTO } from '../../../utils/api-types'; import { createAtomicTesting, searchAtomicTestings } from '../../../actions/atomic_testings/atomic-testing-actions'; import CreateInject from '../common/injects/CreateInject'; @@ -16,7 +16,7 @@ const AtomicTestings = () => { const { t } = useFormatter(); const navigate = useNavigate(); - const { userAdmin } = useHelper((helper: UsersHelper) => ({ + const { userAdmin } = useHelper((helper: UserHelper) => ({ userAdmin: helper.getMe()?.user_admin ?? false, })); diff --git a/openbas-front/src/admin/components/atomic_testings/atomic_testing/AtomicTestingDetail.tsx b/openbas-front/src/admin/components/atomic_testings/atomic_testing/AtomicTestingDetail.tsx index 5a78ac4460..6476efee15 100644 --- a/openbas-front/src/admin/components/atomic_testings/atomic_testing/AtomicTestingDetail.tsx +++ b/openbas-front/src/admin/components/atomic_testings/atomic_testing/AtomicTestingDetail.tsx @@ -9,7 +9,7 @@ import ItemStatus from '../../../../components/ItemStatus'; import { InjectResultDtoContext, InjectResultDtoContextType } from '../InjectResultDtoContext'; import useDataLoader from '../../../../utils/hooks/useDataLoader'; import { fetchDocuments } from '../../../../actions/Document'; -import type { DocumentsHelper } from '../../../../actions/helper'; +import type { DocumentHelper } from '../../../../actions/helper'; const useStyles = makeStyles(() => ({ paper: { @@ -37,7 +37,7 @@ const AtomicTestingDetail: FunctionComponent = () => { // Fetching data const { injectResultDto } = useContext(InjectResultDtoContext); - const { documentMap } = useHelper((helper: DocumentsHelper) => ({ + const { documentMap } = useHelper((helper: DocumentHelper) => ({ documentMap: helper.getDocumentsMap(), })); useDataLoader(() => { diff --git a/openbas-front/src/admin/components/common/articles/Articles.tsx b/openbas-front/src/admin/components/common/articles/Articles.tsx index 5e78f78f40..bbef995c89 100644 --- a/openbas-front/src/admin/components/common/articles/Articles.tsx +++ b/openbas-front/src/admin/components/common/articles/Articles.tsx @@ -18,7 +18,7 @@ import { fetchChannels } from '../../../../actions/channels/channel-action'; import { fetchDocuments } from '../../../../actions/Document'; import { useAppDispatch } from '../../../../utils/hooks'; import { useFormatter } from '../../../../components/i18n'; -import type { DocumentsHelper } from '../../../../actions/helper'; +import type { DocumentHelper } from '../../../../actions/helper'; import CreateArticle from './CreateArticle'; import type { ChannelsHelper } from '../../../../actions/channels/channel-helper'; import { ArticleContext, PermissionsContext } from '../Context'; @@ -58,7 +58,7 @@ const Articles: FunctionComponent = ({ articles }) => { const { t } = useFormatter(); // Fetching data - const { channelsMap, documentsMap } = useHelper((helper: ChannelsHelper & DocumentsHelper) => ({ + const { channelsMap, documentsMap } = useHelper((helper: ChannelsHelper & DocumentHelper) => ({ channelsMap: helper.getChannelsMap(), documentsMap: helper.getDocumentsMap(), })); diff --git a/openbas-front/src/admin/components/common/entreprise_edition/EEChip.tsx b/openbas-front/src/admin/components/common/entreprise_edition/EEChip.tsx index 16675a43b7..3aabc7491b 100644 --- a/openbas-front/src/admin/components/common/entreprise_edition/EEChip.tsx +++ b/openbas-front/src/admin/components/common/entreprise_edition/EEChip.tsx @@ -4,7 +4,7 @@ import EnterpriseEditionAgreement from './EnterpriseEditionAgreement'; import type { Theme } from '../../../../components/Theme'; import useEnterpriseEdition from '../../../../utils/hooks/useEnterpriseEdition'; import { useHelper } from '../../../../store'; -import type { UsersHelper } from '../../../../actions/helper'; +import type { UserHelper } from '../../../../actions/helper'; // Deprecated - https://mui.com/system/styles/basics/ // Do not use it for new code. @@ -45,7 +45,7 @@ const EEChip = ({ clickable = true, floating = false }: { clickable?: boolean, f const classes = useStyles(); const isEnterpriseEdition = useEnterpriseEdition(); const [displayDialog, setDisplayDialog] = useState(false); - const userAdmin = useHelper((helper: UsersHelper) => { + const userAdmin = useHelper((helper: UserHelper) => { const me = helper.getMe(); return me?.user_admin ?? false; }); diff --git a/openbas-front/src/admin/components/common/entreprise_edition/EETooltip.tsx b/openbas-front/src/admin/components/common/entreprise_edition/EETooltip.tsx index 60d86bffb3..98c348092c 100644 --- a/openbas-front/src/admin/components/common/entreprise_edition/EETooltip.tsx +++ b/openbas-front/src/admin/components/common/entreprise_edition/EETooltip.tsx @@ -5,7 +5,7 @@ import { useFormatter } from '../../../../components/i18n'; import useEnterpriseEdition from '../../../../utils/hooks/useEnterpriseEdition'; import useAI from '../../../../utils/hooks/useAI'; import { useHelper } from '../../../../store'; -import type { UsersHelper } from '../../../../actions/helper'; +import type { UserHelper } from '../../../../actions/helper'; const EETooltip = ({ children, @@ -20,7 +20,7 @@ const EETooltip = ({ const [feedbackCreation, setFeedbackCreation] = useState(false); const [openEnableAI, setOpenEnableAI] = useState(false); const [openConfigAI, setOpenConfigAI] = useState(false); - const userAdmin = useHelper((helper: UsersHelper) => { + const userAdmin = useHelper((helper: UserHelper) => { const me = helper.getMe(); return me?.user_admin ?? false; }); diff --git a/openbas-front/src/admin/components/common/entreprise_edition/EnterpriseEditionButton.tsx b/openbas-front/src/admin/components/common/entreprise_edition/EnterpriseEditionButton.tsx index 355709a48f..6c94bac9e5 100644 --- a/openbas-front/src/admin/components/common/entreprise_edition/EnterpriseEditionButton.tsx +++ b/openbas-front/src/admin/components/common/entreprise_edition/EnterpriseEditionButton.tsx @@ -6,7 +6,7 @@ import classNames from 'classnames'; import EnterpriseEditionAgreement from './EnterpriseEditionAgreement'; import { useFormatter } from '../../../../components/i18n'; import { useHelper } from '../../../../store'; -import type { UsersHelper } from '../../../../actions/helper'; +import type { UserHelper } from '../../../../actions/helper'; // Deprecated - https://mui.com/system/styles/basics/ // Do not use it for new code. @@ -24,7 +24,7 @@ const EnterpriseEditionButton = ({ inLine = false }: { inLine?: boolean; }) => { const { t } = useFormatter(); const classes = useStyles(); const [openEnterpriseEditionConsent, setOpenEnterpriseEditionConsent] = useState(false); - const userAdmin = useHelper((helper: UsersHelper) => { + const userAdmin = useHelper((helper: UserHelper) => { const me = helper.getMe(); return me?.user_admin ?? false; }); diff --git a/openbas-front/src/admin/components/common/injects/InjectAddChallenges.tsx b/openbas-front/src/admin/components/common/injects/InjectAddChallenges.tsx index 8eca9b004c..05adf42682 100644 --- a/openbas-front/src/admin/components/common/injects/InjectAddChallenges.tsx +++ b/openbas-front/src/admin/components/common/injects/InjectAddChallenges.tsx @@ -15,7 +15,7 @@ import type { Option } from '../../../../utils/Option'; import useDataLoader from '../../../../utils/hooks/useDataLoader'; import { useAppDispatch } from '../../../../utils/hooks'; import { useHelper } from '../../../../store'; -import type { ChallengesHelper } from '../../../../actions/helper'; +import type { ChallengeHelper } from '../../../../actions/helper'; import { PermissionsContext } from '../Context'; import type { Challenge } from '../../../../utils/api-types'; @@ -55,7 +55,7 @@ const InjectAddChallenges: FunctionComponent = ({ const dispatch = useAppDispatch(); const { permissions } = useContext(PermissionsContext); - const { challenges, challengesMap } = useHelper((helper: ChallengesHelper) => ({ + const { challenges, challengesMap } = useHelper((helper: ChallengeHelper) => ({ challenges: helper.getChallenges(), challengesMap: helper.getChallengesMap(), })); diff --git a/openbas-front/src/admin/components/common/injects/InjectAddDocuments.tsx b/openbas-front/src/admin/components/common/injects/InjectAddDocuments.tsx index d4066fe8c2..d551ce46d1 100644 --- a/openbas-front/src/admin/components/common/injects/InjectAddDocuments.tsx +++ b/openbas-front/src/admin/components/common/injects/InjectAddDocuments.tsx @@ -16,7 +16,7 @@ import useDataLoader from '../../../../utils/hooks/useDataLoader'; import { useAppDispatch } from '../../../../utils/hooks'; import type { Theme } from '../../../../components/Theme'; import { useHelper } from '../../../../store'; -import type { DocumentsHelper, UsersHelper } from '../../../../actions/helper'; +import type { DocumentHelper, UserHelper } from '../../../../actions/helper'; import { PermissionsContext } from '../Context'; import type { Document } from '../../../../utils/api-types'; @@ -58,7 +58,7 @@ const InjectAddDocuments: FunctionComponent = ({ const dispatch = useAppDispatch(); const { permissions } = useContext(PermissionsContext); - const { documents, userAdmin } = useHelper((helper: DocumentsHelper & UsersHelper) => ({ + const { documents, userAdmin } = useHelper((helper: DocumentHelper & UserHelper) => ({ documents: helper.getDocumentsMap(), userAdmin: helper.getMe()?.user_admin, })); diff --git a/openbas-front/src/admin/components/common/tags/TagChip.tsx b/openbas-front/src/admin/components/common/tags/TagChip.tsx index d2ec97374c..4a032dff90 100644 --- a/openbas-front/src/admin/components/common/tags/TagChip.tsx +++ b/openbas-front/src/admin/components/common/tags/TagChip.tsx @@ -2,7 +2,7 @@ import { Chip } from '@mui/material'; import React, { FunctionComponent } from 'react'; import { makeStyles } from '@mui/styles'; import { useHelper } from '../../../../store'; -import type { TagsHelper } from '../../../../actions/helper'; +import type { TagHelper } from '../../../../actions/helper'; const useStyles = makeStyles(() => ({ tag: { @@ -23,7 +23,7 @@ const TagChip: FunctionComponent = ({ }) => { // Standard hooks const classes = useStyles(); - const tag = useHelper((helper: TagsHelper) => helper.getTag(tagId)); + const tag = useHelper((helper: TagHelper) => helper.getTag(tagId)); if (!tag) { return <>; diff --git a/openbas-front/src/admin/components/components/channels/Channels.tsx b/openbas-front/src/admin/components/components/channels/Channels.tsx index 08e1def322..bf26d95619 100644 --- a/openbas-front/src/admin/components/components/channels/Channels.tsx +++ b/openbas-front/src/admin/components/components/channels/Channels.tsx @@ -12,7 +12,7 @@ import CreateChannel from './CreateChannel'; import { useFormatter } from '../../../../components/i18n'; import ChannelIcon from './ChannelIcon'; import type { ChannelsHelper } from '../../../../actions/channels/channel-helper'; -import type { UsersHelper } from '../../../../actions/helper'; +import type { UserHelper } from '../../../../actions/helper'; import { useAppDispatch } from '../../../../utils/hooks'; import type { Channel } from '../../../../utils/api-types'; import Breadcrumbs from '../../../../components/Breadcrumbs'; @@ -104,7 +104,7 @@ const Channels = () => { const searchColumns = ['type', 'name', 'description']; const filtering = useSearchAnFilter('channel', 'name', searchColumns); // Fetching data - const { channels, userAdmin }: { channels: Channel[], userAdmin: boolean } = useHelper((helper: ChannelsHelper & UsersHelper) => ({ + const { channels, userAdmin }: { channels: Channel[], userAdmin: boolean } = useHelper((helper: ChannelsHelper & UserHelper) => ({ channels: helper.getChannels(), userAdmin: helper.getMe()?.user_admin ?? false, })); diff --git a/openbas-front/src/admin/components/components/teams/AddTeams.tsx b/openbas-front/src/admin/components/components/teams/AddTeams.tsx index 28be2b4520..9884d475a3 100644 --- a/openbas-front/src/admin/components/components/teams/AddTeams.tsx +++ b/openbas-front/src/admin/components/components/teams/AddTeams.tsx @@ -11,7 +11,7 @@ import useDataLoader from '../../../../utils/hooks/useDataLoader'; import Transition from '../../../../components/common/Transition'; import { useFormatter } from '../../../../components/i18n'; import { useHelper } from '../../../../store'; -import type { OrganizationsHelper } from '../../../../actions/helper'; +import type { OrganizationHelper } from '../../../../actions/helper'; import { fetchTeams } from '../../../../actions/teams/team-actions'; import SearchFilter from '../../../../components/SearchFilter'; import CreateTeam from './CreateTeam'; @@ -57,7 +57,7 @@ const AddTeams: React.FC = ({ addedTeamIds, onAddTeams }) => { const { teamsMap, organizationsMap }: { organizationsMap: Record, teamsMap: Record - } = useHelper((helper: TeamsHelper & OrganizationsHelper) => ({ + } = useHelper((helper: TeamsHelper & OrganizationHelper) => ({ teamsMap: helper.getTeamsMap(), organizationsMap: helper.getOrganizationsMap(), })); diff --git a/openbas-front/src/admin/components/components/teams/ContextualTeams.tsx b/openbas-front/src/admin/components/components/teams/ContextualTeams.tsx index 0b76db7654..e259646fd7 100644 --- a/openbas-front/src/admin/components/components/teams/ContextualTeams.tsx +++ b/openbas-front/src/admin/components/components/teams/ContextualTeams.tsx @@ -7,7 +7,7 @@ import ItemTags from '../../../../components/ItemTags'; import TeamPopover from './TeamPopover'; import useSearchAnFilter from '../../../../utils/SortingFiltering'; import { useHelper } from '../../../../store'; -import type { TagsHelper } from '../../../../actions/helper'; +import type { TagHelper } from '../../../../actions/helper'; import type { TeamStore } from '../../../../actions/teams/Team'; import type { Team } from '../../../../utils/api-types'; import useDataLoader from '../../../../utils/hooks/useDataLoader'; @@ -137,7 +137,7 @@ const ContextualTeams: React.FC = ({ teamIds }) => { const dispatch = useAppDispatch(); const classes = useStyles(); const [selectedTeam, setSelectedTeam] = useState(null); - const { teams }: { teams: TeamStore[] } = useHelper((helper: TagsHelper & TeamsHelper) => ({ + const { teams }: { teams: TeamStore[] } = useHelper((helper: TagHelper & TeamsHelper) => ({ teams: helper.getTeams(), })); const { computeTeamUsersEnabled } = useContext(TeamContext); diff --git a/openbas-front/src/admin/components/components/teams/TeamAddPlayers.tsx b/openbas-front/src/admin/components/components/teams/TeamAddPlayers.tsx index b28ae14167..c57dbd04bb 100644 --- a/openbas-front/src/admin/components/components/teams/TeamAddPlayers.tsx +++ b/openbas-front/src/admin/components/components/teams/TeamAddPlayers.tsx @@ -7,7 +7,7 @@ import type { Organization, Team } from '../../../../utils/api-types'; import { useAppDispatch } from '../../../../utils/hooks'; import { useFormatter } from '../../../../components/i18n'; import { useHelper } from '../../../../store'; -import type { OrganizationsHelper, UsersHelper } from '../../../../actions/helper'; +import type { OrganizationHelper, UserHelper } from '../../../../actions/helper'; import type { UserStore } from '../../teams/players/Player'; import useDataLoader from '../../../../utils/hooks/useDataLoader'; import { fetchPlayers } from '../../../../actions/User'; @@ -61,7 +61,7 @@ const TeamAddPlayers: React.FC = ({ addedUsersIds, teamId }) => { const { usersMap, organizationsMap }: { organizationsMap: Record, usersMap: Record - } = useHelper((helper: UsersHelper & OrganizationsHelper) => ({ + } = useHelper((helper: UserHelper & OrganizationHelper) => ({ usersMap: helper.getUsersMap(), organizationsMap: helper.getOrganizationsMap(), })); diff --git a/openbas-front/src/admin/components/components/teams/TeamPlayers.tsx b/openbas-front/src/admin/components/components/teams/TeamPlayers.tsx index b0fafc3fb5..0cf94ac788 100644 --- a/openbas-front/src/admin/components/components/teams/TeamPlayers.tsx +++ b/openbas-front/src/admin/components/components/teams/TeamPlayers.tsx @@ -17,7 +17,7 @@ import { fetchOrganizations } from '../../../../actions/Organization'; import { useAppDispatch } from '../../../../utils/hooks'; import type { Organization, Team } from '../../../../utils/api-types'; import { useHelper } from '../../../../store'; -import type { OrganizationsHelper, UsersHelper } from '../../../../actions/helper'; +import type { OrganizationHelper, UserHelper } from '../../../../actions/helper'; import type { UserStore } from '../../teams/players/Player'; import type { Option } from '../../../../utils/Option'; import type { TeamsHelper } from '../../../../actions/teams/team-helper'; @@ -174,7 +174,7 @@ const TeamPlayers: React.FC = ({ teamId, handleClose }) => { organizationsMap: Record, team: Team, users: UserStore[] - } = useHelper((helper: UsersHelper & TeamsHelper & OrganizationsHelper) => ({ + } = useHelper((helper: UserHelper & TeamsHelper & OrganizationHelper) => ({ organizationsMap: helper.getOrganizationsMap(), team: helper.getTeam(teamId), users: helper.getTeamUsers(teamId), diff --git a/openbas-front/src/admin/components/components/teams/TeamPopover.tsx b/openbas-front/src/admin/components/components/teams/TeamPopover.tsx index 8d8db54b22..6e66acd88b 100644 --- a/openbas-front/src/admin/components/components/teams/TeamPopover.tsx +++ b/openbas-front/src/admin/components/components/teams/TeamPopover.tsx @@ -10,7 +10,7 @@ import Transition from '../../../../components/common/Transition'; import type { TeamUpdateInput } from '../../../../utils/api-types'; import { Option, organizationOption, tagOptions } from '../../../../utils/Option'; import { useHelper } from '../../../../store'; -import type { OrganizationsHelper, TagsHelper } from '../../../../actions/helper'; +import type { OrganizationHelper, TagHelper } from '../../../../actions/helper'; import type { TeamInputForm, TeamStore } from '../../../../actions/teams/Team'; import type { TeamsHelper } from '../../../../actions/teams/team-helper'; import { TeamContext } from '../../common/Context'; @@ -39,7 +39,7 @@ const TeamPopover: FunctionComponent = ({ const dispatch = useAppDispatch(); const { organizationsMap, tagsMap } = useHelper( ( - helper: ExercisesHelper & TeamsHelper & OrganizationsHelper & TagsHelper, + helper: ExercisesHelper & TeamsHelper & OrganizationHelper & TagHelper, ) => { return { organizationsMap: helper.getOrganizationsMap(), diff --git a/openbas-front/src/admin/components/components/teams/Teams.tsx b/openbas-front/src/admin/components/components/teams/Teams.tsx index 36fd15141d..a67075fa96 100644 --- a/openbas-front/src/admin/components/components/teams/Teams.tsx +++ b/openbas-front/src/admin/components/components/teams/Teams.tsx @@ -16,8 +16,8 @@ import PaginationComponent from '../../../../components/common/pagination/Pagina import SortHeadersComponent from '../../../../components/common/pagination/SortHeadersComponent'; import CreateTeam from './CreateTeam'; import { useHelper } from '../../../../store'; -import type { EndpointsHelper } from '../../../../actions/assets/asset-helper'; -import type { TagsHelper, UsersHelper } from '../../../../actions/helper'; +import type { EndpointHelper } from '../../../../actions/assets/asset-helper'; +import type { TagHelper, UserHelper } from '../../../../actions/helper'; const useStyles = makeStyles(() => ({ itemHead: { @@ -81,7 +81,7 @@ const Teams = () => { const [searchId] = searchParams.getAll('id'); // Fetching data - const { userAdmin } = useHelper((helper: EndpointsHelper & UsersHelper & TagsHelper) => ({ + const { userAdmin } = useHelper((helper: EndpointHelper & UserHelper & TagHelper) => ({ userAdmin: helper.getMe()?.user_admin ?? false, })); diff --git a/openbas-front/src/admin/components/lessons/LessonsTemplate.tsx b/openbas-front/src/admin/components/lessons/LessonsTemplate.tsx index 761ae487bf..f9a9013f83 100644 --- a/openbas-front/src/admin/components/lessons/LessonsTemplate.tsx +++ b/openbas-front/src/admin/components/lessons/LessonsTemplate.tsx @@ -13,7 +13,7 @@ import CreateLessonsTemplateQuestion from './categories/questions/CreateLessonsT import LessonsTemplateQuestionPopover from './categories/questions/LessonsTemplateQuestionPopover'; import { useAppDispatch } from '../../../utils/hooks'; import type { LessonsTemplatesHelper } from '../../../actions/lessons/lesson-helper'; -import type { UsersHelper } from '../../../actions/helper'; +import type { UserHelper } from '../../../actions/helper'; import type { LessonsTemplateCategory, LessonsTemplateQuestion } from '../../../utils/api-types'; const useStyles = makeStyles(() => ({ @@ -38,7 +38,7 @@ const LessonsTemplate = () => { userAdmin: boolean, categories: LessonsTemplateCategory[], questions: LessonsTemplateQuestion[] - } = useHelper((helper: LessonsTemplatesHelper & UsersHelper) => { + } = useHelper((helper: LessonsTemplatesHelper & UserHelper) => { return { categories: helper.getLessonsTemplateCategories(lessonsTemplateId), questions: helper.getLessonsTemplateQuestions(), diff --git a/openbas-front/src/admin/components/nav/LeftBar.tsx b/openbas-front/src/admin/components/nav/LeftBar.tsx index a80acaabca..f309ca2321 100644 --- a/openbas-front/src/admin/components/nav/LeftBar.tsx +++ b/openbas-front/src/admin/components/nav/LeftBar.tsx @@ -32,7 +32,7 @@ import { createStyles, makeStyles, styled, useTheme } from '@mui/styles'; import { fileUri, MESSAGING$ } from '../../../utils/Environment'; import { useFormatter } from '../../../components/i18n'; import { useHelper } from '../../../store'; -import type { UsersHelper } from '../../../actions/helper'; +import type { UserHelper } from '../../../actions/helper'; import type { Theme } from '../../../components/Theme'; import logoFiligranDark from '../../../static/images/logo_filigran_dark.png'; import logoFiligranLight from '../../../static/images/logo_filigran_light.png'; @@ -188,7 +188,7 @@ const LeftBar = () => { const handleGoToPage = (link: string) => { navigate(link); }; - const userAdmin = useHelper((helper: UsersHelper) => { + const userAdmin = useHelper((helper: UserHelper) => { const me = helper.getMe(); return me?.user_admin ?? false; }); diff --git a/openbas-front/src/admin/components/scenarios/Scenarios.tsx b/openbas-front/src/admin/components/scenarios/Scenarios.tsx index 1bf6ab77a6..f0de087c88 100644 --- a/openbas-front/src/admin/components/scenarios/Scenarios.tsx +++ b/openbas-front/src/admin/components/scenarios/Scenarios.tsx @@ -6,7 +6,7 @@ import { Link } from 'react-router-dom'; import classNames from 'classnames'; import { useFormatter } from '../../../components/i18n'; import { useHelper } from '../../../store'; -import type { TagsHelper, UsersHelper } from '../../../actions/helper'; +import type { TagHelper, UserHelper } from '../../../actions/helper'; import { fetchScenarioStatistic, searchScenarios } from '../../../actions/scenarios/scenario-actions'; import type { ScenarioStore } from '../../../actions/scenarios/Scenario'; import ScenarioCreation from './ScenarioCreation'; @@ -97,7 +97,7 @@ const Scenarios = () => { const classes = useStyles(); const { t, nsdt } = useFormatter(); // Fetching data - const { userAdmin } = useHelper((helper: TagsHelper & UsersHelper) => ({ + const { userAdmin } = useHelper((helper: TagHelper & UserHelper) => ({ userAdmin: helper.getMe()?.user_admin ?? false, })); diff --git a/openbas-front/src/admin/components/scenarios/scenario/challenges/ScenarioChallenges.tsx b/openbas-front/src/admin/components/scenarios/scenario/challenges/ScenarioChallenges.tsx index a8442ac7e0..0733082996 100644 --- a/openbas-front/src/admin/components/scenarios/scenario/challenges/ScenarioChallenges.tsx +++ b/openbas-front/src/admin/components/scenarios/scenario/challenges/ScenarioChallenges.tsx @@ -3,7 +3,7 @@ import { useParams } from 'react-router-dom'; import { useAppDispatch } from '../../../../../utils/hooks'; import type { ScenarioStore } from '../../../../../actions/scenarios/Scenario'; import { useHelper } from '../../../../../store'; -import type { ChallengesHelper } from '../../../../../actions/helper'; +import type { ChallengeHelper } from '../../../../../actions/helper'; import useDataLoader from '../../../../../utils/hooks/useDataLoader'; import { fetchScenarioChallenges } from '../../../../../actions/Challenge'; import ContextualChallenges from '../../../common/challenges/ContextualChallenges'; @@ -14,7 +14,7 @@ const ScenarioChallenges = () => { const dispatch = useAppDispatch(); // Fetching data const { scenarioId } = useParams() as { scenarioId: ScenarioStore['scenario_id'] }; - const challenges = useHelper((helper: ChallengesHelper) => helper.getScenarioChallenges(scenarioId)); + const challenges = useHelper((helper: ChallengeHelper) => helper.getScenarioChallenges(scenarioId)); useDataLoader(() => { dispatch(fetchScenarioChallenges(scenarioId)); }); diff --git a/openbas-front/src/admin/components/scenarios/scenario/injects/ScenarioInjects.tsx b/openbas-front/src/admin/components/scenarios/scenario/injects/ScenarioInjects.tsx index 3bb93b8734..f700f69400 100644 --- a/openbas-front/src/admin/components/scenarios/scenario/injects/ScenarioInjects.tsx +++ b/openbas-front/src/admin/components/scenarios/scenario/injects/ScenarioInjects.tsx @@ -7,7 +7,7 @@ import { useAppDispatch } from '../../../../../utils/hooks'; import { useHelper } from '../../../../../store'; import type { InjectHelper } from '../../../../../actions/injects/inject-helper'; import type { ArticlesHelper } from '../../../../../actions/channels/article-helper'; -import type { ChallengesHelper } from '../../../../../actions/helper'; +import type { ChallengeHelper } from '../../../../../actions/helper'; import type { VariablesHelper } from '../../../../../actions/variables/variable-helper'; import type { ScenariosHelper } from '../../../../../actions/scenarios/scenario-helper'; import useDataLoader from '../../../../../utils/hooks/useDataLoader'; @@ -32,7 +32,7 @@ const ScenarioInjects: FunctionComponent = () => { const { scenarioId } = useParams() as { scenarioId: ScenarioStore['scenario_id'] }; const { injects, scenario, teams, articles, variables } = useHelper( - (helper: InjectHelper & ScenariosHelper & ArticlesHelper & ChallengesHelper & VariablesHelper) => { + (helper: InjectHelper & ScenariosHelper & ArticlesHelper & ChallengeHelper & VariablesHelper) => { return { injects: helper.getScenarioInjects(scenarioId), scenario: helper.getScenario(scenarioId), diff --git a/openbas-front/src/admin/components/simulations/ExerciseList.tsx b/openbas-front/src/admin/components/simulations/ExerciseList.tsx index 2d7c1211cb..f95ff3163c 100644 --- a/openbas-front/src/admin/components/simulations/ExerciseList.tsx +++ b/openbas-front/src/admin/components/simulations/ExerciseList.tsx @@ -12,7 +12,7 @@ import TagsFilter from '../common/filters/TagsFilter'; import { exportData } from '../../../utils/Environment'; import useSearchAnFilter from '../../../utils/SortingFiltering'; import { useHelper } from '../../../store'; -import type { TagsHelper } from '../../../actions/helper'; +import type { TagHelper } from '../../../actions/helper'; import { useFormatter } from '../../../components/i18n'; import type { ExerciseSimpleStore, ExerciseStore } from '../../../actions/exercises/Exercise'; import AtomicTestingResult from '../atomic_testings/atomic_testing/AtomicTestingResult'; @@ -136,7 +136,7 @@ const ExerciseList: FunctionComponent = ({ const { t, nsdt } = useFormatter(); // Fetching data - const { tagsMap } = useHelper((helper: TagsHelper) => ({ + const { tagsMap } = useHelper((helper: TagHelper) => ({ tagsMap: helper.getTagsMap(), })); const searchColumns = ['name']; diff --git a/openbas-front/src/admin/components/simulations/Exercises.tsx b/openbas-front/src/admin/components/simulations/Exercises.tsx index d5e3859843..f857f21991 100644 --- a/openbas-front/src/admin/components/simulations/Exercises.tsx +++ b/openbas-front/src/admin/components/simulations/Exercises.tsx @@ -8,7 +8,7 @@ import ExerciseCreation from './simulation/ExerciseCreation'; import ExerciseList from './ExerciseList'; import { useAppDispatch } from '../../../utils/hooks'; import type { ExercisesHelper } from '../../../actions/exercises/exercise-helper'; -import type { UsersHelper } from '../../../actions/helper'; +import type { UserHelper } from '../../../actions/helper'; const Exercises = () => { // Standard hooks @@ -16,7 +16,7 @@ const Exercises = () => { const { t } = useFormatter(); // Fetching data - const { exercises, userAdmin } = useHelper((helper: ExercisesHelper & UsersHelper) => ({ + const { exercises, userAdmin } = useHelper((helper: ExercisesHelper & UserHelper) => ({ exercises: helper.getExercises(), userAdmin: helper.getMe()?.user_admin ?? false, })); diff --git a/openbas-front/src/admin/components/simulations/simulation/challenges/ExerciseChallenges.tsx b/openbas-front/src/admin/components/simulations/simulation/challenges/ExerciseChallenges.tsx index abdbd0a04d..8c674065e8 100644 --- a/openbas-front/src/admin/components/simulations/simulation/challenges/ExerciseChallenges.tsx +++ b/openbas-front/src/admin/components/simulations/simulation/challenges/ExerciseChallenges.tsx @@ -6,7 +6,7 @@ import { useHelper } from '../../../../../store'; import useDataLoader from '../../../../../utils/hooks/useDataLoader'; import ContextualChallenges from '../../../common/challenges/ContextualChallenges'; import { fetchExerciseChallenges } from '../../../../../actions/Challenge'; -import type { ChallengesHelper } from '../../../../../actions/helper'; +import type { ChallengeHelper } from '../../../../../actions/helper'; import { ChallengeContext, ChallengeContextType } from '../../../common/Context'; const ExerciseChallenges = () => { @@ -14,7 +14,7 @@ const ExerciseChallenges = () => { const dispatch = useAppDispatch(); // Fetching data const { exerciseId } = useParams() as { exerciseId: Exercise['exercise_id'] }; - const challenges = useHelper((helper: ChallengesHelper) => helper.getExerciseChallenges(exerciseId)); + const challenges = useHelper((helper: ChallengeHelper) => helper.getExerciseChallenges(exerciseId)); useDataLoader(() => { dispatch(fetchExerciseChallenges(exerciseId)); }); diff --git a/openbas-front/src/admin/components/simulations/simulation/controls/CreateControl.tsx b/openbas-front/src/admin/components/simulations/simulation/controls/CreateControl.tsx index 58ad4f7169..c255f9c6e6 100644 --- a/openbas-front/src/admin/components/simulations/simulation/controls/CreateControl.tsx +++ b/openbas-front/src/admin/components/simulations/simulation/controls/CreateControl.tsx @@ -16,7 +16,7 @@ import { addDryrun } from '../../../../../actions/Dryrun'; import { useFormatter } from '../../../../../components/i18n'; import Transition from '../../../../../components/common/Transition'; import { useHelper } from '../../../../../store'; -import type { UsersHelper } from '../../../../../actions/helper'; +import type { UserHelper } from '../../../../../actions/helper'; import type { TeamsHelper } from '../../../../../actions/teams/team-helper'; import type { ExercisesHelper } from '../../../../../actions/exercises/exercise-helper'; @@ -43,7 +43,7 @@ const CreateControl: React.FC = ({ exerciseId, variant }) => { const dispatch = useAppDispatch(); const { me, exercise, teams } = useHelper( - (helper: UsersHelper & ExercisesHelper & TeamsHelper) => { + (helper: UserHelper & ExercisesHelper & TeamsHelper) => { return { me: helper.getMe(), exercise: helper.getExercise(exerciseId), diff --git a/openbas-front/src/admin/components/simulations/simulation/injects/ExerciseInjects.tsx b/openbas-front/src/admin/components/simulations/simulation/injects/ExerciseInjects.tsx index 48138cf4f2..413bdf05c4 100644 --- a/openbas-front/src/admin/components/simulations/simulation/injects/ExerciseInjects.tsx +++ b/openbas-front/src/admin/components/simulations/simulation/injects/ExerciseInjects.tsx @@ -22,7 +22,7 @@ import { secondsFromToNow } from '../../../../../utils/Exercise'; import { fetchExerciseInjectExpectations, fetchExerciseTeams } from '../../../../../actions/Exercise'; import type { ExercisesHelper } from '../../../../../actions/exercises/exercise-helper'; import type { ArticlesHelper } from '../../../../../actions/channels/article-helper'; -import type { ChallengesHelper } from '../../../../../actions/helper'; +import type { ChallengeHelper } from '../../../../../actions/helper'; import type { VariablesHelper } from '../../../../../actions/variables/variable-helper'; import { fetchVariablesForExercise } from '../../../../../actions/variables/variable-actions'; import type { InjectHelper } from '../../../../../actions/injects/inject-helper'; @@ -61,7 +61,7 @@ const ExerciseInjects: FunctionComponent = () => { const { exerciseId } = useParams() as { exerciseId: Exercise['exercise_id'] }; const { injects, exercise, teams, articles, variables } = useHelper( - (helper: InjectHelper & ExercisesHelper & ArticlesHelper & ChallengesHelper & VariablesHelper) => { + (helper: InjectHelper & ExercisesHelper & ArticlesHelper & ChallengeHelper & VariablesHelper) => { return { injects: helper.getExerciseInjects(exerciseId), exercise: helper.getExercise(exerciseId), diff --git a/openbas-front/src/admin/components/simulations/simulation/mails/MailDistributionByPlayer.tsx b/openbas-front/src/admin/components/simulations/simulation/mails/MailDistributionByPlayer.tsx index 894c69ceac..bac7115ee3 100644 --- a/openbas-front/src/admin/components/simulations/simulation/mails/MailDistributionByPlayer.tsx +++ b/openbas-front/src/admin/components/simulations/simulation/mails/MailDistributionByPlayer.tsx @@ -14,7 +14,7 @@ import type { Communication, User } from '../../../../../utils/api-types'; import { resolveUserName } from '../../../../../utils/String'; import type { CommunicationHelper } from '../../../../../actions/communications/communication-helper'; import { fetchExerciseCommunications } from '../../../../../actions/Communication'; -import type { UsersHelper } from '../../../../../actions/helper'; +import type { UserHelper } from '../../../../../actions/helper'; import { fetchPlayers } from '../../../../../actions/User'; interface Props { @@ -30,7 +30,7 @@ const MailDistributionByPlayer: FunctionComponent = ({ const theme: Theme = useTheme(); // Fetching data - const { communications, usersMap } = useHelper((helper: CommunicationHelper & UsersHelper) => ({ + const { communications, usersMap } = useHelper((helper: CommunicationHelper & UserHelper) => ({ communications: helper.getExerciseCommunications(exerciseId), usersMap: helper.getUsersMap(), })); diff --git a/openbas-front/src/admin/components/simulations/simulation/overview/ExerciseDistributionScoreByOrganization.tsx b/openbas-front/src/admin/components/simulations/simulation/overview/ExerciseDistributionScoreByOrganization.tsx index 65a1cd0bd9..5577d008b5 100644 --- a/openbas-front/src/admin/components/simulations/simulation/overview/ExerciseDistributionScoreByOrganization.tsx +++ b/openbas-front/src/admin/components/simulations/simulation/overview/ExerciseDistributionScoreByOrganization.tsx @@ -9,7 +9,7 @@ import { useFormatter } from '../../../../../components/i18n'; import type { Theme } from '../../../../../components/Theme'; import { useHelper } from '../../../../../store'; import type { InjectHelper } from '../../../../../actions/injects/inject-helper'; -import type { OrganizationsHelper, UsersHelper } from '../../../../../actions/helper'; +import type { OrganizationHelper, UserHelper } from '../../../../../actions/helper'; import type { InjectExpectationStore } from '../../../../../actions/injects/Inject'; import { computeOrganizationsColors } from './DistributionUtils'; import type { Organization } from '../../../../../utils/api-types'; @@ -26,7 +26,7 @@ const ExerciseDistributionScoreByOrganization: FunctionComponent = ({ const theme: Theme = useTheme(); // Fetching data - const { injectExpectations, organizations, organizationsMap, usersMap } = useHelper((helper: InjectHelper & OrganizationsHelper & UsersHelper) => ({ + const { injectExpectations, organizations, organizationsMap, usersMap } = useHelper((helper: InjectHelper & OrganizationHelper & UserHelper) => ({ injectExpectations: helper.getExerciseInjectExpectations(exerciseId), organizationsMap: helper.getOrganizationsMap(), usersMap: helper.getUsersMap(), diff --git a/openbas-front/src/admin/components/simulations/simulation/overview/ExerciseDistributionScoreByPlayer.tsx b/openbas-front/src/admin/components/simulations/simulation/overview/ExerciseDistributionScoreByPlayer.tsx index 92888c6fc8..126a6d60f3 100644 --- a/openbas-front/src/admin/components/simulations/simulation/overview/ExerciseDistributionScoreByPlayer.tsx +++ b/openbas-front/src/admin/components/simulations/simulation/overview/ExerciseDistributionScoreByPlayer.tsx @@ -10,7 +10,7 @@ import type { Theme } from '../../../../../components/Theme'; import { useHelper } from '../../../../../store'; import type { InjectHelper } from '../../../../../actions/injects/inject-helper'; import { resolveUserName } from '../../../../../utils/String'; -import type { UsersHelper } from '../../../../../actions/helper'; +import type { UserHelper } from '../../../../../actions/helper'; import type { InjectExpectation, User } from '../../../../../utils/api-types'; import type { InjectExpectationStore } from '../../../../../actions/injects/Inject'; @@ -26,7 +26,7 @@ const ExerciseDistributionScoreByPlayer: FunctionComponent = ({ const theme: Theme = useTheme(); // Fetching data - const { injectExpectations, usersMap } = useHelper((helper: InjectHelper & UsersHelper) => ({ + const { injectExpectations, usersMap } = useHelper((helper: InjectHelper & UserHelper) => ({ injectExpectations: helper.getExerciseInjectExpectations(exerciseId), usersMap: helper.getUsersMap(), })); diff --git a/openbas-front/src/admin/components/simulations/simulation/validation/common/TeamOrAssetLine.tsx b/openbas-front/src/admin/components/simulations/simulation/validation/common/TeamOrAssetLine.tsx index 22d28fa054..e5cbb341bc 100644 --- a/openbas-front/src/admin/components/simulations/simulation/validation/common/TeamOrAssetLine.tsx +++ b/openbas-front/src/admin/components/simulations/simulation/validation/common/TeamOrAssetLine.tsx @@ -20,8 +20,8 @@ import { fetchExerciseChallenges } from '../../../../../../actions/Challenge'; import { fetchEndpoints } from '../../../../../../actions/assets/endpoint-actions'; import { fetchAssetGroups } from '../../../../../../actions/asset_groups/assetgroup-action'; import type { AssetGroupsHelper } from '../../../../../../actions/asset_groups/assetgroup-helper'; -import type { EndpointsHelper } from '../../../../../../actions/assets/asset-helper'; -import type { ChallengesHelper } from '../../../../../../actions/helper'; +import type { EndpointHelper } from '../../../../../../actions/assets/asset-helper'; +import type { ChallengeHelper } from '../../../../../../actions/helper'; import type { ArticlesHelper } from '../../../../../../actions/channels/article-helper'; import type { ChannelsHelper } from '../../../../../../actions/channels/channel-helper'; import type { TeamsHelper } from '../../../../../../actions/teams/team-helper'; @@ -68,7 +68,7 @@ const TeamOrAssetLine: FunctionComponent = ({ challengesMap, articlesMap, channelsMap, - } = useHelper((helper: ArticlesHelper & AssetGroupsHelper & EndpointsHelper & ChallengesHelper & ChannelsHelper & TeamsHelper) => { + } = useHelper((helper: ArticlesHelper & AssetGroupsHelper & EndpointHelper & ChallengeHelper & ChannelsHelper & TeamsHelper) => { return { articlesMap: helper.getArticlesMap(), assetsMap: helper.getEndpointsMap(), diff --git a/openbas-front/src/admin/components/simulations/simulation/validation/expectations/TechnicalExpectationAssetGroup.tsx b/openbas-front/src/admin/components/simulations/simulation/validation/expectations/TechnicalExpectationAssetGroup.tsx index 8c52758b98..e7a656217e 100644 --- a/openbas-front/src/admin/components/simulations/simulation/validation/expectations/TechnicalExpectationAssetGroup.tsx +++ b/openbas-front/src/admin/components/simulations/simulation/validation/expectations/TechnicalExpectationAssetGroup.tsx @@ -10,7 +10,7 @@ import { typeIcon } from '../../../../common/injects/expectations/ExpectationUti import type { EndpointStore } from '../../../../assets/endpoints/Endpoint'; import TechnicalExpectationAsset from './TechnicalExpectationAsset'; import { useHelper } from '../../../../../../store'; -import type { EndpointsHelper } from '../../../../../../actions/assets/asset-helper'; +import type { EndpointHelper } from '../../../../../../actions/assets/asset-helper'; import type { AssetGroupStore } from '../../../../assets/asset_groups/AssetGroup'; import groupedByAsset from './ExpectationUtils'; @@ -46,7 +46,7 @@ const TechnicalExpectationAssetGroup: FunctionComponent = ({ // Fetching data const { assetsMap, - } = useHelper((helper: EndpointsHelper) => { + } = useHelper((helper: EndpointHelper) => { return { assetsMap: helper.getEndpointsMap(), }; diff --git a/openbas-front/src/admin/components/simulations/simulation/variables/AvailableVariablesDialog.tsx b/openbas-front/src/admin/components/simulations/simulation/variables/AvailableVariablesDialog.tsx index 3d452ffdf6..3b9c82630b 100644 --- a/openbas-front/src/admin/components/simulations/simulation/variables/AvailableVariablesDialog.tsx +++ b/openbas-front/src/admin/components/simulations/simulation/variables/AvailableVariablesDialog.tsx @@ -8,7 +8,7 @@ import Transition from '../../../../../components/common/Transition'; import { useFormatter } from '../../../../../components/i18n'; import type { Variable } from '../../../../../utils/api-types'; import { useHelper } from '../../../../../store'; -import type { UsersHelper } from '../../../../../actions/helper'; +import type { UserHelper } from '../../../../../actions/helper'; import type { Contract } from '../../../../../actions/contract/contract'; import { copyToClipboard } from '../../../../../utils/utils'; @@ -89,7 +89,7 @@ AvailableVariablesDialogProps setTab(newTab); }; - const me = useHelper((helper: UsersHelper) => helper.getMe()); + const me = useHelper((helper: UserHelper) => helper.getMe()); return ( { const { t } = useFormatter(); // Fetching data - const { organizations, tagsMap, userAdmin } = useHelper((helper: UsersHelper & TagsHelper & OrganizationsHelper) => ({ + const { organizations, tagsMap, userAdmin } = useHelper((helper: UserHelper & TagHelper & OrganizationHelper) => ({ organizations: helper.getOrganizations(), tagsMap: helper.getTagsMap(), userAdmin: helper.getMe()?.user_admin, diff --git a/openbas-front/src/admin/components/teams/Players.tsx b/openbas-front/src/admin/components/teams/Players.tsx index ad5ddab2be..ea982eeb31 100644 --- a/openbas-front/src/admin/components/teams/Players.tsx +++ b/openbas-front/src/admin/components/teams/Players.tsx @@ -13,7 +13,7 @@ import { useHelper } from '../../../store'; import { useFormatter } from '../../../components/i18n'; import Breadcrumbs from '../../../components/Breadcrumbs'; import { initSorting } from '../../../components/common/pagination/Page'; -import type { OrganizationsHelper, UsersHelper } from '../../../actions/helper'; +import type { OrganizationHelper, UserHelper } from '../../../actions/helper'; import PaginationComponent from '../../../components/common/pagination/PaginationComponent'; import SortHeadersComponent from '../../../components/common/pagination/SortHeadersComponent'; import type { UserStore } from './players/Player'; @@ -89,7 +89,7 @@ const Players = () => { }); // Fetching data - const { isPlanner, organizationsMap } = useHelper((helper: UsersHelper & OrganizationsHelper) => ({ + const { isPlanner, organizationsMap } = useHelper((helper: UserHelper & OrganizationHelper) => ({ isPlanner: helper.getMe().user_is_planner, organizationsMap: helper.getOrganizationsMap(), })); diff --git a/openbas-front/src/admin/components/teams/Teams.tsx b/openbas-front/src/admin/components/teams/Teams.tsx index 40fe198f1a..bc3485e0e2 100644 --- a/openbas-front/src/admin/components/teams/Teams.tsx +++ b/openbas-front/src/admin/components/teams/Teams.tsx @@ -2,7 +2,7 @@ import React from 'react'; import TeamsComponent from '../components/teams/Teams'; import { PermissionsContext, PermissionsContextType, TeamContext, type TeamContextType } from '../common/Context'; import { useHelper } from '../../../store'; -import type { UsersHelper } from '../../../actions/helper'; +import type { UserHelper } from '../../../actions/helper'; import type { TeamStore } from '../../../actions/teams/Team'; import type { Team, User } from '../../../utils/api-types'; import type { TeamsHelper } from '../../../actions/teams/team-helper'; @@ -12,7 +12,7 @@ import { useAppDispatch } from '../../../utils/hooks'; const Teams = () => { const dispatch = useAppDispatch(); - const { user, teams }: { user: User, teams: TeamStore[] } = useHelper((helper: UsersHelper & TeamsHelper) => ({ + const { user, teams }: { user: User, teams: TeamStore[] } = useHelper((helper: UserHelper & TeamsHelper) => ({ user: helper.getMe(), teams: helper.getTeams(), })); diff --git a/openbas-front/src/admin/components/teams/players/PlayerPopover.tsx b/openbas-front/src/admin/components/teams/players/PlayerPopover.tsx index 4082a97d2d..765a9720f3 100644 --- a/openbas-front/src/admin/components/teams/players/PlayerPopover.tsx +++ b/openbas-front/src/admin/components/teams/players/PlayerPopover.tsx @@ -10,7 +10,7 @@ import Transition from '../../../../components/common/Transition'; import type { UpdatePlayerInput } from '../../../../utils/api-types'; import { countryOption, Option, organizationOption, tagOptions } from '../../../../utils/Option'; import { useHelper } from '../../../../store'; -import type { OrganizationsHelper, TagsHelper, UsersHelper } from '../../../../actions/helper'; +import type { OrganizationHelper, TagHelper, UserHelper } from '../../../../actions/helper'; import type { PlayerInputForm, UserStore } from './Player'; import { TeamContext } from '../../common/Context'; @@ -33,7 +33,7 @@ const PlayerPopover: FunctionComponent = ({ const dispatch = useAppDispatch(); const { userAdmin, organizationsMap, tagsMap } = useHelper( ( - helper: UsersHelper & OrganizationsHelper & TagsHelper, + helper: UserHelper & OrganizationHelper & TagHelper, ) => { return { userAdmin: helper.getMe()?.user_admin, diff --git a/openbas-front/src/components/common/ExportButton.tsx b/openbas-front/src/components/common/ExportButton.tsx index abdb0b6325..21f20031d0 100644 --- a/openbas-front/src/components/common/ExportButton.tsx +++ b/openbas-front/src/components/common/ExportButton.tsx @@ -5,7 +5,7 @@ import { CSVLink } from 'react-csv'; import { exportData } from '../../utils/Environment'; import { useFormatter } from '../i18n'; import { useHelper } from '../../store'; -import type { TagsHelper } from '../../actions/helper'; +import type { TagHelper } from '../../actions/helper'; export interface ExportProps { exportType: string; @@ -23,7 +23,7 @@ const ExportButton = ({ totalElements, exportProps }: Props // Standard hooks const { t } = useFormatter(); // Fetching data - const { tagsMap } = useHelper((helper: TagsHelper) => ({ + const { tagsMap } = useHelper((helper: TagHelper) => ({ tagsMap: helper.getTagsMap(), })); diff --git a/openbas-front/src/components/common/ImportUploader.tsx b/openbas-front/src/components/common/ImportUploader.tsx index 3043d2e14d..7e0e433d2d 100644 --- a/openbas-front/src/components/common/ImportUploader.tsx +++ b/openbas-front/src/components/common/ImportUploader.tsx @@ -3,7 +3,7 @@ import { CircularProgress, CircularProgressProps, IconButton, ToggleButton, Tool import { CloudUploadOutlined } from '@mui/icons-material'; import { useFormatter } from '../i18n'; import { useHelper } from '../../store'; -import type { UsersHelper } from '../../actions/helper'; +import type { UserHelper } from '../../actions/helper'; interface Props { title: string; @@ -21,7 +21,7 @@ const ImportUploader: FunctionComponent = ({ const uploadRef = useRef(null); const [upload, setUpload] = useState(false); const handleOpenUpload = () => uploadRef.current && uploadRef.current.click(); - const userAdmin = useHelper((helper: UsersHelper) => { + const userAdmin = useHelper((helper: UserHelper) => { const me = helper.getMe(); return me?.user_admin ?? false; }); diff --git a/openbas-front/src/components/fields/TagField.tsx b/openbas-front/src/components/fields/TagField.tsx index b0d32881e9..7755e37dee 100644 --- a/openbas-front/src/components/fields/TagField.tsx +++ b/openbas-front/src/components/fields/TagField.tsx @@ -8,7 +8,7 @@ import { useAppDispatch } from '../../utils/hooks'; import useDataLoader from '../../utils/hooks/useDataLoader'; import type { Tag } from '../../utils/api-types'; import { useHelper } from '../../store'; -import type { TagsHelper, UsersHelper } from '../../actions/helper'; +import type { TagHelper, UserHelper } from '../../actions/helper'; import { useFormatter } from '../i18n'; import { addTag, fetchTags } from '../../actions/Tag'; import TagForm from '../../admin/components/settings/tags/TagForm'; @@ -50,7 +50,7 @@ const TagField: FunctionComponent = ({ const classes = useStyles(); // Fetching data - const { tags, userAdmin }: { tags: [Tag]; userAdmin: boolean } = useHelper((helper: TagsHelper & UsersHelper) => ({ + const { tags, userAdmin }: { tags: [Tag]; userAdmin: boolean } = useHelper((helper: TagHelper & UserHelper) => ({ tags: helper.getTags(), userAdmin: helper.getMe()?.user_admin ?? false, })); diff --git a/openbas-front/src/utils/Scenario.tsx b/openbas-front/src/utils/Scenario.tsx index 5b942b51ff..21fff2af25 100644 --- a/openbas-front/src/utils/Scenario.tsx +++ b/openbas-front/src/utils/Scenario.tsx @@ -1,10 +1,10 @@ import * as R from 'ramda'; import { useHelper } from '../store'; import type { ScenariosHelper } from '../actions/scenarios/scenario-helper'; -import type { LoggedHelper, UsersHelper } from '../actions/helper'; +import type { LoggedHelper, UserHelper } from '../actions/helper'; const useScenarioPermissions = (scenarioId: string, fullScenario = null) => { - const { scenario, me, logged } = useHelper((helper: ScenariosHelper & UsersHelper & LoggedHelper) => { + const { scenario, me, logged } = useHelper((helper: ScenariosHelper & UserHelper & LoggedHelper) => { return { scenario: helper.getScenario(scenarioId), me: helper.getMe(), diff --git a/openbas-front/src/utils/api-types.d.ts b/openbas-front/src/utils/api-types.d.ts index e025ec3121..2ea11c888f 100644 --- a/openbas-front/src/utils/api-types.d.ts +++ b/openbas-front/src/utils/api-types.d.ts @@ -100,6 +100,8 @@ export interface Asset { asset_active?: boolean; asset_children?: Asset[]; /** @format date-time */ + asset_cleared_at?: string; + /** @format date-time */ asset_created_at?: string; asset_description?: string; asset_executor?: Executor; @@ -492,7 +494,7 @@ export interface DryInject { export interface DryInjectStatus { status_id?: string; - status_name?: "INFO" | "DRAFT" | "QUEUING" | "STARTING" | "RUNNING" | "PENDING" | "PARTIAL" | "ERROR" | "SUCCESS"; + status_name?: "DRAFT" | "INFO" | "QUEUING" | "PENDING" | "PARTIAL" | "ERROR" | "SUCCESS"; status_traces?: InjectStatusExecution[]; /** @format date-time */ tracking_ack_date?: string; @@ -539,6 +541,8 @@ export interface Endpoint { asset_active?: boolean; asset_children?: Asset[]; /** @format date-time */ + asset_cleared_at?: string; + /** @format date-time */ asset_created_at?: string; asset_description?: string; asset_executor?: Executor; @@ -1007,7 +1011,7 @@ export interface InjectResultDTO { export interface InjectStatus { status_id?: string; - status_name?: "INFO" | "DRAFT" | "QUEUING" | "STARTING" | "RUNNING" | "PENDING" | "PARTIAL" | "ERROR" | "SUCCESS"; + status_name?: "DRAFT" | "INFO" | "QUEUING" | "PENDING" | "PARTIAL" | "ERROR" | "SUCCESS"; status_traces?: InjectStatusExecution[]; /** @format date-time */ tracking_ack_date?: string; @@ -1032,16 +1036,7 @@ export interface InjectStatusExecution { /** @format int32 */ execution_duration?: number; execution_message?: string; - execution_status?: - | "INFO" - | "DRAFT" - | "QUEUING" - | "STARTING" - | "RUNNING" - | "PENDING" - | "PARTIAL" - | "ERROR" - | "SUCCESS"; + execution_status?: "DRAFT" | "INFO" | "QUEUING" | "PENDING" | "PARTIAL" | "ERROR" | "SUCCESS"; /** @format date-time */ execution_time?: string; } @@ -1082,6 +1077,7 @@ export interface Injector { /** @format date-time */ injector_created_at?: string; injector_custom_contracts?: boolean; + injector_executor_clear_commands?: Record; injector_executor_commands?: Record; injector_external?: boolean; injector_id: string; @@ -1162,6 +1158,7 @@ export interface InjectorCreateInput { injector_category?: string; injector_contracts?: InjectorContractInput[]; injector_custom_contracts?: boolean; + injector_executor_clear_commands?: Record; injector_executor_commands?: Record; injector_id: string; injector_name: string; @@ -1177,6 +1174,7 @@ export interface InjectorUpdateInput { injector_category?: string; injector_contracts?: InjectorContractInput[]; injector_custom_contracts?: boolean; + injector_executor_clear_commands?: Record; injector_executor_commands?: Record; injector_name: string; } @@ -1840,6 +1838,7 @@ export interface Payload { } export interface PayloadCreateInput { + payload_content: string; payload_description?: string; payload_name: string; payload_tags?: string[]; @@ -1847,6 +1846,7 @@ export interface PayloadCreateInput { } export interface PayloadUpdateInput { + payload_content: string; payload_description?: string; payload_name: string; payload_tags?: string[];