Skip to content

armgit / ARTEX

Public Imported from GitHub
0

ARTEX - AI autonomous penetration testing system (English translation; upstream: Autumn-27/ARTEX, AGPL-3.0)

feat(traffic/rewrite): let the proxy record a rule's transport error

BaaRaib3e1f5359f82
diff --git a/traffic/rewrite/compile.go b/traffic/rewrite/compile.go
index ed663f9..87079de 100644
--- a/traffic/rewrite/compile.go
+++ b/traffic/rewrite/compile.go
@@ -80,6 +80,14 @@ func (s *Set) LoadErrors() map[int64]string {
return s.loadErrors
}
+// NoteError records a run-time error of a rule seen outside the engine, such
+// as the transport failure of a request the rule rewrote.
+func (s *Set) NoteError(id int64, class string) {
+ if s != nil {
+ s.errors.record(id, class)
+ }
+}
+
// LastError is the most recent run-time error of a rule. It lives in memory
// only; the per-exchange trace keeps the history.
type LastError struct {
diff --git a/traffic/rewrite/trace.go b/traffic/rewrite/trace.go
index 506a85e..5bf494d 100644
--- a/traffic/rewrite/trace.go
+++ b/traffic/rewrite/trace.go
@@ -30,6 +30,9 @@ const (
ErrClassInvalidURL = "invalid_url" // a rewritten path and query is not a valid request URI
ErrClassExpansion = "expansion_limit" // a replace result exceeds MaxExpansion
ErrClassPanic = "panic"
+ // ErrClassTransport is recorded by the proxy, not the engine: the request a
+ // rule rewrote could not be sent or answered.
+ ErrClassTransport = "transport_error"
)
// TraceLine is one row of an exchange's rewrite trace, in order. An exchange is