diff --git a/.gitignore b/.gitignore index 6b5edaa..34b051c 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ Thumbs.db # Temp tmp/ .tmp/ +waf_config.json diff --git a/cmd/mockwallarm/main.go b/cmd/mockwallarm/main.go index a721008..e2a28fb 100644 --- a/cmd/mockwallarm/main.go +++ b/cmd/mockwallarm/main.go @@ -9,7 +9,7 @@ import ( "time" ) -// MockWallarm is a test server that simulates a Wallarm node. +// Mockinspection endpoint is a test server that simulates a inspection endpoint. // Usage: go run mock_wallarm.go [--mode=allow|block|slow|flaky] // // Modes: @@ -47,7 +47,7 @@ func main() { port = p } - log.Printf("Mock Wallarm node starting on :%s (mode=%s)", port, mode) + log.Printf("Mock inspection endpoint starting on :%s (mode=%s)", port, mode) if err := http.ListenAndServe(":"+port, nil); err != nil { log.Fatal(err) } diff --git a/config.go b/config.go index 9e85b3d..4b7dc82 100644 --- a/config.go +++ b/config.go @@ -11,7 +11,7 @@ import ( type Config struct { Enabled bool `json:"enabled"` NodeURL string `json:"node_url"` // e.g. http://192.168.1.50:8080 - ReturnPort int `json:"return_port"` // port for Wallarm async callbacks + ReturnPort int `json:"return_port"` // port for inspection endpoint async callbacks TimeoutMs int `json:"timeout_ms"` // inspection timeout in milliseconds } diff --git a/go.mod b/go.mod index 06858e5..5eb00bc 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module zoraxy-waf +module zoraxy-firewall go 1.21 diff --git a/main.go b/main.go index d66e1e7..7bb00af 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,7 @@ import ( "log" "net/http" - "zoraxy-waf/zoraxy_plugin" + "zoraxy-firewall/zoraxy_plugin" ) //go:embed web/* @@ -17,11 +17,11 @@ func main() { loadConfig() spec := &zoraxy_plugin.IntroSpect{ - ID: "zoraxy-waf", - Name: "Zoraxy WAF", + ID: "zoraxy-firewall", + Name: "Firewall", Author: "Zoraxy Community", AuthorContact: "", - Description: "Web Application Firewall — synchronous Wallarm inspection with circuit breaker and fail-open protection.", + Description: "Web Application Firewall with circuit breaker and fail-open protection.", URL: "", Type: zoraxy_plugin.PluginType_Router, // Type 0 — intercepts traffic VersionMajor: 1, @@ -57,7 +57,7 @@ func main() { }, mux) uiRouter.AttachHandlerToMux(mux) - // --- Return port listener for Wallarm async callbacks (future) --- + // --- Return port listener for inspection endpoint async callbacks (future) --- cfg := getConfig() if cfg.ReturnPort > 0 { go func() { @@ -120,7 +120,7 @@ func handleGetStats(w http.ResponseWriter, r *http.Request) { } func handleReturnVerdict(w http.ResponseWriter, r *http.Request) { - // Future: Wallarm async callbacks arrive here. + // Future: inspection endpoint async callbacks arrive here. var resp InspectionResponse if err := json.NewDecoder(r.Body).Decode(&resp); err != nil { writeJSON(w, http.StatusBadRequest, map[string]string{"error": "bad verdict"}) diff --git a/middleware.go b/middleware.go index 38f0cc0..e7f3b33 100644 --- a/middleware.go +++ b/middleware.go @@ -6,7 +6,7 @@ import ( "net/http" "sync/atomic" - "zoraxy-waf/zoraxy_plugin" + "zoraxy-firewall/zoraxy_plugin" ) var breaker = newCircuitBreaker() diff --git a/wallarm_client.go b/wallarm_client.go index 728d42e..68885ee 100644 --- a/wallarm_client.go +++ b/wallarm_client.go @@ -10,7 +10,7 @@ import ( "time" ) -// InspectionRequest is sent to the Wallarm node. +// InspectionRequest is sent to the inspection endpoint. type InspectionRequest struct { Method string `json:"method"` URL string `json:"url"` @@ -22,16 +22,16 @@ type InspectionRequest struct { BodySample []byte `json:"body_sample"` // first N bytes } -// InspectionResponse is returned by the Wallarm node. +// InspectionResponse is returned by the inspection endpoint. type InspectionResponse struct { Verdict string `json:"verdict"` // "allow" or "block" Reason string `json:"reason,omitempty"` Score int `json:"score,omitempty"` } -const maxBodySample = 4096 // only send first 4KB to Wallarm +const maxBodySample = 4096 // only send first 4KB to inspection endpoint -// inspect sends a synchronous inspection request to the Wallarm node. +// inspect sends a synchronous inspection request to the inspection endpoint. // Returns nil if allowed, or an error describing the block reason. func inspect(r *http.Request) (*InspectionResponse, error) { c := getConfig() @@ -70,13 +70,13 @@ func inspect(r *http.Request) (*InspectionResponse, error) { resp, err := client.Post(c.NodeURL+"/inspect", "application/json", bytes.NewReader(body)) if err != nil { - return nil, fmt.Errorf("wallarm node unreachable: %w", err) + return nil, fmt.Errorf("inspection node unreachable: %w", err) } defer resp.Body.Close() var inspResp InspectionResponse if err := json.NewDecoder(resp.Body).Decode(&inspResp); err != nil { - return nil, fmt.Errorf("decode wallarm response: %w", err) + return nil, fmt.Errorf("decode inspection response: %w", err) } log.Printf("WAF: %s %s → %s (score=%d reason=%s)", diff --git a/web/app.js b/web/app.js index b8868ea..8f21bd7 100644 --- a/web/app.js +++ b/web/app.js @@ -1,9 +1,9 @@ -// Zoraxy WAF — config panel +// Firewall — config panel function loadConfig() { $.get('./api/config', function (data) { $('#waf-enabled').prop('checked', data.enabled); - $('#enabled-label').text(data.enabled ? 'WAF Enabled' : 'WAF Disabled'); + $('#enabled-label').text(data.enabled ? 'Firewall Enabled' : 'Firewall Disabled'); $('#node-url').val(data.node_url); $('#return-port').val(data.return_port); $('#timeout-ms').val(data.timeout_ms); @@ -47,7 +47,7 @@ function saveConfig() { } $('#waf-enabled').on('change', function () { - $('#enabled-label').text(this.checked ? 'WAF Enabled' : 'WAF Disabled'); + $('#enabled-label').text(this.checked ? 'Firewall Enabled' : 'Firewall Disabled'); }); $('#save-btn').on('click', saveConfig); diff --git a/web/index.html b/web/index.html index 9ab06ff..87e6a2f 100644 --- a/web/index.html +++ b/web/index.html @@ -4,13 +4,13 @@ - Zoraxy WAF + Firewall
-

Zoraxy WAF

-

Web Application Firewall with Wallarm inspection.

+

Firewall

+

Web Application Firewall — inspect traffic against a remote inspection engine.

@@ -22,11 +22,11 @@ - WAF Disabled + Firewall Disabled
- +
@@ -51,7 +51,7 @@ --
- WAF Status: + Status: --