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

Bug 1879980: Fix swallowed error message in GroupDetector #719

Closed

Conversation

zerodayz
Copy link
Contributor

ldapquery.IsQueryOutOfBoundsError(err) ||
ldapquery.IsEntryNotFoundError(err) ||
ldapquery.IsNoSuchObjectError(err)

Would return false but error was swallowed

 ldapquery.IsQueryOutOfBoundsError(err) ||
 ldapquery.IsEntryNotFoundError(err) ||
 ldapquery.IsNoSuchObjectError(err)

Would return false but error was swallowed
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: zerodayz
To complete the pull request process, please assign tnozicka after the PR has been reviewed.
You can assign the PR to them by writing /assign @tnozicka in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@zerodayz
Copy link
Contributor Author

Following that, with swallowed error we set exists to false, but no err as we returned nil.

		exists, err := s.GroupDetector.Exists(ldapGroupUID)
		if err != nil {
			fmt.Fprintf(s.Err, "Error determining LDAP group existence for group %q: %v.\n", ldapGroupUID, err)
			errors = append(errors, err)
			continue
		}
		if exists {
			continue
		}

This PR fixes that and we exit with error properly.

@zerodayz
Copy link
Contributor Author

Also to mention, it has a side effect of deleting the group from OpenShift, since it doesn't find the group in AD, throws an error, that error is not passed over. no error, means skip the next block, check if exists if true, if not, then delete from OpenShift.

@zerodayz zerodayz changed the title Fix swallowed error message in GroupDetector Bug 1879980: Fix swallowed error message in GroupDetector Jan 27, 2021
@openshift-ci-robot
Copy link

@zerodayz: This pull request references Bugzilla bug 1879980, which is invalid:

  • expected the bug to target the "4.7.0" release, but it targets "---" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

Bug 1879980: Fix swallowed error message in GroupDetector

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.

@openshift-ci-robot openshift-ci-robot added bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Jan 27, 2021
@zerodayz
Copy link
Contributor Author

/bugzilla refresh

@openshift-ci-robot openshift-ci-robot added bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. and removed bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Jan 27, 2021
@openshift-ci-robot
Copy link

@zerodayz: This pull request references Bugzilla bug 1879980, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.7.0) matches configured target release for branch (4.7.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

/bugzilla refresh

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.

@zerodayz
Copy link
Contributor Author

/retest

6 similar comments
@zerodayz
Copy link
Contributor Author

zerodayz commented Feb 1, 2021

/retest

@zerodayz
Copy link
Contributor Author

zerodayz commented Feb 3, 2021

/retest

@zerodayz
Copy link
Contributor Author

/retest

@zerodayz
Copy link
Contributor Author

/retest

@zerodayz
Copy link
Contributor Author

/retest

@zerodayz
Copy link
Contributor Author

zerodayz commented Mar 7, 2021

/retest

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 8, 2021

@zerodayz: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/unit ab6be6f link /test unit
ci/prow/e2e-aws-serial ab6be6f link /test e2e-aws-serial

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.

@zerodayz
Copy link
Contributor Author

zerodayz commented Apr 5, 2021

@deads2k, @mfojtik Can you guys please review, this has been laying around since January 30th and it prevents the unnecessary delete of the AD groups from OpenShift when customer use wrong casing.

@@ -20,7 +20,7 @@ type GroupBasedDetector struct {
func (l *GroupBasedDetector) Exists(ldapGroupUID string) (bool, error) {
group, err := l.groupGetter.GroupEntryFor(ldapGroupUID)
if ldapquery.IsQueryOutOfBoundsError(err) || ldapquery.IsEntryNotFoundError(err) || ldapquery.IsNoSuchObjectError(err) {
return false, nil
return false, err
Copy link
Contributor

Choose a reason for hiding this comment

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

Does your fix from go-ldap/ldap#307 applies, I'm worried this is breaking expected scripts where we wanted to ignore, I'd be more inclined to log with V(4), for example, rather than hard fail.

Copy link
Contributor Author

@zerodayz zerodayz Jun 14, 2021

Choose a reason for hiding this comment

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

hi @soltysh this is related to https://bugzilla.redhat.com/show_bug.cgi?id=1879980

The groupSync deleted the groups because it can't find the correct OU

OU=Groups,OU=Unix != OU=groups,OU=unix

I believe this will return also if you query wrong DN. I will take some time to check it again. (its been a while ago)

Now this means you hit the error ldapquery.IsQueryOutOfBoundsError(err), but that err is never returned.

Not sure which case is used for ignoring, but if you by mistake set the wrong DN, which will hit OutOfBounds Error. GroupSync will delete all your OpenShift groups because this error is swallowed and GroupSync doesn't know you hit the wrong DN, instead it just can't see any groups, so it will sync with nothing.

The other patch for upper/lowercase in that case you are in correct DN but just wrong case.

For example:

usersQuery:
        baseDN: "ou=users,dc=redhat,dc=com"

usersQuery:
        baseDN: "ou=Users,dc=redhat,dc=com"

With go-ldap/ldap#307, we can then easily update oc client, especially https://github.com/openshift/library-go/blob/master/pkg/security/ldapquery/query.go#L116

From:
		if !baseDN.AncestorOf(dn) && !baseDN.Equal(dn) {

To:
		if !baseDN.AncestorOfFold(dn) && !baseDN.EqualFold(dn) {

But we would also need to bump the version of go-ldap to include that fix, I am not sure how to do that part.

Copy link
Contributor

Choose a reason for hiding this comment

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

But we would also need to bump the version of go-ldap to include that fix, I am not sure how to do that part.

Hmm... it looks like we're using quite old ldap library

oc/go.mod

Line 55 in 64b59fe

gopkg.in/ldap.v2 v2.5.1
whereas the current version is 3.3 which would also require updating what we're using in oc. Lemme know if you're interested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will talk to you, I would like to take this.

@soltysh
Copy link
Contributor

soltysh commented Jun 8, 2021

/assign

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 8, 2021

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: zerodayz
To complete the pull request process, please assign soltysh after the PR has been reviewed.
You can assign the PR to them by writing /assign @soltysh in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot
Copy link
Contributor

/bugzilla refresh

The requirements for Bugzilla bugs have changed, recalculating validity.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 6, 2021

@openshift-merge-robot: This pull request references Bugzilla bug 1879980, which is invalid:

  • expected the bug to target the "4.10.0" release, but it targets "---" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

Retaining the bugzilla/valid-bug label as it was manually added.

In response to this:

/bugzilla refresh

The requirements for Bugzilla bugs have changed, recalculating validity.

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.

@openshift-merge-robot
Copy link
Contributor

/bugzilla refresh

The requirements for Bugzilla bugs have changed, recalculating validity.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 6, 2021

@openshift-merge-robot: This pull request references Bugzilla bug 1879980, which is invalid:

  • expected the bug to target the "4.10.0" release, but it targets "---" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

Retaining the bugzilla/valid-bug label as it was manually added.

In response to this:

/bugzilla refresh

The requirements for Bugzilla bugs have changed, recalculating validity.

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.

@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 5, 2021
@openshift-bot
Copy link
Contributor

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci openshift-ci bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jan 4, 2022
@openshift-bot
Copy link
Contributor

/bugzilla refresh

The requirements for Bugzilla bugs have changed (BZs linked to PRs on master branch need to target OCP 4.11), recalculating validity.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 28, 2022

@openshift-bot: This pull request references Bugzilla bug 1879980, which is invalid:

  • expected the bug to target the "4.11.0" release, but it targets "---" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

Retaining the bugzilla/valid-bug label as it was manually added.

In response to this:

/bugzilla refresh

The requirements for Bugzilla bugs have changed (BZs linked to PRs on master branch need to target OCP 4.11), recalculating validity.

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.

@wking
Copy link
Member

wking commented Jan 31, 2022

/bugzilla refresh

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 31, 2022

@wking: This pull request references Bugzilla bug 1879980, which is invalid:

  • expected the bug to target the "4.11.0" release, but it targets "---" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

Retaining the bugzilla/valid-bug label as it was manually added.

In response to this:

/bugzilla refresh

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.

@openshift-bot
Copy link
Contributor

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-ci openshift-ci bot closed this Mar 2, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 2, 2022

@openshift-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

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.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 2, 2022

@zerodayz: This pull request references Bugzilla bug 1879980. The bug has been updated to no longer refer to the pull request using the external bug tracker.

In response to this:

Bug 1879980: Fix swallowed error message in GroupDetector

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants