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

rspamd selector syntax not supported #6

Open
pipera opened this issue Sep 25, 2019 · 7 comments
Open

rspamd selector syntax not supported #6

pipera opened this issue Sep 25, 2019 · 7 comments

Comments

@pipera
Copy link

pipera commented Sep 25, 2019

conf-files using selector syntax (https://rspamd.com/doc/configuration/selectors.html) seem not to be supported. For example, I see no way to create 'ratelimit.conf' (https://rspamd.com/doc/modules/ratelimit.html) with the following syntax:

rates {
# Selector based ratelimit
some_limit = {
selector = 'user.lower';
# You can define more than one bucket, however, you need to use array syntax only
bucket = [
{
burst = 100;
rate = "10 / 1min";
},
{
burst = 10;
rate = "100 / 1min";
}]
}
}

@oxc
Copy link
Contributor

oxc commented Nov 1, 2019

Can you be a bit more explicit about what part exactly of the syntax is not supported? That would make it easier to find a solution. Thanks!

@pipera
Copy link
Author

pipera commented Nov 4, 2019

The problem is the nested structure of blocks (defined by '{..}') inside of an array (defined by '[..]' as seen in the 'bucket'-example above. I don't see a way to define this, I can only define blocks inside blocks (defined by '{...{...}{...}...}').

@oxc
Copy link
Contributor

oxc commented Apr 7, 2020

It should be easy to support this in the custom functions, but do you have any suggestions how to support this in hiera?

@SimonHoenscheid
Copy link

SimonHoenscheid commented Aug 23, 2020

I ran into this as well, trying to work with dkim, but it has primarily to do with the way the module handles data types:

RSPAMD exspects the selector to be a string value. The only way to force the module to quote the value, is to add a special caracter to it, in the case "_".
A way to go around this, would be maps, but maps don't seem to be supported by the module.

domain {
  example.com {
    path = "/var/lib/rspamd/dkim/$domain.$selector.key";
    selector = "date_20200822";
  }
  example.net {
    path = "/var/lib/rspamd/dkim/$domain.$selector.key";
    selector = 20200822;
  }
}

@oxc
Copy link
Contributor

oxc commented Sep 23, 2020

I ran into this as well, trying to work with dkim, but it has primarily to do with the way the module handles data types:

RSPAMD exspects the selector to be a string value. The only way to force the module to quote the value, is to add a special caracter to it, in the case "_".
A way to go around this, would be maps, but maps don't seem to be supported by the module.

domain {
  example.com {
    path = "/var/lib/rspamd/dkim/$domain.$selector.key";
    selector = "date_20200822";
  }
  example.net {
    path = "/var/lib/rspamd/dkim/$domain.$selector.key";
    selector = 20200822;
  }
}

The rspamd::config resource already supports specifying the type, e.g. $type = 'string'. By default the type is 'auto', which coerces strings that look like numbers into numbers, which is what you are describing here.

Please open a different issue for this. If you can, please provide an idea on how to solve this.

@oxc
Copy link
Contributor

oxc commented Sep 23, 2020

@pipera, I tried to model your example from the first post:

    rates:
      some_limit:
        selector: 'user.lower'
        bucket:
          - burst: 100
            rate: "10 / 1min"
          - burst: 10
            rate: "100 / 1min"

This results in the following UCL:

rates {
  some_limit {
    selector = "user.lower";
    bucket {
      burst = 100;
      rate = "10 / 1min";
    }
    bucket {
      burst = 10;
      rate = "100 / 1min";
    }
  }
}

According to the UCL documentation, "Non-unique keys in an object are allowed and are automatically converted to the arrays internally". Unless this is wrong, the generated code should be fully equivalent to what you have pasted (at least as long as you stay within one file, I vaguely remember encountering issues when automatic arrays were merged).

Does this work for you?

@pipera
Copy link
Author

pipera commented Sep 24, 2020 via email

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

No branches or pull requests

3 participants