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

Exposing some of the hidden packages behind internal folder. #1094

Open
s3rj1k opened this issue Jul 11, 2024 · 9 comments
Open

Exposing some of the hidden packages behind internal folder. #1094

s3rj1k opened this issue Jul 11, 2024 · 9 comments

Comments

@s3rj1k
Copy link

s3rj1k commented Jul 11, 2024

I think that this internal folder that hides most of exported modules is an unfortunate situation.

Consider a use-case when someone wants to make a rules parser to help migrate off libmodsecurity, in current state this can only be done by actually launching waf via NewWAF function, this works but is a bit uncomfortable.

Furthermore, considering the case above, when broken rule is encountered, in some cases, error message is so obscured with error wrapping and lacks the actual information that can help to find the actual broken rule as opposed to how libmodsecurity reports parse errors (with partial rule and file:linenumber).

By exposing so of the internal packages to public it will allow to reuse them more comfortably and will help improve error messaging, at least there will be no multiple/useless error wrapping for parser code.

@jptosso
Copy link
Member

jptosso commented Jul 12, 2024

Hey! The reason behind this is long-term maintenance; if you want a specific API or set of APIs, please mention them on this issue so we can review this. We don't have any problem with exposing additional APIs as long as it's safe, it doesn't break compatibility, and there is a clear use case.

There are certain limitations, for example, we cannot expose additional functions for existing immutable interfaces, as it breaks compatibility. In which case we would have to release Wrappers to access to them. Like:

tx := tx.(types.TransactionState)
tx = tx.(otherpackage.TransactionExtended)

@s3rj1k
Copy link
Author

s3rj1k commented Jul 12, 2024

In my case described above I guess I would want access to:

  • corazawaf.NewWAF()
  • seclang.NewParser()
  • parser.FromString()

@fzipi
Copy link
Member

fzipi commented Jul 12, 2024

Do you want to create a new parser, or just add some directives?

@s3rj1k
Copy link
Author

s3rj1k commented Jul 12, 2024

No, some utility that checks rules validity and has a bit more verbose error messages in regards to where the actual broken rule is (file:linenumber).

@jcchavezs
Copy link
Member

jcchavezs commented Jul 15, 2024 via email

@s3rj1k
Copy link
Author

s3rj1k commented Jul 15, 2024

@jptosso Another solution maybe just standalone CLI utility in repository that just loads ruleset and reports error if any, I am fine with doing PRs as long as there is some kind of simplified entry point for rule testing that is.

Also this will be similar to what has libmodsecurity, they ship standalone CLI to just do rule verification.

This way there is no need to wraparound into experimental API.

@jcchavezs
Copy link
Member

jcchavezs commented Jul 15, 2024 via email

@s3rj1k
Copy link
Author

s3rj1k commented Jul 15, 2024

@jptosso Yea, sounds also good

@jcchavezs
Copy link
Member

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

No branches or pull requests

4 participants