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

RateLimiterLive : cast des IPs en string #3659

Merged
merged 7 commits into from Dec 12, 2023

Conversation

AntoineAugusti
Copy link
Member

@AntoineAugusti AntoineAugusti commented Dec 12, 2023

Suite de #3652.

Répare une exception Sentry, les clés Cachex étaient stockées en tant que character list ~c. Dommage, la librairie ne documente pas ceci. J'en profite pour ajouter pas mal de tests 🧑‍🏭 ✅

@AntoineAugusti AntoineAugusti marked this pull request as ready for review December 12, 2023 08:54
@AntoineAugusti AntoineAugusti requested a review from a team as a code owner December 12, 2023 08:54

test "ips_in_jail" do
assert [] == TransportWeb.Backoffice.RateLimiterLive.ips_in_jail()
PhoenixDDoS.Jail.send(~c"108.128.238.17", {nil, %{jail_time: {1, :hour}}})
Copy link
Member Author

Choose a reason for hiding this comment

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

auto-merge was automatically disabled December 12, 2023 13:04

Merge queue setting changed

Copy link
Contributor

@thbar thbar left a comment

Choose a reason for hiding this comment

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

Bien vu !

Dommage, la librairie est mal documentée

Je le vois autrement : si je comprends bien, notre code fait appel à Cachex en direct pour avoir les clés.

Or, ce point n'est pas mentionné dans la doc publique (https://github.com/xward/phoenix_ddos).

Donc on est en train d'appeler une API privée de la librairie, qui ne fournit aucune garantie (et qui pourrait changer librement en tant que mainteneur à chaque release). On se protège de ça avec les tests (et ça c'est cool).

Suggestions pour améliorer ça:

  • mettre un commentaire clair dans le code sur cet appel à Cachex pour indiquer que c'est "instable / API privée / non documenté"
  • ouvrir un ticket sur la librairie pour remonter le besoin de ce type (il pourrait y avoir un wrapper qui convertit et expose les clés, directement là dedans ; il y a partiellement ça déjà dans les helpers de test de la librairie

@AntoineAugusti
Copy link
Member Author

AntoineAugusti commented Dec 12, 2023

@thbar Merci, j'ai ajouté un commentaire sur le "gotcha" de l'API interne, j'ai ouvert un ticket au niveau de la dépendance utilisée en indiquant ce qui est fait chez nous et en proposant de faire une PR si le mainteneur est OK pour cet ajout.

@AntoineAugusti AntoineAugusti added this pull request to the merge queue Dec 12, 2023
Copy link
Contributor

@thbar thbar left a comment

Choose a reason for hiding this comment

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

Top, merci @AntoineAugusti pour le soin apporté là dessus.

Mea culpa sur mon commentaire qui aurait pu être plus lissé on va dire, j'ai un peu mal à la tête, ceci explique peut-être un peu cela.

@AntoineAugusti
Copy link
Member Author

image

Merged via the queue into master with commit 008e6c6 Dec 12, 2023
3 checks passed
@AntoineAugusti AntoineAugusti deleted the rate_limiter_live_ip_keys branch December 12, 2023 13:32
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.

None yet

2 participants