Skip to content

Commit

Permalink
[backend/frontend] Use ID instead of label when resolving expectation…
Browse files Browse the repository at this point in the history
… from OpenBAS
  • Loading branch information
RomuDeuxfois committed Oct 3, 2024
1 parent c1def1b commit c60f1b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
3 changes: 1 addition & 2 deletions opencti-platform/opencti-front/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ const depsToOptimize = [
"@mui/lab/LoadingButton",
"@mui/material/Breadcrumbs",
"classnames",
"react-draggable",
"react-beautiful-dnd"
"react-draggable"
]

const logger = createLogger()
Expand Down
18 changes: 9 additions & 9 deletions opencti-platform/opencti-graphql/src/database/xtm-obas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,29 +185,29 @@ export const getScenarioResult = async (id: string) => {
success: 0,
failure: 0
} : {
unknown: prevention.distribution?.filter((n: { label: string, value: number }) => n.label === 'Pending').at(0).value,
success: prevention.distribution?.filter((n: { label: string, value: number }) => n.label === 'Successful').at(0).value,
failure: prevention.distribution?.filter((n: { label: string, value: number }) => n.label === 'Failed').at(0).value
unknown: prevention.distribution?.filter((n: { id: string, value: number }) => n.id === 'PENDING').at(0)?.value,
success: prevention.distribution?.filter((n: { id: string, value: number }) => n.id === 'SUCCESS').at(0)?.value,
failure: prevention.distribution?.filter((n: { id: string, value: number }) => n.id === 'FAILED').at(0)?.value

Check warning on line 190 in opencti-platform/opencti-graphql/src/database/xtm-obas.ts

View check run for this annotation

Codecov / codecov/patch

opencti-platform/opencti-graphql/src/database/xtm-obas.ts#L188-L190

Added lines #L188 - L190 were not covered by tests
};
const detection = exercise.exercise_global_score.filter((n: { type: string, value: number }) => n.type === 'DETECTION').at(0);
const detectionResult = detection.avgResult === 'UNKNOWN' ? {
unknown: 1,
success: 0,
failure: 0
} : {
unknown: detection.distribution?.filter((n: { label: string, value: number }) => n.label === 'Pending').at(0).value,
success: detection.distribution?.filter((n: { label: string, value: number }) => n.label === 'Successful').at(0).value,
failure: detection.distribution?.filter((n: { label: string, value: number }) => n.label === 'Failed').at(0).value
unknown: detection.distribution?.filter((n: { id: string, value: number }) => n.id === 'PENDING').at(0)?.value,
success: detection.distribution?.filter((n: { id: string, value: number }) => n.id === 'SUCCESS').at(0)?.value,
failure: detection.distribution?.filter((n: { id: string, value: number }) => n.id === 'FAILED').at(0)?.value

Check warning on line 200 in opencti-platform/opencti-graphql/src/database/xtm-obas.ts

View check run for this annotation

Codecov / codecov/patch

opencti-platform/opencti-graphql/src/database/xtm-obas.ts#L198-L200

Added lines #L198 - L200 were not covered by tests
};
const humanResponse = exercise.exercise_global_score.filter((n: { type: string, value: number }) => n.type === 'HUMAN_RESPONSE').at(0);
const humanResponseResult = humanResponse.avgResult === 'UNKNOWN' ? {
unknown: 1,
success: 0,
failure: 0
} : {
unknown: humanResponse.distribution?.filter((n: { label: string, value: number }) => n.label === 'Pending').at(0).value,
success: humanResponse.distribution?.filter((n: { label: string, value: number }) => n.label === 'Successful').at(0).value,
failure: humanResponse.distribution?.filter((n: { label: string, value: number }) => n.label === 'Failed').at(0).value
unknown: humanResponse.distribution?.filter((n: { id: string, value: number }) => n.id === 'PENDING').at(0)?.value,
success: humanResponse.distribution?.filter((n: { id: string, value: number }) => n.id === 'SUCCESS').at(0)?.value,
failure: humanResponse.distribution?.filter((n: { id: string, value: number }) => n.id === 'FAILED').at(0)?.value

Check warning on line 210 in opencti-platform/opencti-graphql/src/database/xtm-obas.ts

View check run for this annotation

Codecov / codecov/patch

opencti-platform/opencti-graphql/src/database/xtm-obas.ts#L208-L210

Added lines #L208 - L210 were not covered by tests
};
return {
prevention: preventionResult,
Expand Down

0 comments on commit c60f1b3

Please sign in to comment.