mocksy

package
v0.0.0-...-7fb543b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2017 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToHistory

func AddToHistory(itm Item)

AddToHistory inserts a pair request-response in the responseHistory.

func ClearHistory

func ClearHistory()

func HistoryLength

func HistoryLength() int

HistoryLength returns the number of entries in history

func LoadResponseHistory

func LoadResponseHistory(dir string) error

LoadResponseHistory loads all XML files found in `histDir` into the matcher's history. It does NOT clear the current history (use `ClearHistory()` for that). It does NOT recurse on the directory. In case of errors, it tries to load as much files as possible and reports the error afterwards.

func LoadResponsesFrom

func LoadResponsesFrom(source io.ReadSeeker) error

LoadResponseFrom decodes an XML source and loads all req-resp pairs in the matcher's responseHistory.

func Main

func Main(_ ...string)

func SetHistDir

func SetHistDir(dir string)

SetHistDir changes the value of the history load directory. Calling `LoadResponseHistory` after this will load all the XML files found in the given directory.

func StartServer

func StartServer(port string) error

StartServer loads the response history from `histDir` and starts the Mocksy server on given `port`

Types

type Host

type Host struct {
	Ip    string `xml:"ip,attr"`
	Value string `xml:",chardata"`
}

Host is used to deserialize burp saved XML. It contains text data and an attribute "ip".

type Item

type Item struct {
	Time           string   `xml:"time"`
	Url            string   `xml:"url"`
	Request        Request  `xml:"request"`
	Host           Host     `xml:"host"`
	Port           string   `xml:"port"`
	Protocol       string   `xml:"protocol"`
	Method         string   `xml:"method"`
	Path           string   `xml:"path"`
	Extension      string   `xml:"extension"`
	Status         string   `xml:"status"`
	ResponseLength string   `xml:"responselength"`
	Response       Response `xml:"response"`
	Mimetype       string   `xml:"mimetype"`
	Comment        string   `xml:"comment"`
}

Item is used to deserialize burp saved XML. It is the element containing all the information about a single request.

type Items

type Items struct {
	Items []Item `xml:"item"`
}

Items is used to deserialize burp saved XML. It is the root element, containing a list of Item's.

func BurpImport

func BurpImport(r io.Reader) (*Items, error)

BurpImport reads a "saved requests" file from r both in base64 and cleartext form

type Request

type Request struct {
	Base64 string `xml:"base64,attr"`
	Value  []byte `xml:",chardata"`
}

Response is struct used to deserialize burp XML. It contains text data and an attribute telling if the content is base64 or not.

func (Request) Bytes

func (r Request) Bytes() []byte

Bytes returns the []byte read by the XML decoder

type Response

type Response struct {
	Base64 string `xml:"base64,attr"`
	Value  []byte `xml:",chardata"`
}

Response is struct used to deserialize burp XML. It contains text data and an attribute telling if the content is base64 or not.

func FindMatching

func FindMatching(req *http.Request) Response

FindMatching takes an http request and returns the closest match to it based on the response history.

func (Response) Bytes

func (r Response) Bytes() []byte

Bytes returns the []byte read by the XML decoder

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL