browser

package
v0.0.0-...-bf5dde6 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToNetworkHeaders

func ConvertToNetworkHeaders(headersMap map[string][]string) proto.NetworkHeaders

ConvertToNetworkHeaders converts map[string][]string to NetworkHeaders

func CreateHistoryFromHijack

func CreateHistoryFromHijack(request *rod.HijackRequest, response *rod.HijackResponse, source string, note string, workspaceID, taskID uint) *db.History

CreateHistoryFromHijack saves a history request from hijack request/response items.

func DumpHijackRequest

func DumpHijackRequest(req *rod.HijackRequest) (raw string, body string)

func DumpHijackResponse

func DumpHijackResponse(res *rod.HijackResponse) (rawResponse string, body string)

func GetBrowserLauncher

func GetBrowserLauncher() *launcher.Launcher

func Hijack

func Hijack(config HijackConfig, browser *rod.Browser, source string, resultsChannel chan HijackResult, workspaceID, taskID uint)

func HijackWithContext

func HijackWithContext(config HijackConfig, browser *rod.Browser, source string, resultsChannel chan HijackResult, ctx context.Context, workspaceID, taskID uint) *rod.HijackRouter

func ListenForPostMessages

func ListenForPostMessages(page *rod.Page) error

ListenForPostMessages executes JavaScript in the page to listen for post messages

func NewBrowser

func NewBrowser() *rod.Browser

func NewBrowserWithTimeout

func NewBrowserWithTimeout(timeoutDuration time.Duration) (*rod.Browser, error)

NewBrowserWithTimeout attempts to create a new browser instance with a specified timeout.

func ReplayRequestInBrowser

func ReplayRequestInBrowser(page *rod.Page, req *http.Request) error

ReplayRequestInBrowser takes a rod.Page and an http.Request, it loads the URL of the input request in the browser, but hijacks it and updates the headers, method, etc. to match the input request.

func ReplayRequestInBrowserAndCreateHistory

func ReplayRequestInBrowserAndCreateHistory(page *rod.Page, req *http.Request, workspaceID, taskID uint, note string) (history *db.History, err error)

Types

type BrowserGeolocation

type BrowserGeolocation struct {
	// Latitude (optional) Mock latitude
	Latitude float64 `json:"latitude,omitempty"`

	// Longitude (optional) Mock longitude
	Longitude float64 `json:"longitude,omitempty"`

	// Accuracy (optional) Mock accuracy
	Accuracy float64 `json:"accuracy,omitempty"`
}

BrowserGeolocation https://pkg.go.dev/github.com/go-rod/rod@v0.81.3/lib/proto#EmulationSetGeolocationOverride

type BrowserPoolManager

type BrowserPoolManager struct {
	HijackResultsChannel chan HijackResult
	// contains filtered or unexported fields
}

func GetScannerBrowserPoolManager

func GetScannerBrowserPoolManager() *BrowserPoolManager

GetBrowserPoolManager returns a singleton instance of BrowserPoolManager used by active scanners

func NewBrowserPoolManager

func NewBrowserPoolManager(config BrowserPoolManagerConfig, workspaceID, taskID uint) *BrowserPoolManager

func NewHijackedBrowserPoolManager

func NewHijackedBrowserPoolManager(config BrowserPoolManagerConfig, hijackResultsChannel chan HijackResult, workspaceID uint) *BrowserPoolManager

func (*BrowserPoolManager) Cleanup

func (b *BrowserPoolManager) Cleanup()

func (*BrowserPoolManager) NewBrowser

func (b *BrowserPoolManager) NewBrowser() *rod.Browser

func (*BrowserPoolManager) ReleaseBrowser

func (b *BrowserPoolManager) ReleaseBrowser(browser *rod.Browser)

func (*BrowserPoolManager) Start

func (b *BrowserPoolManager) Start()

type BrowserPoolManagerConfig

type BrowserPoolManagerConfig struct {
	PoolSize int
	Source   string
}

type EmulationConfig

type EmulationConfig struct {
	UserAgent           string
	OverrideGeolocation BrowserGeolocation
	Viewport            proto.EmulationSetDeviceMetricsOverride
}

type HijackConfig

type HijackConfig struct {
	AnalyzeJs   bool
	AnalyzeHTML bool
}

HijackConfig represents a hijack configuration to apply when using the browser

type HijackResult

type HijackResult struct {
	History        *db.History
	DiscoveredURLs []string
}

type PagePoolManager

type PagePoolManager struct {
	HijackResultsChannel chan HijackResult
	// contains filtered or unexported fields
}

func NewHijackedPagePoolManager

func NewHijackedPagePoolManager(config PagePoolManagerConfig, source string, hijackResultsChannel chan HijackResult, workspaceID, taskID uint) *PagePoolManager

func NewPagePoolManager

func NewPagePoolManager(config PagePoolManagerConfig, source string) *PagePoolManager

func (*PagePoolManager) Close

func (b *PagePoolManager) Close()

func (*PagePoolManager) NewPage

func (b *PagePoolManager) NewPage() *rod.Page

func (*PagePoolManager) ReleasePage

func (b *PagePoolManager) ReleasePage(page *rod.Page)

func (*PagePoolManager) Start

func (b *PagePoolManager) Start(hijack bool, source string)

type PagePoolManagerConfig

type PagePoolManagerConfig struct {
	PoolSize  int
	UserAgent string
}

type PostMessage

type PostMessage struct {
	Data      interface{} `json:"data"`
	Origin    string      `json:"origin"`
	Timestamp int64       `json:"timestamp"`
}

PostMessage represents the structure of a post message

func GetPostMessages

func GetPostMessages(page *rod.Page) ([]PostMessage, error)

GetPostMessages returns all post messages that have been sent to the page. NOTE: This function will only return messages that have been sent after ListenForPostMessages has been called.

Jump to

Keyboard shortcuts

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