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

feat(middleware): v4 experimental middleware #986

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

jptosso
Copy link
Member

@jptosso jptosso commented Feb 7, 2024

No description provided.

@jptosso jptosso requested a review from a team as a code owner February 7, 2024 00:18
@jptosso jptosso marked this pull request as draft February 7, 2024 00:19
jptosso and others added 3 commits February 7, 2024 01:41
…ooks to the middleware.

This is specially useful when you want to use transaction data to populate things like logs or spans in a trace enriching the experience and connecting the dots with observability.
Comment on lines 13 to 14
//go:embed error_template.html error_template.html
var embededTemplates embed.FS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... are these going to be html/templates or just html code? At first read I thought they were not static html files only.

In summary:

  • are these meant to be static html?
  • wouldn't be more interesting to use html/template templates that can be filled with details about the transaction? E.g. "Some error found. Contact your admin with this code: { < the transaction ID> }"`

If we use static html, maybe removing the "_template" in the name will make more sense, and use "default_error.html" and "default_interruption.html" instead?

"net/http"

"github.com/corazawaf/coraza/v3"
)

//go:embed error_template.html error_template.html
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//go:embed error_template.html error_template.html
//go:embed error_template.html interruption_template.html

That's just to fix this. But I suggest changing to "default_error.html" and "default_interruption.html", pending on the next comment.

Comment on lines 23 to 30
errorTemplate, err = embededTemplates.ReadFile("error_template.html")
if err != nil {
panic(err)
}
interruptionTemplate, err = embededTemplates.ReadFile("interruption_template.html")
if err != nil {
panic(err)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we avoid error handling at the init level? Can we have a readTemplates method instead that will be called by the middleware?

Comment on lines 69 to 70
// Interruption template supports variables in macro expansion format: %{var}
// Variables are:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Macro expansion as in SecRule macro expansion?

@fzipi
Copy link
Member

fzipi commented Apr 27, 2024

@jptosso Care to take a look at comments?

@fzipi
Copy link
Member

fzipi commented May 1, 2024

And provide a description about what this PR does?

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

3 participants