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

Add greedy regex for the bridge namespace #366

Merged
merged 2 commits into from
Oct 25, 2021

Conversation

Half-Shot
Copy link
Contributor

@Half-Shot Half-Shot commented Oct 21, 2021

We don't use the namespace login in the bot-sdk for anything, so this should be safe to do. We don't use this namespace to inform Synapse, so there isn't a risk to security either.

A solution for turt2live/matrix-bot-sdk#159

Hopefully helps solve matrix-org/matrix-appservice-irc#1490

Comment on lines +646 to +647
regex: "@.+_.+:.*",
exclusive: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Exclusive only prevents humans from registering a name with an underscore in their username, right?

Can other appservices still have an exclusive claim on @slack_ or @telegram_?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't matter in this context, only the bridge is going to see this namespace. Synapse will see the "real" namespace from the reg file.

@@ -639,7 +639,13 @@ export class Bridge {
url: rawReg.url || undefined,
protocols: rawReg.protocols || undefined,
namespaces: {
users: rawReg.namespaces?.users || [],
users: [{
// Deliberately greedy regex to fix https://github.com/turt2live/matrix-bot-sdk/issues/159
Copy link
Contributor

Choose a reason for hiding this comment

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

"Too many user namespaces registered: expecting exactly one"
Why is it any array then?
Or is it that you may only have one of any "exclusive" value?

namespaces:
  aliases: []
  users:
    - exclusive: false
      regex: "@.*:localhost"
    - exclusive: true
      regex: "@adminbot:localhost"

This works for me locally.. and I don't see an issue with having two claims.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, this is about the bot-sdk only allowing one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, this is us basically faking it to the bot-sdk that we have one big namespace to get around the issue.

@Half-Shot Half-Shot requested a review from jaller94 October 22, 2021 12:34
Copy link
Contributor

@tadzik tadzik left a comment

Choose a reason for hiding this comment

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

Seems to fix the issue when tested locally. Looks good to me too :)

@tadzik tadzik merged commit 99cbd66 into develop Oct 25, 2021
@Half-Shot Half-Shot deleted the hs/bot-sdk-allow-multiple-user-namespaces branch May 2, 2023 16:06
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.

3 participants