discovery

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiscoveryResult

type DiscoveryResult struct {
	PageURL string         `json:"page_url"`
	Targets []UploadTarget `json:"targets"`
	Error   string         `json:"error,omitempty"`
}

DiscoveryResult holds all discovered upload targets from a page

type DiscoveryType

type DiscoveryType string

DiscoveryType indicates how the upload target was discovered

const (
	DiscoveryHTMLForm DiscoveryType = "HTML_FORM"
	DiscoveryManual   DiscoveryType = "MANUAL"
	DiscoveryAPI      DiscoveryType = "API"
)

type FileField

type FileField struct {
	Name     string   `json:"name"`
	Accept   []string `json:"accept,omitempty"`
	Multiple bool     `json:"multiple"`
}

FileField represents a file input field in an HTML form

type FormField

type FormField struct {
	Name  string `json:"name"`
	Value string `json:"value"`
	Type  string `json:"type"`
}

FormField represents a non-file form field

type HTMLFormParser

type HTMLFormParser struct {
	// contains filtered or unexported fields
}

HTMLFormParser parses HTML pages to discover upload forms

func NewHTMLFormParser

func NewHTMLFormParser(client *http.Client) *HTMLFormParser

NewHTMLFormParser creates a new HTML form parser

func (*HTMLFormParser) DiscoverFromHTML

func (p *HTMLFormParser) DiscoverFromHTML(htmlContent string, pageURL string, cookies []*http.Cookie) (*DiscoveryResult, error)

DiscoverFromHTML parses HTML content directly

func (*HTMLFormParser) DiscoverFromURL

func (p *HTMLFormParser) DiscoverFromURL(pageURL string, headers map[string]string) (*DiscoveryResult, error)

DiscoverFromURL fetches a URL and discovers upload forms

type RequestBuilder

type RequestBuilder struct {
	// contains filtered or unexported fields
}

RequestBuilder builds multipart upload requests from discovered targets

func NewRequestBuilder

func NewRequestBuilder(client *http.Client) *RequestBuilder

NewRequestBuilder creates a new request builder

func (*RequestBuilder) BuildRequest

func (rb *RequestBuilder) BuildRequest(target *UploadTarget, fileFieldName string, filename string, body []byte, contentType string) (*http.Request, error)

BuildRequest creates an HTTP request from an UploadTarget with a payload

func (*RequestBuilder) BuildRequestFromPayload

func (rb *RequestBuilder) BuildRequestFromPayload(target *UploadTarget, fileFieldName string, filename string, body []byte, contentType string, additionalFields map[string]string) (*http.Request, error)

BuildRequestFromPayload builds a request using a Payload-compatible interface

func (*RequestBuilder) DiscoverAndBuild

func (rb *RequestBuilder) DiscoverAndBuild(pageURL string, headers map[string]string, payload []byte, contentType string) ([]*http.Request, error)

DiscoverAndBuild discovers forms and builds requests for all file fields

type UploadTarget

type UploadTarget struct {
	PageURL       string            `json:"page_url"`
	ActionURL     string            `json:"action_url"`
	Method        string            `json:"method"`
	Enctype       string            `json:"enctype"`
	FileFields    []FileField       `json:"file_fields"`
	FormFields    []FormField       `json:"form_fields"`
	Headers       map[string]string `json:"headers"`
	Cookies       []*http.Cookie    `json:"-"`
	DiscoveryType DiscoveryType     `json:"discovery_type"`
}

UploadTarget represents a discovered file upload endpoint

func (*UploadTarget) FormData

func (ut *UploadTarget) FormData() map[string]string

FormData builds a map of form fields for multipart submission

func (*UploadTarget) GetFileField

func (ut *UploadTarget) GetFileField(name string) *FileField

GetFileField returns a file field by name

func (*UploadTarget) HasFileField

func (ut *UploadTarget) HasFileField(name string) bool

HasFileField checks if a specific file field exists

func (*UploadTarget) Validate

func (ut *UploadTarget) Validate() error

Validate checks if the upload target is usable

Jump to

Keyboard shortcuts

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