enumeratejavascript

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 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.

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 RootEndpoints

func RootEndpoints(endpoints []*enumerate.JavascriptEndpoint, baseCandidates []string, preferHosts []string) []*enumerate.JavascriptEndpoint

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 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 []*enumerate.JavascriptEndpoint
	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.

Jump to

Keyboard shortcuts

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