{"modulePath":"github.com/Method-Security/webscan","version":"v0.41.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package enumeratejavascript\n\n## Constants\n\n```go\nconst DefaultWindowBytes = 256 * 1024\n```\nDefaultWindowBytes bounds one parse. tree-sitter recovers poorly on multi-megabyte minified bundles and silently yields nothing, so source is analyzed in windows rather than whole.\n\n```go\nconst DefaultWindowOverlapBytes = 64 * 1024\n```\nDefaultWindowOverlapBytes keeps a call split by a window boundary visible to one of the windows.\n\n```go\nconst MaxQueryParamValueBytes = 256\n```\nMaxQueryParamValueBytes keeps embedded payload-like examples from bloating a JavaScript endpoint record.\n\n## Functions\n\n```go\nfunc BaseCandidatesInScope(candidates []string, targetHosts []string, ignoreCrossDomain bool) []string\n```\nBaseCandidatesInScope keeps only the origins belonging to an analyzed host or a subdomain of one.\n\n```go\nfunc CredentialMatcher() jsluice.SecretMatcher\n```\nCredentialMatcher reports configuration assignments whose key names a credential and whose value is opaque.\n\njsluice ships matchers for credentials with a recognisable shape — an AWS key, a GCP key, a JWT. A platform key is just an opaque string, so it is identifiable only by the name it is assigned to, and those names live in configs/enumerate/javascript/credential\\_keys.json.\n\n```go\nfunc ExtractPublicPath(content string) string\n```\nExtractPublicPath returns the webpack publicPath a runtime bundle configures, if any.\n\n```go\nfunc ExtractScriptReferences(html string, pageURL string) []string\n```\nExtractScriptReferences returns the JavaScript a page loads, in document order.\n\nOnly the bundles the document itself declares are returned. A lazily-loaded chunk is never a script tag — the bundler injects it at runtime and removes the element once it has loaded — so reaching those is the chunk manifest's job, not this one.\n\n```go\nfunc ExtractViteChunkNames(content string) []string\n```\nExtractViteChunkNames returns asset-directory JavaScript paths referenced as string literals.\n\n```go\nfunc ExtractWebpackChunkNames(content string) []string\n```\nExtractWebpackChunkNames returns the file name webpack builds for every chunk its runtime declares.\n\n```go\nfunc LooksLikeHTML(body string, contentType string) bool\n```\nLooksLikeHTML reports a body an HTML parser should read rather than a JavaScript analyzer.\n\n```go\nfunc SortedUnique(values []string) []string\n```\nSortedUnique returns the unique values of a slice in a stable order.\n\n## Types\n\n```go\ntype Analysis struct {\n\tEndpoints []*Endpoint\n\tSecrets   []*enumerate.JavascriptSecret\n\tOrigins   []string\n}\n```\nAnalysis is everything one JavaScript artifact yielded.\n\n```go\nfunc AnalyzeSource(source []byte, sourceURL string, windowBytes int, overlapBytes int) Analysis\n```\nAnalyzeSource extracts endpoints, secrets and origins from one artifact's source.\n\n```go\ntype Endpoint struct {\n\tDetails *enumerate.JavascriptEndpoint\n\tBaseURL string\n\tRooted  bool\n}\n```\nEndpoint is an extracted endpoint, the origin serving it and whether that origin is established. Both are stages of the extraction: the origin is reported as the application the endpoint sits under, and rooted is not reported at all.\n\n```go\nfunc AttachPathParamExamples(endpoints []*Endpoint) []*Endpoint\n```\nAttachPathParamExamples adds concrete values to templates already present in the extracted endpoints. It never invents a template from sibling literals, because doing that merges distinct pages as readily as it finds identifiers.\n\n```go\nfunc RootEndpoints(endpoints []*Endpoint, baseCandidates []string, preferHosts []string) []*Endpoint\n```\nRootEndpoints resolves relative endpoint literals against the API base the bundle configures.\n\nA bundle states its base once, as configuration, and then concatenates bare paths onto it. Left alone the two never meet: the literal \\`general/DeleteFile\\` is not a path the origin serves, and the base alone names no endpoint.\n\n```go\nfunc (e *Endpoint) Clone() *Endpoint\n```\nClone copies an endpoint so an artifact shared by two applications roots once per application.\n\n","path":"github.com/Method-Security/webscan/internal/enumerate/javascript/helpers","name":"enumeratejavascript","synopsis":"","isRedistributable":true}
