-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[backend] Change external reference resolution for OpenCTI integration (
- Loading branch information
1 parent
af85fe3
commit 4d9272e
Showing
5 changed files
with
99 additions
and
59 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
openbas-api/src/main/java/io/openbas/opencti/OpenCTIApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.openbas.opencti; | ||
|
||
import io.openbas.database.model.Exercise; | ||
import io.openbas.rest.exercise.form.ExerciseSimple; | ||
import io.openbas.service.ScenarioService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import jakarta.validation.constraints.NotBlank; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.security.access.annotation.Secured; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import static io.openbas.database.model.User.ROLE_USER; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
@Secured(ROLE_USER) | ||
public class OpenCTIApi { | ||
|
||
public static final String OPENCTI_URI = "/api/opencti/v1"; | ||
|
||
private final ScenarioService scenarioService; | ||
|
||
@Operation(summary = "Retrieve the latest exercise by external reference ID (example: a report ID") | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "Found the exercise", | ||
content = { | ||
@Content(mediaType = "application/json", schema = @Schema(implementation = ExerciseSimple.class)) | ||
}), | ||
@ApiResponse(responseCode = "404", description = "Exercise not found", content = @Content) | ||
}) | ||
@GetMapping(OPENCTI_URI + "/exercises/latest/{externalReferenceId}") | ||
public ExerciseSimple latestExerciseByExternalReference(@PathVariable @NotBlank final String externalReferenceId) { | ||
Exercise exercise = this.scenarioService.latestExerciseByExternalReference(externalReferenceId); | ||
return ExerciseSimple.fromExercise(exercise); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters