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)

650 B
Raw Blame
package intercept

import "net/http"

// ApplyAssessmentUserAgent adds the task's configured identifier to a target
// request. An explicitly supplied User-Agent, including an empty one, takes
// precedence. It reports whether it inserted the identifier.
func ApplyAssessmentUserAgent(req *http.Request) bool {
	scope, ok := TargetScopeFromContext(req.Context())
	if !ok || scope.TaskID == "" || scope.ConversationID != 0 || !scope.AssessmentIdentity.AllowsOrigin(req.URL) {
		return false
	}
	if _, explicit := req.Header["User-Agent"]; explicit {
		return false
	}
	req.Header.Set("User-Agent", scope.AssessmentIdentity.UserAgent())
	return true
}