question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to whitelist paths and/or http verbs?

See original GitHub issue

I can’t seem to find an example in the documentation for either of these.

Is there a way to see the full payload for

query_engine: "jp",
query: "$.login",

?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
travisghansencommented, Mar 26, 2021

I’ve added the necessary bits to the server to cope with this. Once it lands you’ll be able to do something like this:

        {
          "type": "noop",
          "pcb": {
            "skip": [
              {
                "query_engine": "jp",
                "query": "$.parentReqInfo.method",
                "rule": {
                  "method": "eq",
                  "value": "POST",
                  "negate": true
                }
              },
              {
                "query_engine": "jp",
                "query": "$.parentReqInfo.parsedUri.path",
                "rule": {
                  "method": "regex",
                  "value": "/^\/foo\//i",
                  "negate": true
                }
              }
            ]
          }
        }

The idea being, if the noop plugin is executed it always returns a 200 and therefore stops the pipeline. Keep in mind that each rule is a logical and so all must pass for the pcb to take effect. In this case it’s slightly confusing because we’re using the negate attribute combined with the fact that it’s a skip procedure (basically a double negative). However, the end result of the above is, this plugin is skipped unless it’s a POST to /foo/... Implicitly noop passes if invoked so if it’s not skipped, then request is allowed. If you want to OR logic of this nature then add multiple noop plugins inside the pipeline.

Having said all that, it’s much easier to use request_js plugin if feasible as the ability to do complex logic can be expressed much easier using pure code.

1reaction
travisghansencommented, Mar 1, 2021

OK, there are really 2 approaches:

Using request_js already has access to parentReqInfo which includes all the info you would need to check verb, path, etc and make decisions. I’ve already got adding that info to the pcb logic queued up to make it work using that mechanism as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Access-Control-Allow-Methods - HTTP - MDN Web Docs
The Access-Control-Allow-Methods response header specifies one or more methods allowed when accessing a resource in response to a preflight ...
Read more >
Why should someone block all methods other than GET ...
The reason this best practice exists is because of the HTTP Verb ... Reject all requests not matching the whitelist with HTTP response...
Read more >
no-http-verbs-in-paths
Disallows HTTP verbs used in paths. ... The REST type prefers to name paths after resources like "customers", and "payments".
Read more >
The request was rejected because the HTTP method ...
The request was rejected because the HTTP method "CONNECT" was not included within the whitelist [HEAD, DELETE, POST, GET, OPTIONS, PATCH, PUT].
Read more >
Whitelist based on HTTP verb · Issue #462 · openflagr/flagr
Currently, whitelisting is based solely on path. There is no way to allow only GET access to a path. Is there any way...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found