Skip to content

Conversation

thess
Copy link

@thess thess commented Jun 1, 2025

Allows bot policy rule to check if remote client address falls within a list of CIDR ranges

For example:

  - name: deny-unwanted-scrapers
    action: DENY
    expression:
      all:
        - userAgent.matches("(?i)Wget|lftp")
        - remoteAddrInList(remoteAddress, [ "5.107.206.0/24", "2603:c022:8002:6200::8888/128" ])

FWIW - this is my attempt to address #569. I'm not a Golang programmer but was willing to give it a try (hey - code is code) to see if I could resolve my own issue. This function does seem to work OK - I have tested it live but would like to figure out an integration test. Playwright_test looks like a place to start. Probably needs re-factoring too.

Checklist:

  • Added a description of the changes to the [Unreleased] section of docs/docs/CHANGELOG.md
  • Added test cases to the relevant parts of the codebase
  • Ran integration tests npm run test:integration (unsupported on Windows, please use WSL)

@Xe Xe self-requested a review June 1, 2025 05:07
@Xe
Copy link
Contributor

Xe commented Jun 1, 2025

Thank you so much for this! I'm going to take a look tomorrow once I wake up.

Copy link
Contributor

@Xe Xe left a comment

Choose a reason for hiding this comment

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

I love this!

@thess thess force-pushed the cel-remoteAddrInList branch from 54137ac to 20b187b Compare June 2, 2025 17:30
@thess thess force-pushed the cel-remoteAddrInList branch from 4324cd0 to 93690c5 Compare June 13, 2025 20:22
@thess thess marked this pull request as ready for review June 13, 2025 21:39
@thess thess force-pushed the cel-remoteAddrInList branch 2 times, most recently from 3c4c9f8 to a4a8e87 Compare June 14, 2025 22:28
@thess thess force-pushed the cel-remoteAddrInList branch 3 times, most recently from 73faa5b to d417eae Compare June 24, 2025 13:12
@thess
Copy link
Author

thess commented Jun 24, 2025

Updated to current trunk (again)
@Xe -- Are we going to merge this for 1.20 ?

feat(expressions): implement CIDR ranger caching for remoteAddrInList function

Allows bot policy rule to check if remote client address falls within a list of CIDR ranges

For example:

  - name: deny-unwanted-scrapers
    action: DENY
    expression:
      all:
        - userAgent.matches("(?i)Wget|lftp")
        - remoteAddrInList(remoteAddress, [
            "5.107.206.0/24",
            "2603:c022:8002:6200::8888/128" ])

Signed-off-by: Ted Hess <[email protected]>
Co-authored-by: Jason Cameron <[email protected]>
@thess thess force-pushed the cel-remoteAddrInList branch from d417eae to a67ea49 Compare June 24, 2025 13:20
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