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

ROX-18155: pg generic store: Exists #6766

Merged

Conversation

janisz
Copy link
Contributor

@janisz janisz commented Jun 30, 2023

Description

A detailed explanation of the changes in your PR.

Feel free to remove this section if it is overkill for your PR, and the title of your PR is sufficiently descriptive.

Checklist

  • Investigated and inspected CI test results
  • Unit test and regression tests added
  • Evaluated and added CHANGELOG entry if required
  • Determined and documented upgrade steps
  • Documented user facing changes (create PR based on openshift/openshift-docs and merge into rhacs-docs)

If any of these don't apply, please comment below.

Testing Performed

TODO(replace-me)
Use this space to explain how you tested your PR, or, if you didn't test it, why
you did not do so. Valid reasons include, for example, "CI is sufficient",
"No testable changes". Feel free to attach JSON snippets, curl commands,
screenshots.

In addition to reviewing your code, reviewers must also review your testing
instructions and make sure they are sufficient.

@janisz janisz requested review from a team as code owners June 30, 2023 16:18
@roxbot
Copy link
Contributor

roxbot commented Jun 30, 2023

Images are ready for the commit at 6bddaf3.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.1.x-286-g6bddaf35c4.

@janisz janisz mentioned this pull request Jun 30, 2023
5 tasks
Copy link
Contributor

@rhybrillou rhybrillou left a comment

Choose a reason for hiding this comment

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

In the case the permission checker denies access to the object, I think a behaviour change is introduced that leaks information about the user allowed scope. I'd rather stick to the old behaviour.

pkg/search/postgres/store.go Show resolved Hide resolved
setPostgresOperationDurationTime durationTimeSetter
setAcquireDBConnDuration durationTimeSetter
permissionChecker PermissionChecker
pkGetter primaryKeyGetter[T, PT]
Copy link
Contributor

Choose a reason for hiding this comment

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

super-nit: field order -> move targetResource and permissionChecker to the end of the list (makes it easier to compare with NewGenericStore and NewGenericStoreWithPermissionChecker)

pkg/search/postgres/store.go Show resolved Hide resolved
if ok, err := s.permissionChecker.ExistsAllowed(ctx); err != nil {
return false, err
} else if !ok {
return false, sac.ErrResourceAccessDenied
Copy link
Contributor

Choose a reason for hiding this comment

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

This changes the behaviour compared to the generated code.
I'd stick to the previous behaviour that returns false, nil, as if the item did not exist, rather than an error that already tells that the item exists. I think from a security point of view, the new behaviour is a data leak.

tools/generate-helpers/pg-table-bindings/store.go.tpl Outdated Show resolved Hide resolved
@janisz janisz requested a review from rhybrillou July 3, 2023 15:51
@janisz janisz force-pushed the master-janisz/06-30-ROX-18155_pg_generic_store_Exists branch from c6001f4 to 6c69e38 Compare July 3, 2023 16:01
@janisz
Copy link
Contributor Author

janisz commented Jul 4, 2023

/retest

Comment on lines +94 to +98
if ok, err := s.permissionChecker.ExistsAllowed(ctx); err != nil {
return false, err
} else if !ok {
return false, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if ok, err := s.permissionChecker.ExistsAllowed(ctx); err != nil {
return false, err
} else if !ok {
return false, nil
}
return s.permissionChecker.ExistsAllowed(ctx)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we cannot do that as this does not handle true correctly.

@janisz janisz force-pushed the master-janisz/06-30-ROX-18155_pg_generic_store_Exists branch from 21509c8 to 6bddaf3 Compare July 4, 2023 13:22
@openshift-ci
Copy link

openshift-ci bot commented Jul 4, 2023

@janisz: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/ocp-4-10-qa-e2e-tests 6bddaf3 link false /test ocp-4-10-qa-e2e-tests

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@janisz
Copy link
Contributor Author

janisz commented Jul 6, 2023

@janisz started a stack merge that includes this pull request via Graphite.

@janisz janisz merged commit a3ab4c7 into master Jul 6, 2023
39 of 40 checks passed
@janisz janisz deleted the master-janisz/06-30-ROX-18155_pg_generic_store_Exists branch July 6, 2023 09:57
@janisz
Copy link
Contributor Author

janisz commented Jul 6, 2023

@janisz merged this pull request with Graphite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants