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

Added handling disallow_attester_search_for_domains OrgRule #1387

Merged

Conversation

DenBond7
Copy link
Collaborator

@DenBond7 DenBond7 commented Aug 5, 2021

This PR added handling disallow_attester_search_for_domains OrgRule

close #1203


Tests (delete all except exactly one):

  • Tests added or updated

To be filled by reviewers

I have reviewed that this PR... (tick whichever items you personally focused on during this review):

  • addresses the issue it closes (if any)
  • code is readable and understandable
  • is accompanied with tests, or tests are not needed
  • is free of vulnerabilities

@DenBond7 DenBond7 added the PR submitted PR is submitted for this issue label Aug 5, 2021
@DenBond7 DenBond7 added this to the 1.2.0: More OrgRules milestone Aug 5, 2021
@DenBond7 DenBond7 removed the PR submitted PR is submitted for this issue label Aug 6, 2021
@DenBond7 DenBond7 closed this Aug 6, 2021
@DenBond7 DenBond7 force-pushed the issue_1203_disallow_attester_search_for_domains branch from 9f1b659 to 8d0fe16 Compare August 6, 2021 07:12
@DenBond7 DenBond7 reopened this Aug 6, 2021
@DenBond7 DenBond7 marked this pull request as ready for review August 6, 2021 13:37
@DenBond7 DenBond7 requested a review from IvanPizhenko as a code owner August 6, 2021 13:37
Copy link
Contributor

@IvanPizhenko IvanPizhenko left a comment

Choose a reason for hiding this comment

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

I have a question

throw IllegalStateException("Not a valid email $emailAddr")
}

return !disallowedDomains.contains(userDomain)
Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't this require sort of case-insensitive comparison?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

In typescript we have:

  public canLookupThisRecipientOnAttester = (emailAddr: string): boolean => {
    ....
    const userDomain = Str.getDomainFromEmailAddress(emailAddr);
    if (!userDomain) {
      throw new Error(`Not a valid email ${emailAddr}`);
    }
    return !disallowedDomains.includes(userDomain);
  }

and then:

  public static getDomainFromEmailAddress = (emailAddr: string) => {
    // todo: parseEmail()?
    return emailAddr.toLowerCase().split('@')[1];
  }

So function for getting domain in the typescript casts it to lowercase and then if you configure everything in lowercase, all works.
In Kotlin that doesn't happen:

    // from EmailUtil.kt
    fun getDomain(email: String): String {
      return when {
        TextUtils.isEmpty(email) -> ""
        email.contains("@") -> email.substring(email.indexOf('@') + 1)
        else -> ""
      }
    }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see. Thank you. I will fix it.

@tomholub
Copy link
Collaborator

tomholub commented Aug 8, 2021

Well noticed, Ivan - thank you.

@DenBond7 DenBond7 requested a review from IvanPizhenko August 9, 2021 11:00
@IvanPizhenko IvanPizhenko merged commit 4771ba0 into master Aug 9, 2021
@IvanPizhenko IvanPizhenko deleted the issue_1203_disallow_attester_search_for_domains branch August 9, 2021 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement disallow_attester_search_for_domains OrgRule
3 participants