diff --git a/models/sanction_check.go b/models/sanction_check.go new file mode 100644 index 00000000..94b78bc0 --- /dev/null +++ b/models/sanction_check.go @@ -0,0 +1,28 @@ +package models + +type SanctionCheckQuery struct { + String string +} + +type SanctionCheckResponse struct { + Total struct { + Value int `json:"value"` + } `json:"total"` +} + +type SanctionCheckResult struct { + Hits int +} + +func (in SanctionCheckResult) process() SanctionCheckResult { + // TODO; process matches and merge them. + return in +} + +func AdaptSanctionCheckResult(resp SanctionCheckResponse) SanctionCheckResult { + result := SanctionCheckResult{ + Hits: resp.Total.Value, + } + + return result.process() +} diff --git a/repositories/eval_scenario_testrun.go b/repositories/eval_scenario_testrun.go index 008247a5..a63ec367 100644 --- a/repositories/eval_scenario_testrun.go +++ b/repositories/eval_scenario_testrun.go @@ -10,6 +10,10 @@ type EvalScenarioRepository interface { GetScenarioIteration(ctx context.Context, exec Executor, scenarioIterationId string) (models.ScenarioIteration, error) } +type EvalSanctionCheckConfigRepository interface { + GetSanctionCheckConfig(ctx context.Context, exec Executor, scenarioIterationId string) (models.SanctionCheckConfig, error) +} + type EvalTestRunScenarioRepository interface { GetTestRunIterationIdByScenarioId(ctx context.Context, exec Executor, scenarioID string) (*string, error) } diff --git a/repositories/opensanctions_repository.go b/repositories/opensanctions_repository.go new file mode 100644 index 00000000..4d71b8cf --- /dev/null +++ b/repositories/opensanctions_repository.go @@ -0,0 +1,62 @@ +package repositories + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "net/url" + + "github.com/checkmarble/marble-backend/models" + "github.com/checkmarble/marble-backend/utils" + "github.com/cockroachdb/errors" +) + +const ( + // TODO: Pull this as server configuration + DEV_YENTE_URL = "http://app.yente.orb.local" +) + +type OpenSanctionsRepository struct{} + +func (repo OpenSanctionsRepository) Search(ctx context.Context, cfg models.SanctionCheckConfig, + query models.SanctionCheckQuery, +) (models.SanctionCheckResult, error) { + req, err := repo.searchRequest(ctx, query) + if err != nil { + return models.SanctionCheckResult{}, err + } + + utils.LoggerFromContext(ctx).Debug("SANCTION CHECK: sending request...") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return models.SanctionCheckResult{}, errors.Wrap(err, "could not perform sanction check") + } + + if resp.StatusCode != http.StatusOK { + return models.SanctionCheckResult{}, fmt.Errorf( + "sanction check API returned status %d", resp.StatusCode) + } + + var sanctionCheckResp models.SanctionCheckResponse + + defer resp.Body.Close() + + if err := json.NewDecoder(resp.Body).Decode(&sanctionCheckResp); err != nil { + return models.SanctionCheckResult{}, errors.Wrap(err, + "could not parse sanction check response") + } + + return models.AdaptSanctionCheckResult(sanctionCheckResp), nil +} + +func (OpenSanctionsRepository) searchRequest(ctx context.Context, query models.SanctionCheckQuery) (*http.Request, error) { + q := url.Values{} + q.Set("q", query.String) + + url := fmt.Sprintf("%s/search/sanctions?%s", DEV_YENTE_URL, q.Encode()) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) + + return req, err +} diff --git a/repositories/sanction_check_repository.go b/repositories/sanction_check_repository.go new file mode 100644 index 00000000..8ccae1b3 --- /dev/null +++ b/repositories/sanction_check_repository.go @@ -0,0 +1,16 @@ +package repositories + +import ( + "context" + + "github.com/checkmarble/marble-backend/models" + "github.com/checkmarble/marble-backend/utils" +) + +func (*MarbleDbRepository) InsertResults(ctx context.Context, matches models.SanctionCheckResult) (models.SanctionCheckResult, error) { + utils.LoggerFromContext(ctx).Debug("SANCTION CHECK: inserting matches in database") + + return models.SanctionCheckResult{ + Hits: matches.Hits, + }, nil +} diff --git a/usecases/decision_phantom/decision_phantom.go b/usecases/decision_phantom/decision_phantom.go index 53ffe2f5..d74963bc 100644 --- a/usecases/decision_phantom/decision_phantom.go +++ b/usecases/decision_phantom/decision_phantom.go @@ -20,15 +20,16 @@ type evalScenarioRepository interface { scenarioIterationId string) (models.ScenarioIteration, error) } type PhantomDecisionUsecase struct { - enforceSecurity security.EnforceSecurityPhantomDecision - executorFactory executor_factory.ExecutorFactory - ingestedDataReadRepository repositories.IngestedDataReadRepository - repository repositories.DecisionPhantomUsecaseRepository - testrunRepository repositories.ScenarioTestRunRepository - scenarioRepository repositories.ScenarioUsecaseRepository - evaluateAstExpression ast_eval.EvaluateAstExpression - snoozesReader evaluate_scenario.SnoozesForDecisionReader - evalScenarioRepository evalScenarioRepository + enforceSecurity security.EnforceSecurityPhantomDecision + executorFactory executor_factory.ExecutorFactory + ingestedDataReadRepository repositories.IngestedDataReadRepository + repository repositories.DecisionPhantomUsecaseRepository + testrunRepository repositories.ScenarioTestRunRepository + scenarioRepository repositories.ScenarioUsecaseRepository + evaluateAstExpression ast_eval.EvaluateAstExpression + snoozesReader evaluate_scenario.SnoozesForDecisionReader + evalScenarioRepository evalScenarioRepository + evalSanctionCheckConfigRepository repositories.EvalSanctionCheckConfigRepository } func NewPhantomDecisionUseCase(enforceSecurity security.EnforceSecurityPhantomDecision, @@ -38,17 +39,19 @@ func NewPhantomDecisionUseCase(enforceSecurity security.EnforceSecurityPhantomDe testrunRepository repositories.ScenarioTestRunRepository, scenarioRepository repositories.ScenarioUsecaseRepository, evalScenarioRepository evalScenarioRepository, + evalSanctionCheckConfigRepository repositories.EvalSanctionCheckConfigRepository, ) PhantomDecisionUsecase { return PhantomDecisionUsecase{ - enforceSecurity: enforceSecurity, - executorFactory: executorFactory, - ingestedDataReadRepository: ingestedDataReadRepository, - repository: repository, - scenarioRepository: scenarioRepository, - evaluateAstExpression: evaluateAstExpression, - testrunRepository: testrunRepository, - snoozesReader: snoozesReader, - evalScenarioRepository: evalScenarioRepository, + enforceSecurity: enforceSecurity, + executorFactory: executorFactory, + ingestedDataReadRepository: ingestedDataReadRepository, + repository: repository, + scenarioRepository: scenarioRepository, + evaluateAstExpression: evaluateAstExpression, + testrunRepository: testrunRepository, + snoozesReader: snoozesReader, + evalScenarioRepository: evalScenarioRepository, + evalSanctionCheckConfigRepository: evalSanctionCheckConfigRepository, } } @@ -66,14 +69,15 @@ func (usecase *PhantomDecisionUsecase) CreatePhantomDecision(ctx context.Context return models.PhantomDecision{}, err } evaluationRepositories := evaluate_scenario.ScenarioEvaluationRepositories{ - EvalScenarioRepository: usecase.evalScenarioRepository, - EvalTestRunScenarioRepository: usecase.repository, - ScenarioTestRunRepository: usecase.testrunRepository, - ExecutorFactory: usecase.executorFactory, - IngestedDataReadRepository: usecase.ingestedDataReadRepository, - EvaluateAstExpression: usecase.evaluateAstExpression, - ScenarioRepository: usecase.scenarioRepository, - SnoozeReader: usecase.snoozesReader, + EvalScenarioRepository: usecase.evalScenarioRepository, + EvalSanctionCheckConfigRepository: usecase.evalSanctionCheckConfigRepository, + EvalTestRunScenarioRepository: usecase.repository, + ScenarioTestRunRepository: usecase.testrunRepository, + ExecutorFactory: usecase.executorFactory, + IngestedDataReadRepository: usecase.ingestedDataReadRepository, + EvaluateAstExpression: usecase.evaluateAstExpression, + ScenarioRepository: usecase.scenarioRepository, + SnoozeReader: usecase.snoozesReader, } // TODO remove diff --git a/usecases/decision_usecase.go b/usecases/decision_usecase.go index 75df7082..55f2e47c 100644 --- a/usecases/decision_usecase.go +++ b/usecases/decision_usecase.go @@ -98,19 +98,21 @@ type snoozesForDecisionReader interface { } type DecisionUsecase struct { - enforceSecurity security.EnforceSecurityDecision - enforceSecurityScenario security.EnforceSecurityScenario - transactionFactory executor_factory.TransactionFactory - executorFactory executor_factory.ExecutorFactory - ingestedDataReadRepository repositories.IngestedDataReadRepository - dataModelRepository repositories.DataModelRepository - repository DecisionUsecaseRepository - scenarioTestRunRepository repositories.ScenarioTestRunRepository - evaluateAstExpression ast_eval.EvaluateAstExpression - decisionWorkflows decisionWorkflowsUsecase - webhookEventsSender webhookEventsUsecase - phantomUseCase decision_phantom.PhantomDecisionUsecase - snoozesReader snoozesForDecisionReader + enforceSecurity security.EnforceSecurityDecision + enforceSecurityScenario security.EnforceSecurityScenario + transactionFactory executor_factory.TransactionFactory + executorFactory executor_factory.ExecutorFactory + ingestedDataReadRepository repositories.IngestedDataReadRepository + dataModelRepository repositories.DataModelRepository + repository DecisionUsecaseRepository + sanctionCheckConfigRepository repositories.EvalSanctionCheckConfigRepository + sanctionCheckUsecase SanctionCheckUsecase + scenarioTestRunRepository repositories.ScenarioTestRunRepository + evaluateAstExpression ast_eval.EvaluateAstExpression + decisionWorkflows decisionWorkflowsUsecase + webhookEventsSender webhookEventsUsecase + phantomUseCase decision_phantom.PhantomDecisionUsecase + snoozesReader snoozesForDecisionReader } func (usecase *DecisionUsecase) GetDecision(ctx context.Context, decisionId string) (models.DecisionWithRuleExecutions, error) { @@ -400,11 +402,13 @@ func (usecase *DecisionUsecase) CreateDecision( } evaluationRepositories := evaluate_scenario.ScenarioEvaluationRepositories{ - EvalScenarioRepository: usecase.repository, - ExecutorFactory: usecase.executorFactory, - IngestedDataReadRepository: usecase.ingestedDataReadRepository, - EvaluateAstExpression: usecase.evaluateAstExpression, - SnoozeReader: usecase.snoozesReader, + EvalScenarioRepository: usecase.repository, + EvalSanctionCheckConfigRepository: usecase.sanctionCheckConfigRepository, + EvalSanctionCheckUsecase: usecase.sanctionCheckUsecase, + ExecutorFactory: usecase.executorFactory, + IngestedDataReadRepository: usecase.ingestedDataReadRepository, + EvaluateAstExpression: usecase.evaluateAstExpression, + SnoozeReader: usecase.snoozesReader, } scenarioExecution, err := evaluate_scenario.EvalScenario(ctx, evaluationParameters, evaluationRepositories) @@ -553,11 +557,12 @@ func (usecase *DecisionUsecase) CreateAllDecisions( } evaluationRepositories := evaluate_scenario.ScenarioEvaluationRepositories{ - EvalScenarioRepository: usecase.repository, - ExecutorFactory: usecase.executorFactory, - IngestedDataReadRepository: usecase.ingestedDataReadRepository, - EvaluateAstExpression: usecase.evaluateAstExpression, - SnoozeReader: usecase.snoozesReader, + EvalScenarioRepository: usecase.repository, + EvalSanctionCheckConfigRepository: usecase.sanctionCheckConfigRepository, + ExecutorFactory: usecase.executorFactory, + IngestedDataReadRepository: usecase.ingestedDataReadRepository, + EvaluateAstExpression: usecase.evaluateAstExpression, + SnoozeReader: usecase.snoozesReader, } type decisionAndScenario struct { diff --git a/usecases/evaluate_scenario/evaluate_scenario.go b/usecases/evaluate_scenario/evaluate_scenario.go index 4a671040..c4550dab 100644 --- a/usecases/evaluate_scenario/evaluate_scenario.go +++ b/usecases/evaluate_scenario/evaluate_scenario.go @@ -32,6 +32,10 @@ type ScenarioEvaluationParameters struct { Pivot *models.Pivot } +type EvalSanctionCheckUsecase interface { + Execute(context.Context, models.SanctionCheckConfig, models.SanctionCheckQuery) (models.SanctionCheckResult, error) +} + type SnoozesForDecisionReader interface { ListActiveRuleSnoozesForDecision( ctx context.Context, @@ -42,14 +46,16 @@ type SnoozesForDecisionReader interface { } type ScenarioEvaluationRepositories struct { - EvalScenarioRepository repositories.EvalScenarioRepository - EvalTestRunScenarioRepository repositories.EvalTestRunScenarioRepository - ScenarioTestRunRepository repositories.ScenarioTestRunRepository - ScenarioRepository repositories.ScenarioUsecaseRepository - ExecutorFactory executor_factory.ExecutorFactory - IngestedDataReadRepository repositories.IngestedDataReadRepository - EvaluateAstExpression ast_eval.EvaluateAstExpression - SnoozeReader SnoozesForDecisionReader + EvalScenarioRepository repositories.EvalScenarioRepository + EvalSanctionCheckConfigRepository repositories.EvalSanctionCheckConfigRepository + EvalSanctionCheckUsecase EvalSanctionCheckUsecase + EvalTestRunScenarioRepository repositories.EvalTestRunScenarioRepository + ScenarioTestRunRepository repositories.ScenarioTestRunRepository + ScenarioRepository repositories.ScenarioUsecaseRepository + ExecutorFactory executor_factory.ExecutorFactory + IngestedDataReadRepository repositories.IngestedDataReadRepository + EvaluateAstExpression ast_eval.EvaluateAstExpression + SnoozeReader SnoozesForDecisionReader } func processScenarioIteration(ctx context.Context, params ScenarioEvaluationParameters, @@ -121,6 +127,16 @@ func processScenarioIteration(ctx context.Context, params ScenarioEvaluationPara "error during concurrent rule evaluation") } + if iteration.SanctionCheckConfig != nil { + result, err := repositories.EvalSanctionCheckUsecase.Execute(ctx, + *iteration.SanctionCheckConfig, models.SanctionCheckQuery{String: "obama"}) + if err != nil { + return models.ScenarioExecution{}, errors.Wrap(err, "could not perform sanction check") + } + + logger.Debug("SANCTION CHECK: found", "matches", result.Hits) + } + // Compute outcome from score var outcome models.Outcome @@ -217,6 +233,16 @@ func EvalTestRunScenario(ctx context.Context, return models.ScenarioExecution{}, err } + scc, err := repositories.EvalSanctionCheckConfigRepository.GetSanctionCheckConfig(ctx, exec, testRunIteration.Id) + + switch { + case err == nil: + testRunIteration.SanctionCheckConfig = &scc + case !errors.Is(err, models.NotFoundError): + return models.ScenarioExecution{}, errors.Wrap(err, + "error getting sanction check config from scenario iteration") + } + se, err = processScenarioIteration(ctx, params, testRunIteration, repositories, start, logger, exec) if err != nil { return models.ScenarioExecution{}, err @@ -277,6 +303,16 @@ func EvalScenario( "error getting scenario iteration in EvalScenario") } + scc, err := repositories.EvalSanctionCheckConfigRepository.GetSanctionCheckConfig(ctx, exec, versionToRun.Id) + + switch { + case err == nil: + versionToRun.SanctionCheckConfig = &scc + case !errors.Is(err, models.NotFoundError): + return models.ScenarioExecution{}, errors.Wrap(err, + "error getting sanction check config from scenario iteration") + } + se, errSe := processScenarioIteration(ctx, params, versionToRun, repositories, start, logger, exec) if errSe != nil { return models.ScenarioExecution{}, errors.Wrap(errSe, diff --git a/usecases/sanction_check_usecase.go b/usecases/sanction_check_usecase.go new file mode 100644 index 00000000..9c3aad03 --- /dev/null +++ b/usecases/sanction_check_usecase.go @@ -0,0 +1,33 @@ +package usecases + +import ( + "context" + + "github.com/checkmarble/marble-backend/models" +) + +type SanctionCheckProvider interface { + Search(context.Context, models.SanctionCheckConfig, models.SanctionCheckQuery) (models.SanctionCheckResult, error) +} + +type SanctionCheckRepository interface { + InsertResults(context.Context, models.SanctionCheckResult) (models.SanctionCheckResult, error) +} + +type SanctionCheckUsecase struct { + openSanctionsProvider SanctionCheckProvider + repository SanctionCheckRepository +} + +func (uc SanctionCheckUsecase) Execute(ctx context.Context, cfg models.SanctionCheckConfig, + query models.SanctionCheckQuery, +) (models.SanctionCheckResult, error) { + matches, err := uc.openSanctionsProvider.Search(ctx, cfg, query) + if err != nil { + return models.SanctionCheckResult{}, err + } + + result, err := uc.repository.InsertResults(ctx, matches) + + return result, err +} diff --git a/usecases/scenario_iterations_usecase.go b/usecases/scenario_iterations_usecase.go index 0a40b528..f3030e9c 100644 --- a/usecases/scenario_iterations_usecase.go +++ b/usecases/scenario_iterations_usecase.go @@ -223,6 +223,17 @@ func (usecase *ScenarioIterationUsecase) CreateDraftFromScenarioIteration( if err != nil { return models.ScenarioIteration{}, err } + + var sanctionCheckConfig *models.SanctionCheckConfig + + switch scc, err := usecase.sanctionCheckConfigRepository.GetSanctionCheckConfig(ctx, tx, si.Id); { + case err == nil: + sanctionCheckConfig = &scc + case !errors.Is(err, models.NotFoundError): + return models.ScenarioIteration{}, errors.Wrap(err, + "could not retrieve sanction check config while creating draft") + } + iterations, err := usecase.repository.ListScenarioIterations( ctx, tx, @@ -284,7 +295,19 @@ func (usecase *ScenarioIterationUsecase) CreateDraftFromScenarioIteration( return models.ScenarioIteration{}, err } } - return usecase.repository.CreateScenarioIterationAndRules(ctx, tx, organizationId, createScenarioIterationInput) + + newScenarioIteration, err := usecase.repository.CreateScenarioIterationAndRules( + ctx, tx, organizationId, createScenarioIterationInput) + + if sanctionCheckConfig != nil { + if _, err := usecase.sanctionCheckConfigRepository.UpdateSanctionCheckConfig(ctx, tx, + newScenarioIteration.Id, *sanctionCheckConfig); err != nil { + return models.ScenarioIteration{}, errors.Wrap(err, + "could not duplicate sanction check config for new iteration") + } + } + + return newScenarioIteration, err }) if err != nil { return models.ScenarioIteration{}, err diff --git a/usecases/scheduled_execution/async_decision_job.go b/usecases/scheduled_execution/async_decision_job.go index dede2c24..00a8b0ec 100644 --- a/usecases/scheduled_execution/async_decision_job.go +++ b/usecases/scheduled_execution/async_decision_job.go @@ -103,6 +103,7 @@ type AsyncDecisionWorker struct { snoozesReader snoozesForDecisionReader phantomDecision decision_phantom.PhantomDecisionUsecase scenarioFetcher scenarios.ScenarioFetcher + sanctionCheckConfigRepository repositories.EvalSanctionCheckConfigRepository } func NewAsyncDecisionWorker( @@ -118,6 +119,7 @@ func NewAsyncDecisionWorker( webhookEventsSender webhookEventsUsecase, snoozesReader snoozesForDecisionReader, scenarioFetcher scenarios.ScenarioFetcher, + sanctionCheckConfigRepository repositories.EvalSanctionCheckConfigRepository, phantom decision_phantom.PhantomDecisionUsecase, ) AsyncDecisionWorker { return AsyncDecisionWorker{ @@ -133,6 +135,7 @@ func NewAsyncDecisionWorker( webhookEventsSender: webhookEventsSender, snoozesReader: snoozesReader, scenarioFetcher: scenarioFetcher, + sanctionCheckConfigRepository: sanctionCheckConfigRepository, phantomDecision: phantom, } } @@ -286,11 +289,12 @@ func (w *AsyncDecisionWorker) createSingleDecisionForObjectId( } evaluationRepositories := evaluate_scenario.ScenarioEvaluationRepositories{ - EvalScenarioRepository: w.repository, - ExecutorFactory: w.executorFactory, - IngestedDataReadRepository: w.ingestedDataReadRepository, - EvaluateAstExpression: w.evaluateAstExpression, - SnoozeReader: w.snoozesReader, + EvalScenarioRepository: w.repository, + EvalSanctionCheckConfigRepository: w.sanctionCheckConfigRepository, + ExecutorFactory: w.executorFactory, + IngestedDataReadRepository: w.ingestedDataReadRepository, + EvaluateAstExpression: w.evaluateAstExpression, + SnoozeReader: w.snoozesReader, } scenarioExecution, err := evaluate_scenario.EvalScenario( diff --git a/usecases/scheduled_execution/async_scheduled_exec_status_job.go b/usecases/scheduled_execution/async_scheduled_exec_status_job.go index 6bd29780..d2b81f18 100644 --- a/usecases/scheduled_execution/async_scheduled_exec_status_job.go +++ b/usecases/scheduled_execution/async_scheduled_exec_status_job.go @@ -39,6 +39,7 @@ type AsyncScheduledExecWorker struct { webhookEventsSender webhookEventsUsecase snoozesReader snoozesForDecisionReader scenarioFetcher scenarios.ScenarioFetcher + sanctionCheckConfigRepository repositories.EvalSanctionCheckConfigRepository } func NewAsyncScheduledExecWorker( @@ -53,6 +54,7 @@ func NewAsyncScheduledExecWorker( webhookEventsSender webhookEventsUsecase, snoozesReader snoozesForDecisionReader, scenarioFetcher scenarios.ScenarioFetcher, + sanctionCheckConfigRepository repositories.EvalSanctionCheckConfigRepository, ) AsyncScheduledExecWorker { return AsyncScheduledExecWorker{ repository: repository, @@ -66,6 +68,7 @@ func NewAsyncScheduledExecWorker( webhookEventsSender: webhookEventsSender, snoozesReader: snoozesReader, scenarioFetcher: scenarioFetcher, + sanctionCheckConfigRepository: sanctionCheckConfigRepository, } } diff --git a/usecases/usecases_with_creds.go b/usecases/usecases_with_creds.go index a6a5880b..d9ac72b5 100644 --- a/usecases/usecases_with_creds.go +++ b/usecases/usecases_with_creds.go @@ -2,6 +2,7 @@ package usecases import ( "github.com/checkmarble/marble-backend/models" + "github.com/checkmarble/marble-backend/repositories" "github.com/checkmarble/marble-backend/usecases/decision_phantom" "github.com/checkmarble/marble-backend/usecases/decision_workflows" "github.com/checkmarble/marble-backend/usecases/inboxes" @@ -93,27 +94,37 @@ func (usecases *UsecasesWithCreds) NewEnforceTagSecurity() security.EnforceSecur func (usecases *UsecasesWithCreds) NewDecisionUsecase() DecisionUsecase { return DecisionUsecase{ - enforceSecurity: usecases.NewEnforceDecisionSecurity(), - enforceSecurityScenario: usecases.NewEnforceScenarioSecurity(), - executorFactory: usecases.NewExecutorFactory(), - transactionFactory: usecases.NewTransactionFactory(), - ingestedDataReadRepository: usecases.Repositories.IngestedDataReadRepository, - dataModelRepository: usecases.Repositories.DataModelRepository, - repository: &usecases.Repositories.MarbleDbRepository, - evaluateAstExpression: usecases.NewEvaluateAstExpression(), - decisionWorkflows: usecases.NewDecisionWorkflows(), - webhookEventsSender: usecases.NewWebhookEventsUsecase(), - snoozesReader: &usecases.Repositories.MarbleDbRepository, + enforceSecurity: usecases.NewEnforceDecisionSecurity(), + enforceSecurityScenario: usecases.NewEnforceScenarioSecurity(), + executorFactory: usecases.NewExecutorFactory(), + transactionFactory: usecases.NewTransactionFactory(), + ingestedDataReadRepository: usecases.Repositories.IngestedDataReadRepository, + dataModelRepository: usecases.Repositories.DataModelRepository, + repository: &usecases.Repositories.MarbleDbRepository, + sanctionCheckConfigRepository: &usecases.Repositories.MarbleDbRepository, + sanctionCheckUsecase: usecases.NewSanctionCheckUsecase(), + evaluateAstExpression: usecases.NewEvaluateAstExpression(), + decisionWorkflows: usecases.NewDecisionWorkflows(), + webhookEventsSender: usecases.NewWebhookEventsUsecase(), + snoozesReader: &usecases.Repositories.MarbleDbRepository, phantomUseCase: decision_phantom.NewPhantomDecisionUseCase( usecases.NewEnforcePhantomDecisionSecurity(), usecases.NewExecutorFactory(), usecases.Repositories.IngestedDataReadRepository, &usecases.Repositories.MarbleDbRepository, usecases.NewEvaluateAstExpression(), &usecases.Repositories.MarbleDbRepository, &usecases.Repositories.MarbleDbRepository, - &usecases.Repositories.MarbleDbRepository, &usecases.Repositories.MarbleDbRepository), + &usecases.Repositories.MarbleDbRepository, &usecases.Repositories.MarbleDbRepository, + &usecases.Repositories.MarbleDbRepository), scenarioTestRunRepository: &usecases.Repositories.MarbleDbRepository, } } +func (usecases *UsecasesWithCreds) NewSanctionCheckUsecase() SanctionCheckUsecase { + return SanctionCheckUsecase{ + openSanctionsProvider: repositories.OpenSanctionsRepository{}, + repository: &usecases.Repositories.MarbleDbRepository, + } +} + func (usecases *UsecasesWithCreds) NewDecisionWorkflows() decision_workflows.DecisionsWorkflows { return decision_workflows.NewDecisionWorkflows( usecases.NewCaseUseCase(), @@ -455,12 +466,14 @@ func (usecases UsecasesWithCreds) NewAsyncDecisionWorker() *scheduled_execution. usecases.NewWebhookEventsUsecase(), &usecases.Repositories.MarbleDbRepository, usecases.NewScenarioFetcher(), + &usecases.Repositories.MarbleDbRepository, decision_phantom.NewPhantomDecisionUseCase( usecases.NewEnforcePhantomDecisionSecurity(), usecases.NewExecutorFactory(), usecases.Repositories.IngestedDataReadRepository, &usecases.Repositories.MarbleDbRepository, usecases.NewEvaluateAstExpression(), &usecases.Repositories.MarbleDbRepository, &usecases.Repositories.MarbleDbRepository, - &usecases.Repositories.MarbleDbRepository, &usecases.Repositories.MarbleDbRepository), + &usecases.Repositories.MarbleDbRepository, &usecases.Repositories.MarbleDbRepository, + &usecases.Repositories.MarbleDbRepository), ) return &w } @@ -478,6 +491,7 @@ func (usecases UsecasesWithCreds) NewNewAsyncScheduledExecWorker() *scheduled_ex usecases.NewWebhookEventsUsecase(), &usecases.Repositories.MarbleDbRepository, usecases.NewScenarioFetcher(), + &usecases.Repositories.MarbleDbRepository, ) return &w }