Document regex json format with example
Closed this issue · 6 comments
Summary
I need to supply a regex json. But the json format is not immediately discoverable. I also can't tell if the file is supplementary or replaces the defaults.
Desired Behavior
In the README and help text, the format of the file (A JSON Object where the key is a description and the value is a regex as a JSON string) should be described.
Example files should be included.
An option should allow the user to include the defaults with their supplementary file.
Perhaps the default should be provided as a file instead of a string in Rust. Then the commands would have a default file we could unpack and copy.
Ditto this option for choctaw_hog:
-w, --whitelist <WHITELIST> Sets a custom whitelist JSON file
This PR addresses some of the concerns but not the idea of "An option should allow the user to include the defaults with their supplementary file." So I'll reopen this.
Hi @jeffalder , first thanks for the feedback and my apologies for the long time it took me to see these.
Regarding your last request, I'm not sure how feasible that would be when cargo compiles everything into binaries. I could include a file in the repo, but then anyone who installs the Rusty Hog binary, or just downloads the release files, would also need to install a text file into some known location that would be hardcoded into Rusty Hog. It seems simpler to bundle the ruleset in the binary, but I agree that it's not a great solution. Would including "rules.json" in the repo, but not having code reference it, be a good middle ground?
@cutler-scott-newrelic Another solution would be to have the default file sit in the repo as Json. Then, could the build process do a "json to rust" conversion first? The easiest conversion would probably be to assign it to a static constant, escaping the file input for a rust string.
I have a few other comments on the PR; I'll open a separate PR.
Because this issue is 99% addressed, I recommend that we close this issue and open a separate one if we choose to go this direction.
That sound good. I like the idea of having a JSON file in the repo, and having the compile process pull that file into the binary to act as a default ruleset. I'm putting that as a TODO for v1.0.7 in the README along with a few other of your issues. I'm going to try and get v1.0.6 out today and v1.0.7 next week.
You can now find the default ruleset under src/default_rules.json. At compile time it loads this file as a string.