Ipstenu / varnish-http-purge

Proxy Cache Purge
Apache License 2.0
46 stars 48 forks source link

Better formatting of grep output #60

Closed danielbachhuber closed 6 years ago

danielbachhuber commented 6 years ago

One request from Ellen earlier this week is that the grep output be formatted in a more digestible manner.

Specifically:

  1. Remove the unnecessary part of the filepath:
image
  1. Ensure the output for the matched line doesn't exceed some character count. Ellen had one example where our regex matched a minified JavaScript file, and the output overtook the whole screen.

This morning, I looked into a couple of options:

  1. Update the $pattern to match up to 10 characters before and after the match ('.{0,10}(PHPSESSID|session_start|start_session|$cookie|setCookie).{0,10}')). However, doing so makes grep execution seemingly 5x slower, which I don't think is a reasonable compromise.
  2. Use ack when available instead of grep. However, ack doesn't seem to be any faster with the before and after character matching.

Additional options we could explore include:

  1. Limiting grep to PHP files, which mitigates the scenario where a bunch of minified JavaScript clogs the screen. The original match pattern seems specific to PHP.
  2. Using proc_open to launch the process, and modifying output with PHP.
Ipstenu commented 6 years ago

Limiting grep to PHP files, which mitigates the scenario where a bunch of minified JavaScript clogs the screen. The original match pattern seems specific to PHP.

I'm actually okay with this, since 99% of the time, JS has nothing to do with it, and the 1% that does was going to need a super hands on dig anyway.

danielbachhuber commented 6 years ago

🚢