OpenBAS-Platform / openbas

Open Breach and Attack Simulation Platform
https://openbas.io
Other
208 stars 23 forks source link

[Frontend][Backend] duplicate an exercise #1159

Open Christian-DONGMO opened 1 week ago

Christian-DONGMO commented 1 week ago

Proposed changes

Related issues

Checklist

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

Dimfacion commented 1 week ago

After I duplicate a scenario, if I try to navigate to a linked simulation, I get Internal Server Error. If I try to update one of it's injects, I'm also having Internal Server Error.

I'm also unsure simulations should be duplicated too. Edit : After checking with @jborozco, simulations of a scenario should not be duplicated.

Dimfacion commented 6 days ago

If I duplicate the duplicate of a scenario, I get a Internal Server Error. I can see in the backend console log : "duplicate key value violates unique constraint "scenario_exercise_pkey"". I also still have linked from a scenarios to a simulation. I think those two issues are linked as you should get an empty list of simulations in a freshly created duplicate. I'm also having Internal Server Error when I try to duplicate an inject of a scenario.

codecov[bot] commented 3 days ago

Codecov Report

Attention: Patch coverage is 8.09568% with 999 lines in your changes missing coverage. Please review.

Project coverage is 25.00%. Comparing base (ae49c2c) to head (7048e9f).

Files Patch % Lines
...ain/java/io/openbas/rest/exercise/ExerciseApi.java 0.25% 387 Missing :warning:
.../main/java/io/openbas/service/ScenarioService.java 20.74% 210 Missing and 4 partials :warning:
.../java/io/openbas/service/AtomicTestingService.java 0.00% 213 Missing :warning:
...java/io/openbas/rest/exercise/ExerciseService.java 0.00% 124 Missing :warning:
...as/rest/inject/service/InjectDuplicateService.java 2.63% 37 Missing :warning:
...ain/java/io/openbas/rest/scenario/ScenarioApi.java 63.63% 15 Missing and 1 partial :warning:
.../openbas/rest/atomic_testing/AtomicTestingApi.java 0.00% 5 Missing :warning:
...rc/main/java/io/openbas/rest/inject/InjectApi.java 33.33% 2 Missing :warning:
...-api/src/main/java/io/openbas/utils/Constants.java 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1159 +/- ## ============================================ - Coverage 25.65% 25.00% -0.65% + Complexity 1079 1058 -21 ============================================ Files 486 488 +2 Lines 11924 12061 +137 Branches 647 653 +6 ============================================ - Hits 3059 3016 -43 - Misses 8775 8954 +179 - Partials 90 91 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Dimfacion commented 2 days ago

@Christian-DONGMO I still have an Internal Server Error if I duplicate the duplicate of a scenario. When looking at the console logs, I have the following : org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "scenario_exercise_pkey" Besides, when duplicating a scenario, the simulations list of that scenario is also duplicated when it should not be.

I think if you don't duplicate the simulations linked to a scenario, given the error in the console logs, that should get rid of the Internal Server Error as well.

savacano28 commented 1 day ago

@Christian-DONGMO : clean dbb, and new scenarios, new injects

Cas 1: Create scenario (add teams, add injects)->duplicate inject: Error image

Cas 2: Create scenario (setup all) -> duplicate scenario: Error, the duplicated has an schedule time setted, is it normal? Documents on injects are not duplicated. image

Cas 3: Create scenario (setup all) -> duplicated scenario 2eme fois: Error image image

Cas 4: Create scenario (setup all) -> duplicated scenario from a duplicated: Error image

Cas 5: Create Scenario (setup all) -> duplicate inject in inject results ( I m not sure if on this part we could duplicate?): OK duplicated inject but status is no the same (draft vs finish) image image

Cas 6: Create scenario(setup all) -> If you click an exercise and duplicate this exercise, should this replace the others? image

Cas 7: Create scenario (setup all) -> injects duplicated of a duplicated scenario has teams, assets, asset groups are doubles (?) image