Documentation
¶
Index ¶
- Constants
- Variables
- func FindViewsDir() (string, error)
- func FuncMap() template.FuncMap
- func GetCookieValue(r *http.Request, key string) string
- func GetFormValue(r *http.Request, key string) string
- func GetHeaderValue(r *http.Request, key string) string
- func GetParamValue(r *http.Request, key string) string
- func GetPathValue(r *http.Request, positions ...int) string
- func GetUserInput(r *http.Request) (val string)
- func LocateDir(dir string, maxTries int) (string, error)
- func MethodFromInput(in string) string
- func ParseViewTemplates() error
- func Register(r Route)
- func Reset()
- type ConstParams
- type HandlerFn
- type LogWrapper
- type Logger
- type Parameters
- type Route
- type RouteMap
- type Routes
- type Safety
- type SanitizerFn
- type Sink
- type VulnerableFnWrapper
Constants ¶
const INPUT = "input"
INPUT used as the standard input name across the project and forms
Variables ¶
var Templates = make(map[string]*template.Template)
Templates is the map we use to lookup the parsed templates based on filenames. It is intended for use for use by all frameworks supported by the bench.
var Verbose bool
Verbose increases the verbosity of logging.
Functions ¶
func FindViewsDir ¶
FindViewsDir looks for the views dir, which contains our html templates. It looks in the current dir and its parents.
func GetCookieValue ¶
GetCookieValue returns the input value for the given cookie
func GetFormValue ¶
GetFormValue returns the input value for the given key from the submitted form
func GetHeaderValue ¶
GetHeaderValue returns the input value from the given header
func GetParamValue ¶
GetParamValue returns the input value for the given key of a GET request query
func GetPathValue ¶
GetPathValue returns element(s) from the given position(s) in the url, joined with '/'. Negative positions are allowed and start at the right.
func GetUserInput ¶
GetUserInput returns the first value found in the request with the key 'input'.
If none are found, it tries for a header with key 'credentials', and finally the last element in the url.
the order of precedence when getting the result is:
- query parameter
- form value
- cookie value
- header value
- credentials header
func LocateDir ¶
LocateDir finds a dir with the given name and returns its path. The given name may contain a slash, i.e. 'cmd/go-swagger'.
func MethodFromInput ¶
MethodFromInput determines the http method from the input type.
func ParseViewTemplates ¶
func ParseViewTemplates() error
ParseViewTemplates is used to set up the template resources for use by std and go-swagger
Types ¶
type ConstParams ¶
ConstParams are the page parameters that will not change during a run. Currently only used with the standard lib.
type HandlerFn ¶
type HandlerFn func(safety Safety, payload string, opaque interface{}) (data, mime string, status int)
HandlerFn is a framework-agnostic function to handle a vulnerable endpoint. `opaque` can be set to some framework-specific struct - for example, gin.Context.
Prefer statuses 200 (success), 400 (generic, expected error), and 500 (generic, unexpected error).
If a HandlerFn returns empty data, drivers should not write any data to the response.
func GenericHandler ¶
GenericHandler returns a generic replacement for HandlerFn. It requires VulnerableFnWrapper and Sanitize to be set.
type LogWrapper ¶
type LogWrapper struct {
// contains filtered or unexported fields
}
LogWrapper wraps log.Logger to work with the above logger interface. Errorf() and Fatalf() are equivalent.
func (*LogWrapper) Errorf ¶
func (w *LogWrapper) Errorf(f string, va ...interface{})
Errorf implements Logger.
func (*LogWrapper) Fatalf ¶
func (w *LogWrapper) Fatalf(f string, va ...interface{})
Fatalf implements Logger.
func (*LogWrapper) Logf ¶
func (w *LogWrapper) Logf(f string, va ...interface{})
Logf implements Logger.
type Logger ¶
type Logger interface { Logf(f string, va ...interface{}) Errorf(f string, va ...interface{}) Fatalf(f string, va ...interface{}) }
Logger contains selected methods of testing.TB
func NewLogWrapper ¶
NewLogWrapper creates a wrapper around log.Logger conforming to Logger.
type Parameters ¶
type Parameters struct { Name string ConstParams }
Parameters includes ConstParams as well as anything page-specific. Currently only used with the standard lib.
type Route ¶
type Route struct { Name string // human-readable name Link string // owasp link Base string // short name, suitable for use in filename or URL - i.e. cmdInjection TmplFile string // name of template used for non-result page; default is Base + '.gohtml' Products []string // relevant Contrast products Inputs []string // input methods supported by this app: query, cookies, body, headers, headers-json, ... Sinks []*Sink // one per vulnerable function Payload string // must be set for the default template. // contains filtered or unexported fields }
Route is the template information for a specific route
func (*Route) UsesGenericTmpl ¶
UsesGenericTmpl returns true if the route uses the generic vulnerability template.
type RouteMap ¶
RouteMap is a map from base path to Route
func PopulateRouteMap ¶
PopulateRouteMap returns a RouteMap, for use in nav bar template.
type Routes ¶
type Routes []Route
Routes is a slice of Route
var AllRoutes Routes
AllRoutes contains all "new" (not in json) routes.
type Safety ¶
type Safety string
Safety indicates whether input to the vulnerable function will be sanitized or not, or if the vulnerable func will be bypassed entirely.
type Sink ¶
type Sink struct { Name string URL string // if nil, a generic handler is used and VulnerableFnWrapper and Sanitizer must // both be set Handler HandlerFn // a function that renders input safe; only used by the generic handler and only // when 'safe' mode is requested. // // for example: url.QueryEscape Sanitize SanitizerFn // the vulnerable function which may receive unsanitized input. Handler must be // nil when this is set. VulnerableFnWrapper VulnerableFnWrapper // the mime type used when VulnerableFnWrapper returns true for R1 (raw); // defaults to text/plain. RawMime string // http status that we expect to be returned for unsafe queries (used in testing) // defaults to http.StatusOK if unset ExpectedUnsafeStatus int }
Sink is a struct that identifies the name of the sink, the associated URL, and what handler/sanitizer to use.
func (*Sink) AddPayloadToRequest ¶
AddPayloadToRequest adds user controllable data to the request r. The data type can be configured with inputType. If inputType is not supported, the program exits. You can also specify the key and value of the data to be added to the request. If key is empty, "input" is used.
type VulnerableFnWrapper ¶
type VulnerableFnWrapper func(opaque interface{}, payload string) (data string, raw bool, err error)
VulnerableFnWrapper is a function wrapping something vulnerable. Used to adapt things for use with GenericHandler. 'raw' indicates data should be sent verbatim, not decorated.