Giter VIP home page Giter VIP logo

mercury's People

Contributors

domaindrivendev avatar magellol avatar samhh avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mercury's Issues

Log invalid Slack bearer token

We currently warn! on a missing or invalid Heroku secret. We don't do the same thing for Slack bearer tokens, probably because it's implemented in a more shorthand way via ValidateRequestHeaderLayer. We should be logging this because in this type of application any such occurrences are likely to be due to a bug or bad configuration somewhere.

There may be a wider question here about our lack of logging on invalid requests aside from the resultant status code. The client tends to get more information in the body at least.

Open sourcing

If/when we're using this, we should open source it! The only urgent consideration is #9. Beyond that it'd be nice to solve #6 more generally. The README should be adjusted a bit accordingly as well.

Nix cross-compilation

nix run works on macOS, however because it's built against our host system the binary fails inside of a container:

$ nix run
2023-10-30T14:53:25.596675Z  WARN No .env found
[...]

$ nix build ".#dockerImage" && ./result | podman load
$ podman run mercury
{"msg":"exec container process `/nix/store/zi27abixfpaq0x4czinw34dyjwvb7lrb-mercury-0.0.0/bin/mercury`: Exec format error","level":"error","time":"2023-10-30T14:55:01.480708Z"}

We could potentially use crossSystem 1, however that loses access to the Nix binary cache, meaning we end up building the universe.

Thus our options for building the container on macOS are:

  • Building the universe.
  • Running an entire Linux container locally, and then running Nix and the container within that (container-ception).
  • Building the binary outside of Nix with cross, and then somehow incorporating that into Nix, or building the image outside of Nix entirely.
  • Using an obscure overlay 2 3 with its own binary cache.

Footnotes

  1. https://n8henrie.com/2023/09/crosscompile-rust-for-x86-linux-from-m1-mac-with-nix/

  2. https://github.com/rustshop/flakebox

  3. https://github.com/alekseysidorov/nixpkgs-cross-overlay

Stale channel cache

The channel map is cached in memory after the first successful request, and there's currently no way to reset it without restarting the app. This could be an issue if channels are renamed.

/// Get a map from channel names to channel IDs. The first successful result of

Slack requests missing URL encoding

Repro directly against the Slack API:

$ # Replaced with a space character
$ curl -X POST https://slack.com/api/chat.postMessage --oauth2-bearer TOKEN -d channel=CHANNEL -d text=+

$ # Works
$ curl -X POST https://slack.com/api/chat.postMessage --oauth2-bearer TOKEN -d channel=CHANNEL -d text='%2B'

$ # Works
$ curl -X POST https://slack.com/api/chat.postMessage --oauth2-bearer TOKEN -d channel=CHANNEL --data-urlencode text=+

So far this has been confirmed to affect + and &.

Also -X POST is technically redundant but I guess better to be explicit.

Avoiding public misuse

In terms of authentication we act as a proxy in front of the Slack API. This poses the risk that someone uses their own access token on our hosted instance - which will be visible in public repos - to send messages to their own instance.

This is particularly unlikely given that they can't be sure we won't steal their access token, but I thought it's worth documenting.

It should be noted that this is an improvement over Otto which allows anyone to post arbitrary messages to our own Slack instance.

Multi-workspace

Mercury currently anticipates a single Slack token which is present at runtime. This is used to:

  • Validate direct Slack messages, ensuring our public endpoint isn't used by anyone else.
  • Determine ahead of time where Heroku messages should be sent.

This appears incompatible with potentially supporting multiple Slack workspaces.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.