enumeratejavascript

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 AttachPathParamExamples added in v0.35.0

func AttachPathParamExamples(endpoints []*Endpoint) []*Endpoint

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

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