enumeratejavascript

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultWindowBytes = 256 * 1024

DefaultWindowBytes 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.

View Source
const DefaultWindowOverlapBytes = 64 * 1024

DefaultWindowOverlapBytes keeps a call split by a window boundary visible to one of the windows.

View Source
const MaxQueryParamValueBytes = 256

MaxQueryParamValueBytes keeps embedded payload-like examples from bloating a JavaScript endpoint record.

Variables

This section is empty.

Functions

func BaseCandidatesInScope

func BaseCandidatesInScope(candidates []string, targetHosts []string, ignoreCrossDomain bool) []string

BaseCandidatesInScope keeps only the origins belonging to an analyzed host or a subdomain of one.

func CredentialMatcher

func CredentialMatcher() jsluice.SecretMatcher

CredentialMatcher reports configuration assignments whose key names a credential and whose value is opaque.

jsluice 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.

func ExtractPublicPath

func ExtractPublicPath(content string) string

ExtractPublicPath returns the webpack publicPath a runtime bundle configures, if any.

func ExtractScriptReferences

func ExtractScriptReferences(html string, pageURL string) []string

ExtractScriptReferences returns the JavaScript a page loads, in document order.

Only 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.

func ExtractViteChunkNames

func ExtractViteChunkNames(content string) []string

ExtractViteChunkNames returns asset-directory JavaScript paths referenced as string literals.

func ExtractWebpackChunkNames

func ExtractWebpackChunkNames(content string) []string

ExtractWebpackChunkNames returns the file name webpack builds for every chunk its runtime declares.

func LooksLikeHTML

func LooksLikeHTML(body string, contentType string) bool

LooksLikeHTML reports a body an HTML parser should read rather than a JavaScript analyzer.

func SortedUnique

func SortedUnique(values []string) []string

SortedUnique returns the unique values of a slice in a stable order.

Types

type Analysis

type Analysis struct {
	Endpoints []*Endpoint
	Secrets   []*enumerate.JavascriptSecret
	Origins   []string
}

Analysis is everything one JavaScript artifact yielded.

func AnalyzeSource

func AnalyzeSource(source []byte, sourceURL string, windowBytes int, overlapBytes int) Analysis

AnalyzeSource extracts endpoints, secrets and origins from one artifact's source.

type Endpoint added in v0.27.1

type Endpoint struct {
	Details *enumerate.JavascriptEndpoint
	BaseURL string
	Rooted  bool
}

Endpoint 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.

func RootEndpoints

func RootEndpoints(endpoints []*Endpoint, baseCandidates []string, preferHosts []string) []*Endpoint

RootEndpoints resolves relative endpoint literals against the API base the bundle configures.

A 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.

func (*Endpoint) Clone added in v0.27.1

func (e *Endpoint) Clone() *Endpoint

Clone copies an endpoint so an artifact shared by two applications roots once per application.

Jump to

Keyboard shortcuts

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