parse

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package parse turns raw input (a file, stdin, or the environment) into a Blob: the original text plus a flattened key/value view and any structured form (JSON object, INI sections). Recognizers consume the Blob.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blob

type Blob struct {
	Raw     string
	File    string
	Kind    module.SourceKind
	ModTime time.Time         // source file mtime (zero if unknown: stdin/env/harvested)
	Vars    map[string]string // flattened key=value (env, dotenv, all INI keys)
	Lines   map[string]int    // 1-based source line per variable name (when known)
	JSON    map[string]any    // populated if the whole blob is a JSON object
	INI     []INISection

	// Fingerprint is an upstream scanner's stable id for this finding, carried
	// through untouched so that scanner's own viewer can dedupe geiger's output
	// against its own. Empty unless the blob came from such a report.
	Fingerprint string
}

Blob is the parsed view of one input source.

func FromEnv

func FromEnv(environ []string) Blob

FromEnv builds a Blob from a list of "KEY=VALUE" strings (os.Environ()).

func Parse

func Parse(raw, fileHint string) Blob

Parse detects the format of raw and returns a Blob. fileHint (a path or label) refines detection (e.g. ".npmrc", "credentials").

type INISection

type INISection struct {
	Name string
	Keys map[string]string
}

INISection is one [section] of an INI file with its keys.

Jump to

Keyboard shortcuts

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