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

introduces the config package to refactor the way the config is obtained #582

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

daniel-ts
Copy link

This commit refactors the ffuf code to simplify the configuration
process. ffuf's configuration has become complex, since it takes configurations
from multiple configuration sources like the commandline, multiple configuration
files and HTTP request files (sometimes called HTTP templates). Inputs from
these configuration sources have to be merged into one coherent configuration
and it's consistency validated. ffuf lacked a clear way to obtain it's
configuration easily and clearly. Any contributor who wanted to introduce a new
feature had to study the configuration code and insert his or modify the
configuration process with the hopes of not breaking anything.

The config package aims to simplify and formalize the configuration of ffuf,
while making it flexible and extensible. It provides:

  • One simple function call to obtain a configuration from a standard hierarchy
    of all configurations sources
  • A mechanism to merge the defined configuration sources
  • A mechanism to validate the merged configuration and supply error messages
    to the caller
  • A way to add a configuration source to ffuf
  • A way to add validation to new or changed options without knowing the code
    base

A pkg/config/README.md is provided to further explain the configuration
process. Additionally, the core functionality is of this package is tested an
examples as Go code are provided.

This commit had to make changes to code outside the main package to untangle the
imports, which were causing import cycles.

This commit refactors the ffuf code to simplify the configuration
process. ffuf's configuration has become complex, since it takes configurations
from multiple configuration sources like the commandline, multiple configuration
files and HTTP request files (sometimes called HTTP templates). Inputs from
these configuration sources have to be merged into one coherent configuration
and it's consistency validated. ffuf lacked a clear way to obtain it's
configuration easily and clearly. Any contributor who wanted to introduce a new
feature had to study the configuration code and insert his or modify the
configuration process with the hopes of not breaking anything.

The config package aims to simplify and formalize the configuration of ffuf,
while making it flexible and extensible. It provides:
  * One simple function call to obtain a configuration from a standard hierarchy
    of all configurations sources
  * A mechanism to merge the defined configuration sources
  * A mechanism to validate the merged configuration and supply error messages
    to the caller
  * A way to add a configuration source to ffuf
  * A way to add validation to new or changed options without knowing the code
    base

A pkg/config/README.md is provided to further explain the configuration
process. Additionally, the core functionality is of this package is tested an
examples as Go code are provided.

This commit had to make changes to code outside the main package to untangle the
imports, which were causing import cycles.
The HTTP version was parsed with http.ParseHTTPVersion, which conforms to RFC
7230, which makes explicit, that the version part of the request line must have
a major and minor version like so "HTTP/<major>.<minor>", http.ParseHTTPVersion
errors if the version part is "HTTP/2".

Because this version of ffuf extracts configuration parameters from the version
part in the request line, especially ConfigOptions.HTTPOptions.Http2, a helper
function parseHTTPVersion was introduced, which handles the version extraction
more suitable to web fuzzing.
@joohoi
Copy link
Member

joohoi commented Feb 2, 2023

Oh boy, I've been on a hiatus for a while, and just now stumbled upon this PR. I do agree with the points made, and in case you are interested to keep on working on this, I'd be delighted to have it in.

There are a couple large commits that will be made towards master in the coming days for the next release, so I would wait for a bit before continuing on the merge conflicts etc.

Also this PR is so large that it will take a good amount of time and multiple large containers of coffee to review properly.

@daniel-ts
Copy link
Author

Hi joohoi, yes I'd be happy to work on getting these conflicts resolved. Next week is the earliest I could take a look, though.

Yeah, it's quite large xD so look at it at your own leasure. I'd be happy to assist.

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