Skip to content

ROX-10303: Replace errox wrappers#1389

Merged
mtodor merged 19 commits intomasterfrom
mtodor/ROX-10303-replace-new-error-wrappers
Apr 28, 2022
Merged

ROX-10303: Replace errox wrappers#1389
mtodor merged 19 commits intomasterfrom
mtodor/ROX-10303-replace-new-error-wrappers

Conversation

@mtodor
Copy link
Copy Markdown
Contributor

@mtodor mtodor commented Apr 22, 2022

Description

Next step of unifying error handling.

We have removed the following helper functions:

errox.NewErrNotAuthorized
errox.NewErrNoCredentials
errox.NewErrInvariantViolation
errox.NewErrInvalidArgs

We have also excluded rxoctl from wrapcheck linting step. Otherwise, we are getting errors on func (e *RoxError) CausedBy().

Note: This PR is based on mtodor/ROX-10259-remove-deprecated-errors branch. After PR #1372 is merged, we will change the base branch.

Checklist

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

Testing Performed

The following things are tested locally:

  • make image works
  • make style works so that the linting of all go files is correct

}
if err := verifyNoPrivilegeEscalation(id.Roles(), roles); err != nil {
return nil, errox.NewErrNotAuthorized(err.Error())
return nil, errox.NotAuthorized.CausedBy(err.Error())
Copy link
Copy Markdown
Contributor

@parametalol parametalol Apr 22, 2022

Choose a reason for hiding this comment

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

Suggested change
return nil, errox.NotAuthorized.CausedBy(err.Error())
return nil, errox.NotAuthorized.CausedBy(err)

Might go to a separate PR with refactorings.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@0x656b694d I would do this in separate PR.

@ghost
Copy link
Copy Markdown

ghost commented Apr 22, 2022

Tag for build #479203 is 3.69.x-527-g9cde10b0e3.

💻 For deploying this image using the dev scripts, run the following first:

export MAIN_IMAGE_TAG='3.69.x-527-g9cde10b0e3'

🕹️ A roxctl binary can be downloaded from the CircleCI artifacts.

@parametalol parametalol mentioned this pull request Apr 22, 2022
Base automatically changed from mtodor/ROX-10259-remove-deprecated-errors to master April 25, 2022 07:41
@mtodor mtodor marked this pull request as ready for review April 25, 2022 13:29
@mtodor mtodor requested review from a team as code owners April 25, 2022 13:29
@mtodor mtodor requested a review from parametalol April 25, 2022 13:29
.golangci.yml Outdated

exclude-rules:
- path: "(central|compliance|integration-tests|local|migrator|operator|pkg|sensor|tests|tools|scale)/"
- path: "(central|compliance|integration-tests|local|migrator|operator|pkg|roxctl|sensor|tests|tools|scale)/"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we need that? If we exclude it here then we can disable this linter

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@janisz, Thank you for pointing this out!

I thought that other parts were excluded because they use CausedBy. But then I have checked commit history, and actually, it was like that from the beginning. I have changed Regex because it was there for wrappers that we have replaced.

@mtodor mtodor requested a review from janisz April 25, 2022 16:43
func (s *serviceImpl) GetAuthProvider(_ context.Context, request *v1.GetAuthProviderRequest) (*storage.AuthProvider, error) {
if request.GetId() == "" {
return nil, errox.NewErrInvalidArgs("auth provider id is required")
return nil, errox.InvalidArgs.CausedBy("auth provider id is required")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This does not read right. auth provider id is required hints remediation whereas no auth provider id provided is the cause.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

}
if providerReq.GetId() != "" {
return nil, errox.NewErrInvalidArgs("auth provider id must be empty")
return nil, errox.InvalidArgs.CausedBy("auth provider id must be empty")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as above. Consider adjusting the msgs for all such instances.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@md2119 I have adjusted messages for this file. ✅

I understand your concerns, and they are absolutely valid! But we should restrain ourselves from further such changes because they are out of the scope of this issue, and it would just expand the PR and make the review complicated. We should instead collect such cases and make follow-ups to address them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@md2119 I have adjusted messages for this file. ✅

Thanks for addressing the comments!

I understand your concerns, and they are absolutely valid! But we should restrain ourselves from further such changes because they are out of the scope of this issue, and it would just expand the PR and make the review complicated. We should instead collect such cases and make follow-ups to address them.

Yea, you make a valid argument. Cascading changes are not encouraged. In this case, we are changing the semantics, hence, the things that the new framework applies to, or what new framework consumes, or what the framework depends become conflicting. For example, if it were a Wrap() func, the relevance of the string wouldn't be an issue.

@stackrox stackrox deleted a comment from md2119 Apr 27, 2022
@gitguardian
Copy link
Copy Markdown

gitguardian bot commented Apr 27, 2022

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id Secret Commit Filename
3038029 Generic High Entropy Secret 138264d qa-tests-backend/src/main/groovy/services/NotifierService.groovy View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

@mtodor mtodor requested a review from md2119 April 27, 2022 07:56
func (s *serviceImpl) GetAuthProvider(_ context.Context, request *v1.GetAuthProviderRequest) (*storage.AuthProvider, error) {
if request.GetId() == "" {
return nil, errox.NewErrInvalidArgs("auth provider id is required")
return nil, errox.InvalidArgs.CausedBy("auth provider id is required")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This does not read right. auth provider id is required hints remediation whereas no auth provider id provided is the cause.

@mtodor mtodor merged commit 3bbdfd7 into master Apr 28, 2022
@mtodor mtodor deleted the mtodor/ROX-10303-replace-new-error-wrappers branch April 28, 2022 08:12
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.

4 participants