curlparse

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BrowserNoiseHeaders = []string{
	headerSecChUA, headerSecChUA + "-mobile", headerSecChUA + "-platform",
	"sec-fetch-dest", "sec-fetch-mode", "sec-fetch-site",
	"sentry-trace", "baggage",
	"priority",
}

BrowserNoiseHeaders are headers added by browsers, not needed for API calls.

View Source
var OptionalHeaders = []string{
	"user-agent",
	"referer",
	"origin",
	"accept-language",
	"accept-encoding",
}

OptionalHeaders are browser-specific headers that are usually not needed for API calls.

View Source
var SecretCookiePatterns = []string{
	"session", "sess", "sid", "token",
	"auth", "csrf", "xsrf", "jwt",
	"login", "password", "key", "secret",
}

SecretCookiePatterns are substrings that indicate a secret cookie name.

View Source
var SecretHeaderPrefixes = []string{
	"authorization",
	"proxy-authorization",
	"x-api-key", "api-key",
	"x-auth",
	"x-access-token",
	"cookie",
	"x-csrf-token", "x-xsrf-token",
}

SecretHeaderPrefixes are case-insensitive prefixes for secret headers.

Functions

func CleanHeaders

func CleanHeaders(r *Result)

CleanHeaders removes browser noise headers.

func IsBrowserNoise

func IsBrowserNoise(name string) bool

IsBrowserNoise returns true if name matches BrowserNoiseHeaders (case-insensitive prefix).

func IsOptionalHeader

func IsOptionalHeader(name string) bool

IsOptionalHeader returns true if name matches OptionalHeaders (case-insensitive).

func IsSecretCookie

func IsSecretCookie(name, value string) bool

IsSecretCookie returns true if cookie name matches SecretCookiePatterns or value looks like a token.

func IsSecretHeader

func IsSecretHeader(name string) bool

IsSecretHeader returns true if name matches any SecretHeaderPrefixes (case-insensitive prefix).

func MaskValue

func MaskValue(v string) string

MaskValue returns a masked version of a secret value for display.

Types

type Cookie struct {
	Name     string
	Value    string
	Secret   bool
	Selected bool
}

Cookie is a single cookie from -b or -H Cookie:.

type Header struct {
	Name     string
	Value    string
	Secret   bool
	Noise    bool
	Selected bool
}

Header is a single -H value classified by type.

type Result

type Result struct {
	URL     string
	Host    string
	Headers []Header
	Cookies []Cookie
	Args    []string // remaining curl args (-X, -d, -o, -v, etc.)
}

Result holds the result of parsing a curl command line.

func Parse

func Parse(args []string) *Result

Parse parses curl command-line arguments into structured form. Leading "curl" word is stripped if present.

Jump to

Keyboard shortcuts

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