diff --git a/openbas-api/src/test/java/io/openbas/helper/InjectHelperTest.java b/openbas-api/src/test/java/io/openbas/helper/InjectHelperTest.java index 8578774a52..ccec7359f2 100644 --- a/openbas-api/src/test/java/io/openbas/helper/InjectHelperTest.java +++ b/openbas-api/src/test/java/io/openbas/helper/InjectHelperTest.java @@ -78,7 +78,7 @@ void injectsToRunTest() { Inject inject = new Inject(); inject.setTitle("Test inject"); inject.setType(TYPE); - inject.setInjectorContract(injectorContractRepository.findById(EMAIL_DEFAULT).orElseThrow()); + inject.setInjectorContract(this.injectorContractRepository.findById(EMAIL_DEFAULT).orElseThrow()); inject.setEnabled(true); inject.setExercise(exerciseSaved); inject.setTeams(List.of(team)); diff --git a/openbas-api/src/test/java/io/openbas/injects/InjectCrudTest.java b/openbas-api/src/test/java/io/openbas/injects/InjectCrudTest.java index 7d89dffc1a..39eaf20271 100644 --- a/openbas-api/src/test/java/io/openbas/injects/InjectCrudTest.java +++ b/openbas-api/src/test/java/io/openbas/injects/InjectCrudTest.java @@ -5,7 +5,6 @@ import io.openbas.database.repository.ExerciseRepository; import io.openbas.database.repository.InjectRepository; import io.openbas.database.repository.InjectorContractRepository; -import io.openbas.injectors.email.EmailContract; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -25,6 +24,7 @@ public class InjectCrudTest { @Autowired private ExerciseRepository exerciseRepository; + @Autowired private InjectorContractRepository injectorContractRepository; @@ -40,7 +40,7 @@ void createInjectSuccess() { Inject inject = new Inject(); inject.setTitle("test"); inject.setType(TYPE); - inject.setInjectorContract(injectorContractRepository.findById(EmailContract.EMAIL_DEFAULT).orElseThrow()); + inject.setInjectorContract(this.injectorContractRepository.findById(EMAIL_DEFAULT).orElseThrow()); inject.setExercise(exerciseCreated); inject.setDependsDuration(0L); diff --git a/openbas-api/src/test/java/io/openbas/injects/email/EmailExecutorTest.java b/openbas-api/src/test/java/io/openbas/injects/email/EmailExecutorTest.java index a1f508456d..58cb675284 100644 --- a/openbas-api/src/test/java/io/openbas/injects/email/EmailExecutorTest.java +++ b/openbas-api/src/test/java/io/openbas/injects/email/EmailExecutorTest.java @@ -22,6 +22,7 @@ import java.util.List; +import static io.openbas.injectors.email.EmailContract.EMAIL_DEFAULT; import static io.openbas.helper.StreamHelper.fromIterable; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -53,7 +54,7 @@ void process() throws Exception { content.setExpectations(List.of(expectation)); Inject inject = new Inject(); inject.setType(EmailContract.TYPE); - inject.setInjectorContract(injectorContractRepository.findById(EmailContract.EMAIL_DEFAULT).orElseThrow()); + inject.setInjectorContract(this.injectorContractRepository.findById(EMAIL_DEFAULT).orElseThrow()); inject.setContent(this.mapper.valueToTree(content)); Iterable users = this.userRepository.findAll(); List userInjectContexts = fromIterable(users).stream() diff --git a/openbas-api/src/test/java/io/openbas/rest/ChallengeApiTest.java b/openbas-api/src/test/java/io/openbas/rest/ChallengeApiTest.java index db682947bc..51d0969a5f 100644 --- a/openbas-api/src/test/java/io/openbas/rest/ChallengeApiTest.java +++ b/openbas-api/src/test/java/io/openbas/rest/ChallengeApiTest.java @@ -7,6 +7,7 @@ import io.openbas.database.model.Scenario; import io.openbas.database.repository.ChallengeRepository; import io.openbas.database.repository.InjectRepository; +import io.openbas.database.repository.InjectorContractRepository; import io.openbas.database.repository.ScenarioRepository; import io.openbas.injectors.challenge.model.ChallengeContent; import io.openbas.service.ScenarioService; @@ -47,6 +48,8 @@ public class ChallengeApiTest { private InjectRepository injectRepository; @Autowired private ChallengeRepository challengeRepository; + @Autowired + private InjectorContractRepository injectorContractRepository; @Resource private ObjectMapper objectMapper; @@ -84,7 +87,7 @@ void retrieveChallengesVariableForScenarioTest() throws Exception { Inject inject = new Inject(); inject.setTitle("Test inject"); inject.setType(TYPE); - inject.setContract(CHALLENGE_PUBLISH); + inject.setInjectorContract(this.injectorContractRepository.findById(CHALLENGE_PUBLISH).orElseThrow()); inject.setContent(this.objectMapper.valueToTree(content)); inject.setDependsDuration(0L); inject.setScenario(scenario); diff --git a/openbas-api/src/test/java/io/openbas/rest/InjectApiTest.java b/openbas-api/src/test/java/io/openbas/rest/InjectApiTest.java index a86b87cfea..325f1b53af 100644 --- a/openbas-api/src/test/java/io/openbas/rest/InjectApiTest.java +++ b/openbas-api/src/test/java/io/openbas/rest/InjectApiTest.java @@ -146,7 +146,7 @@ void updateInjectForScenarioTest() throws Exception { String injectTitle = "A new title"; input.setTitle(injectTitle); input.setType(inject.getType()); - input.setContract(inject.getContract()); + input.setInjectorContract(inject.getInjectorContract().getId()); input.setDependsDuration(inject.getDependsDuration()); // -- EXECUTE -- diff --git a/openbas-api/src/test/java/io/openbas/scenario/ScenarioToExerciseServiceTest.java b/openbas-api/src/test/java/io/openbas/scenario/ScenarioToExerciseServiceTest.java index 51b9463271..b3ebfdc7a4 100644 --- a/openbas-api/src/test/java/io/openbas/scenario/ScenarioToExerciseServiceTest.java +++ b/openbas-api/src/test/java/io/openbas/scenario/ScenarioToExerciseServiceTest.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.List; +import static io.openbas.injectors.email.EmailContract.EMAIL_DEFAULT; import static io.openbas.utils.fixtures.ArticleFixture.ARTICLE_NAME; import static io.openbas.utils.fixtures.ArticleFixture.getArticle; import static io.openbas.utils.fixtures.DocumentFixture.getDocumentJpeg; @@ -196,7 +197,7 @@ void scenarioToExerciseTest() { }}); // Inject - Inject inject = getInjectForEmailContract(); + Inject inject = getInjectForEmailContract(this.injectorContractRepository.findById(EMAIL_DEFAULT).orElseThrow()); inject.setTeams(new ArrayList<>() {{ add(teamSaved); add(contextualTeamSaved); diff --git a/openbas-api/src/test/java/io/openbas/service/ExerciseExpectationServiceTest.java b/openbas-api/src/test/java/io/openbas/service/ExerciseExpectationServiceTest.java index ca9d96605c..11d678ad06 100644 --- a/openbas-api/src/test/java/io/openbas/service/ExerciseExpectationServiceTest.java +++ b/openbas-api/src/test/java/io/openbas/service/ExerciseExpectationServiceTest.java @@ -64,7 +64,7 @@ void beforeAll() { Inject inject = new Inject(); inject.setTitle("test"); inject.setType(TYPE); - inject.setInjectorContract(injectorContractRepository.findById(EMAIL_DEFAULT).orElseThrow()); + inject.setInjectorContract(this.injectorContractRepository.findById(EMAIL_DEFAULT).orElseThrow()); inject.setExercise(exerciseCreated); inject.setDependsDuration(0L); Inject injectCreated = this.injectRepository.save(inject); diff --git a/openbas-api/src/test/java/io/openbas/utils/fixtures/InjectFixture.java b/openbas-api/src/test/java/io/openbas/utils/fixtures/InjectFixture.java index 1a44942702..21a03a94fd 100644 --- a/openbas-api/src/test/java/io/openbas/utils/fixtures/InjectFixture.java +++ b/openbas-api/src/test/java/io/openbas/utils/fixtures/InjectFixture.java @@ -1,21 +1,21 @@ package io.openbas.utils.fixtures; import io.openbas.database.model.Inject; +import io.openbas.database.model.InjectorContract; -import static io.openbas.injectors.email.EmailContract.EMAIL_DEFAULT; import static io.openbas.injectors.email.EmailContract.TYPE; public class InjectFixture { - public static final String INJECT_EMAIL_NAME = "Test email inject"; - - public static Inject getInjectForEmailContract() { - Inject inject = new Inject(); - inject.setTitle(INJECT_EMAIL_NAME); - inject.setType(TYPE); - inject.setEnabled(true); - inject.setDependsDuration(0L); - return inject; - } + public static final String INJECT_EMAIL_NAME = "Test email inject"; + public static Inject getInjectForEmailContract(InjectorContract injectorContract) { + Inject inject = new Inject(); + inject.setTitle(INJECT_EMAIL_NAME); + inject.setType(TYPE); + inject.setInjectorContract(injectorContract); + inject.setEnabled(true); + inject.setDependsDuration(0L); + return inject; + } } diff --git a/openbas-front/src/admin/components/common/injects/CreateinjectDetails.tsx b/openbas-front/src/admin/components/common/injects/CreateinjectDetails.tsx index 4c9223ca59..73db2ce5f1 100644 --- a/openbas-front/src/admin/components/common/injects/CreateinjectDetails.tsx +++ b/openbas-front/src/admin/components/common/injects/CreateinjectDetails.tsx @@ -1,7 +1,7 @@ import React, { FunctionComponent, useContext } from 'react'; import { Button } from '@mui/material'; import InjectDefinition from './InjectDefinition'; -import { PermissionsContext } from '..'; +import { PermissionsContext } from '../Context'; import type { Inject, Tag } from '../../../../utils/api-types'; import { useHelper } from '../../../../store'; import type { InjectHelper } from '../../../../actions/injects/inject-helper'; diff --git a/openbas-front/src/admin/components/common/injects/InjectPopover.tsx b/openbas-front/src/admin/components/common/injects/InjectPopover.tsx index 32801a8e57..d067c392d0 100644 --- a/openbas-front/src/admin/components/common/injects/InjectPopover.tsx +++ b/openbas-front/src/admin/components/common/injects/InjectPopover.tsx @@ -8,7 +8,6 @@ import { InjectContext, PermissionsContext } from '../Context'; import type { Inject, InjectStatus, InjectStatusExecution, Tag } from '../../../../utils/api-types'; import { tryInject } from '../../../../actions/Inject'; import { useAppDispatch } from '../../../../utils/hooks'; -import type { Contract } from '../../../../actions/contract/contract'; interface Props { inject: InjectStore; diff --git a/openbas-front/src/admin/components/common/injects/Injects.js b/openbas-front/src/admin/components/common/injects/Injects.js index 4c4a9b1fb0..3a7b23389c 100644 --- a/openbas-front/src/admin/components/common/injects/Injects.js +++ b/openbas-front/src/admin/components/common/injects/Injects.js @@ -16,8 +16,6 @@ import { useHelper } from '../../../../store'; import ItemBoolean from '../../../../components/ItemBoolean'; import { exportData } from '../../../../utils/Environment'; import Loader from '../../../../components/Loader'; -import useDataLoader from '../../../../utils/ServerSideEvent'; -import { useAppDispatch } from '../../../../utils/hooks'; import { InjectContext, PermissionsContext } from '../Context'; import CreateInject from './CreateInject'; import UpdateInject from './UpdateInject'; @@ -159,7 +157,6 @@ const Injects = ({ }) => { // Standard hooks const classes = useStyles(); - const dispatch = useAppDispatch(); const { t, tPick } = useFormatter(); const [selectedInjectId, setSelectedInjectId] = useState(null); @@ -174,9 +171,6 @@ const Injects = ({ searchColumns, ); // Fetching data - useDataLoader(() => { - dispatch(fetchInjectorContracts()); - }); const { tagsMap, selectedInject, @@ -313,7 +307,6 @@ const Injects = ({ const injectContract = inject.inject_injector_contract.injector_contract_content_parsed; const injectorContractName = tPick(injectContract?.label); const duration = splitDuration(inject.inject_depends_duration || 0); - console.log('injectContract', injectContract); const isDisabled = !injectContract?.config.expose; const isNoTeam = !(injectContract?.fields.filter((f) => f.key === 'teams').length > 0); let injectStatus = inject.inject_enabled diff --git a/openbas-front/src/admin/components/simulations/controls/Dryrun.js b/openbas-front/src/admin/components/simulations/controls/Dryrun.js index ff5047e302..ae292ea025 100644 --- a/openbas-front/src/admin/components/simulations/controls/Dryrun.js +++ b/openbas-front/src/admin/components/simulations/controls/Dryrun.js @@ -20,7 +20,6 @@ import InjectStatus from '../../common/injects/InjectStatus'; import InjectStatusDetails from '../../common/injects/InjectStatusDetails'; import { resolveUserName } from '../../../../utils/String'; import DryrunProgress from './DryrunProgress'; -import { fetchInjectorContracts } from '../../../../actions/InjectorContracts'; const useStyles = makeStyles((theme) => ({ parameters: { @@ -327,7 +326,7 @@ const Dryrun = () => {   {filtering.filterAndSort(dryinjects).map((dryinject) => { - const injectContract = injectorContractsMap[dryinject.dryinject_inject.inject_injector_contract]; + const injectContract = dryinject.inject_injector_contract.injector_contract_content_parsed; const injectorContractName = tPick(injectContract?.label); return ( ({ createButton: { @@ -98,7 +97,6 @@ export default R.compose( connect(select, { fetchExercises, fetchTags, - fetchInjectorContracts, }), inject18n, withTheme, diff --git a/openbas-front/src/admin/components/simulations/overview/ExerciseDistributionByInjectorContract.tsx b/openbas-front/src/admin/components/simulations/overview/ExerciseDistributionByInjectorContract.tsx index 43991c1beb..8cdb95b880 100644 --- a/openbas-front/src/admin/components/simulations/overview/ExerciseDistributionByInjectorContract.tsx +++ b/openbas-front/src/admin/components/simulations/overview/ExerciseDistributionByInjectorContract.tsx @@ -2,9 +2,8 @@ import Chart from 'react-apexcharts'; import React, { FunctionComponent } from 'react'; import { useTheme } from '@mui/styles'; import * as R from 'ramda'; -import { horizontalBarsChartOptions } from '../../../../utils/Charts'; import Empty from '../../../../components/Empty'; -import type { ExerciseStore } from '../../../../actions/exercises/Exercise'; +import { horizontalBarsChartOptions } from '../../../../utils/Charts'; import { useFormatter } from '../../../../components/i18n'; import { useAppDispatch } from '../../../../utils/hooks'; import type { Theme } from '../../../../components/Theme'; @@ -13,22 +12,8 @@ import type { InjectHelper } from '../../../../actions/injects/inject-helper'; import useDataLoader from '../../../../utils/ServerSideEvent'; import { fetchInjects } from '../../../../actions/Inject'; import { fetchExerciseInjectExpectations } from '../../../../actions/Exercise'; -import type { InjectExpectationStore } from '../../../../actions/injects/Inject'; -import type { Inject } from '../../../../utils/api-types'; -import { fetchInjectorContracts } from '../../../../actions/InjectorContracts'; -import type { InjectorContractHelper } from '../../../../actions/injector_contracts/injector-contract-helper'; -import { horizontalBarsChartOptions } from '../../../../../utils/Charts'; -import Empty from '../../../../../components/Empty'; -import type { ExerciseStore } from '../../../../../actions/exercises/Exercise'; -import { useFormatter } from '../../../../../components/i18n'; -import { useAppDispatch } from '../../../../../utils/hooks'; -import type { Theme } from '../../../../../components/Theme'; -import { useHelper } from '../../../../../store'; -import type { InjectHelper } from '../../../../../actions/injects/inject-helper'; -import useDataLoader from '../../../../../utils/ServerSideEvent'; -import { fetchInjects } from '../../../../../actions/Inject'; -import { fetchExerciseInjectExpectations } from '../../../../../actions/Exercise'; -import type { InjectExpectationStore, InjectStore } from '../../../../../actions/injects/Inject'; +import type { InjectExpectationStore, InjectStore } from '../../../../actions/injects/Inject'; +import type { ExerciseStore } from '../../../../actions/exercises/Exercise'; interface Props { exerciseId: ExerciseStore['exercise_id']; diff --git a/openbas-front/src/utils/api-types.d.ts b/openbas-front/src/utils/api-types.d.ts index 8d9b2d1e8d..c59d39c41d 100644 --- a/openbas-front/src/utils/api-types.d.ts +++ b/openbas-front/src/utils/api-types.d.ts @@ -9,6 +9,28 @@ * --------------------------------------------------------------- */ +export interface AiGenericTextInput { + ai_content: string; + ai_format?: string; + ai_tone?: string; +} + +export interface AiMessageInput { + ai_context?: string; + ai_format: string; + ai_input: string; + /** @format int32 */ + ai_paragraphs?: number; + ai_recipient?: string; + ai_sender?: string; + ai_tone?: string; +} + +export interface AiResult { + chunk_content?: string; + chunk_id?: string; +} + export interface Article { article_author?: string; article_channel?: Channel; @@ -458,9 +480,9 @@ export interface CreateUserInput { export interface DirectInjectInput { inject_content?: object; - inject_contract?: string; inject_description?: string; inject_documents?: InjectDocumentInput[]; + inject_injector_contract?: string; inject_title?: string; inject_type?: string; inject_users?: string[]; @@ -569,7 +591,7 @@ export interface Endpoint { endpoint_hostname?: string; endpoint_ips: string[]; endpoint_mac_addresses?: string[]; - endpoint_platform: "Linux" | "Windows" | "Darwin"; + endpoint_platform: "Linux" | "Windows" | "MacOS" | "Service" | "Generic" | "Internal"; updateAttributes?: object; } @@ -586,7 +608,7 @@ export interface EndpointInput { */ endpoint_ips: string[]; endpoint_mac_addresses?: string[]; - endpoint_platform: "Linux" | "Windows" | "Darwin"; + endpoint_platform: "Linux" | "Windows" | "MacOS" | "Service" | "Generic" | "Internal"; } export interface Evaluation { @@ -833,7 +855,6 @@ export interface Inject { /** @format int64 */ inject_communications_number?: number; inject_content?: object; - inject_contract?: string; inject_country?: string; /** @format date-time */ inject_created_at?: string; @@ -932,13 +953,13 @@ export interface InjectInput { inject_assets?: string[]; inject_city?: string; inject_content?: object; - inject_contract?: string; inject_country?: string; /** @format int64 */ inject_depends_duration?: number; inject_depends_from_another?: string; inject_description?: string; inject_documents?: InjectDocumentInput[]; + inject_injector_contract?: string; inject_tags?: string[]; inject_teams?: string[]; inject_title?: string; @@ -1012,12 +1033,16 @@ export interface InjectUpdateTriggerInput { } export interface Injector { + injector_category?: string; /** @format date-time */ injector_created_at?: string; injector_custom_contracts?: boolean; injector_external?: boolean; injector_id: string; injector_name: string; + injector_simulation_agent?: boolean; + injector_simulation_agent_doc?: string; + injector_simulation_agent_platforms?: string[]; injector_type: string; /** @format date-time */ injector_updated_at?: string; @@ -1045,6 +1070,7 @@ export interface InjectorContract { injector_contract_injector?: Injector; injector_contract_labels?: Record; injector_contract_manual?: boolean; + injector_contract_platforms?: string[]; /** @format date-time */ injector_contract_updated_at?: string; updateAttributes?: object; @@ -1058,6 +1084,7 @@ export interface InjectorContractAddInput { contract_id: string; contract_labels?: Record; contract_manual?: boolean; + contract_platforms?: string[]; injector_id: string; is_atomic_testing?: boolean; } @@ -1069,6 +1096,7 @@ export interface InjectorContractInput { contract_id: string; contract_labels?: Record; contract_manual?: boolean; + contract_platforms?: string[]; is_atomic_testing?: boolean; } @@ -1078,6 +1106,7 @@ export interface InjectorContractUpdateInput { contract_content: string; contract_labels?: Record; contract_manual?: boolean; + contract_platforms?: string[]; is_atomic_testing?: boolean; } @@ -1086,10 +1115,14 @@ export interface InjectorContractUpdateMappingInput { } export interface InjectorCreateInput { + injector_category?: string; injector_contracts?: InjectorContractInput[]; injector_custom_contracts?: boolean; injector_id: string; injector_name: string; + injector_simulation_agent?: boolean; + injector_simulation_agent_doc?: string; + injector_simulation_agent_platforms?: string[]; injector_type: string; } @@ -1099,9 +1132,13 @@ export interface InjectorRegistration { } export interface InjectorUpdateInput { + injector_category?: string; injector_contracts?: InjectorContractInput[]; injector_custom_contracts?: boolean; injector_name: string; + injector_simulation_agent?: boolean; + injector_simulation_agent_doc?: string; + injector_simulation_agent_platforms?: string[]; } export type JsonNode = object; @@ -1342,6 +1379,43 @@ export interface LoginUserInput { password: string; } +export interface Mitigation { + mitigation_attack_patterns?: AttackPattern[]; + /** @format date-time */ + mitigation_created_at?: string; + mitigation_description?: string; + mitigation_external_id: string; + mitigation_id: string; + mitigation_log_sources?: string[]; + mitigation_name: string; + mitigation_stix_id: string; + mitigation_threat_hunting_techniques?: string; + /** @format date-time */ + mitigation_updated_at?: string; + updateAttributes?: object; +} + +export interface MitigationCreateInput { + mitigation_attack_patterns?: string[]; + mitigation_description?: string; + mitigation_external_id: string; + mitigation_log_sources?: string[]; + mitigation_name: string; + mitigation_stix_id?: string; + mitigation_threat_hunting_techniques?: string; +} + +export interface MitigationUpdateInput { + mitigation_attack_patterns?: string[]; + mitigation_description?: string; + mitigation_external_id: string; + mitigation_name: string; +} + +export interface MitigationUpsertInput { + mitigations?: MitigationCreateInput[]; +} + export interface OAuthProvider { provider_login?: string; provider_name?: string; @@ -1556,6 +1630,25 @@ export interface PageKillChainPhase { totalPages?: number; } +export interface PageMitigation { + content?: Mitigation[]; + empty?: boolean; + first?: boolean; + last?: boolean; + /** @format int32 */ + number?: number; + /** @format int32 */ + numberOfElements?: number; + pageable?: PageableObject; + /** @format int32 */ + size?: number; + sort?: SortObject[]; + /** @format int64 */ + totalElements?: number; + /** @format int32 */ + totalPages?: number; +} + export interface PagePayload { content?: Payload[]; empty?: boolean; @@ -1575,6 +1668,25 @@ export interface PagePayload { totalPages?: number; } +export interface PageScenario { + content?: Scenario[]; + empty?: boolean; + first?: boolean; + last?: boolean; + /** @format int32 */ + number?: number; + /** @format int32 */ + numberOfElements?: number; + pageable?: PageableObject; + /** @format int32 */ + size?: number; + sort?: SortObject[]; + /** @format int64 */ + totalElements?: number; + /** @format int32 */ + totalPages?: number; +} + export interface PageTag { content?: Tag[]; empty?: boolean; @@ -1668,10 +1780,16 @@ export interface PlatformSettings { platform_saml2_providers?: OAuthProvider[]; auth_local_enable?: boolean; auth_openid_enable?: boolean; + caldera_url?: string; java_version?: string; map_tile_server_dark?: string; map_tile_server_light?: string; + platform_ai_enabled?: boolean; + platform_ai_has_token?: boolean; + platform_ai_model?: string; + platform_ai_type?: string; platform_dark_theme?: ThemeInput; + platform_enterprise_edition?: string; platform_lang?: string; platform_light_theme?: ThemeInput; platform_name?: string; @@ -1789,6 +1907,7 @@ export interface Scenario { /** @format int64 */ scenario_all_users_number?: number; scenario_articles?: Article[]; + scenario_category?: string; /** @format int64 */ scenario_communications_number?: number; /** @format date-time */ @@ -1802,6 +1921,7 @@ export interface Scenario { scenario_lessons_categories?: LessonsCategory[]; scenario_mail_from: string; scenario_mails_reply_to?: string[]; + scenario_main_focus?: string; scenario_message_footer?: string; scenario_message_header?: string; scenario_name: string; @@ -1812,6 +1932,7 @@ export interface Scenario { scenario_recurrence_end?: string; /** @format date-time */ scenario_recurrence_start?: string; + scenario_severity?: string; scenario_subtitle?: string; scenario_tags?: Tag[]; scenario_teams?: Team[]; @@ -1832,8 +1953,11 @@ export interface ScenarioInformationInput { } export interface ScenarioInput { + scenario_category?: string; scenario_description?: string; + scenario_main_focus?: string; scenario_name: string; + scenario_severity?: string; scenario_subtitle?: string; scenario_tags?: string[]; } @@ -1895,6 +2019,10 @@ export interface SearchTerm { searchTerm?: string; } +export interface SettingsEnterpriseEditionUpdateInput { + platform_enterprise_edition: string; +} + export interface SettingsUpdateInput { platform_lang: string; platform_name: string; diff --git a/openbas-model/src/main/java/io/openbas/database/model/Inject.java b/openbas-model/src/main/java/io/openbas/database/model/Inject.java index 91f370f6f7..32731a7bad 100644 --- a/openbas-model/src/main/java/io/openbas/database/model/Inject.java +++ b/openbas-model/src/main/java/io/openbas/database/model/Inject.java @@ -64,11 +64,6 @@ public class Inject implements Base, Injection { @JsonProperty("inject_description") private String description; - @Getter - @Transient - @JsonProperty("inject_injector_contract") - private InjectorContract injectorContract; - @Getter @Column(name = "inject_country") @JsonProperty("inject_country") @@ -139,10 +134,16 @@ public class Inject implements Base, Injection { @Min(value = 0L, message = "The value must be positive") private Long dependsDuration; + @Getter + @ManyToOne(fetch = FetchType.EAGER) + @JoinColumn(name = "inject_injector_contract") + @JsonProperty("inject_injector_contract") + private InjectorContract injectorContract; + @Getter @ManyToOne(fetch = FetchType.LAZY) - @JsonSerialize(using = MonoIdDeserializer.class) @JoinColumn(name = "inject_user") + @JsonSerialize(using = MonoIdDeserializer.class) @JsonProperty("inject_user") private User user; diff --git a/openbas-model/src/main/java/io/openbas/database/model/InjectorContract.java b/openbas-model/src/main/java/io/openbas/database/model/InjectorContract.java index 3776aa15ee..2437102e3f 100644 --- a/openbas-model/src/main/java/io/openbas/database/model/InjectorContract.java +++ b/openbas-model/src/main/java/io/openbas/database/model/InjectorContract.java @@ -73,7 +73,7 @@ public class InjectorContract implements Base { private Injector injector; @Setter - @ManyToMany(fetch = FetchType.LAZY) + @ManyToMany(fetch = FetchType.EAGER) @JoinTable(name = "injectors_contracts_attack_patterns", joinColumns = @JoinColumn(name = "injector_contract_id"), inverseJoinColumns = @JoinColumn(name = "attack_pattern_id")) diff --git a/openbas-model/src/main/java/io/openbas/database/model/Scenario.java b/openbas-model/src/main/java/io/openbas/database/model/Scenario.java index 5c7c7fb94d..baf6381be3 100644 --- a/openbas-model/src/main/java/io/openbas/database/model/Scenario.java +++ b/openbas-model/src/main/java/io/openbas/database/model/Scenario.java @@ -226,9 +226,8 @@ public List
getArticlesForChannel(Channel channel) { } // -- PLATFORMS -- - /* @JsonProperty("scenario_platforms") + @JsonProperty("scenario_platforms") public List getPlatforms() { - return getInjects().stream().flatMap(inject -> Arrays.stream(inject.getContractDefinition() == null ? new String[0] : inject.getContractDefinition().getPlatforms())).distinct().toList(); + return getInjects().stream().flatMap(inject -> Arrays.stream(inject.getInjectorContract().getPlatforms())).distinct().toList(); } - */ }