Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanction check base #803

Open
wants to merge 49 commits into
base: main
Choose a base branch
from
Open

Sanction check base #803

wants to merge 49 commits into from

Conversation

apognu
Copy link

@apognu apognu commented Jan 16, 2025

No description provided.

@apognu apognu self-assigned this Jan 16, 2025
@apognu apognu marked this pull request as draft January 16, 2025 15:25
@apognu apognu force-pushed the feat/sanctions-in-iterations branch 4 times, most recently from 84797bb to 1177382 Compare January 17, 2025 10:41
@apognu apognu force-pushed the feat/sanctions-in-iterations branch 4 times, most recently from 862e4eb to b121202 Compare January 27, 2025 14:15
@apognu apognu removed their assignment Jan 27, 2025
@apognu apognu added WIP go Pull requests that update Go code labels Jan 27, 2025
@Pascal-Delange Pascal-Delange force-pushed the feat/sanctions-in-iterations branch from b121202 to 04f6206 Compare January 27, 2025 21:01
Copy link
Contributor

@Pascal-Delange Pascal-Delange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks !
It's a bit massive so I didn't read every line in depth, I don't think I have major comments so far (a few minor comments in the PR body)
We can continue with this as a feature branch or merge it and take it up from there, I don't have a strong opinion on either solution really

"github.com/cockroachdb/errors"
)

func (repo *MarbleDbRepository) GetSanctionCheckConfig(ctx context.Context, exec Executor,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: since the model of scenario iterations contains a *SanctionCheckConfig, and we get the sanction check config by scenario iteration id, are we perhaps better served with a repo method that returns a *SanctionCheckConfig (or a []SanctionCheckConfig) rather than a SanctionCheckConfig with need to check on the error type for "not found" ?

repositories/sanction_check_repository.go Outdated Show resolved Hide resolved
errors.Wrap(models.NotFoundError, "this sanction is not pending review")
}

inboxes, err := uc.inboxRepository.ListInboxes(ctx, uc.executorFactory.NewExecutor(), decision[0].OrganizationId, nil, false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have a look at (i *InboxReader) ListInboxes(...), maybe we can reuse that here (the permission logic for "do I have access to this inbox" should already been handled in it)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean we can remove the check below this line (ReadOrUpdateCase) because the call to ListInboxes will already check if the user has access to the inbox, and that is the only permission we are interested in here (if someone has access to an inbox, does that mean they are allowed to update the cases in that inbox?)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that is the idea.
Also permissions are a bit more complex on cases/inboxes than on other entities in the app because there is a concept of membership in inboxes (with inbox user roles). This logic is already present in the InboxReader class (and it's one of the more unit-tested parts of the codebase).
I'll propose a change in a PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually sorry, my answer was a bit off. Using it will not allow to remove any lines of code that you already wrote - however it will avoid us having to add some more to take into account inbox permissions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=> #810

@@ -217,6 +247,16 @@ func EvalTestRunScenario(ctx context.Context,
return models.ScenarioExecution{}, err
}

scc, err := repositories.EvalSanctionCheckConfigRepository.GetSanctionCheckConfig(ctx, exec, testRunIteration.Id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note for later: we said that we perhaps don't want to call the opensanctions api again in the context of a test run (to check with arnaud)

@apognu apognu changed the title WIP: sanction check configuration and execution Sanction check base Jan 29, 2025
@apognu apognu force-pushed the feat/sanctions-in-iterations branch from b4f4779 to 89d35fb Compare January 29, 2025 09:11
@apognu apognu marked this pull request as ready for review January 30, 2025 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code WIP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants