Help us shape the future of Go! Take the 2026 Go Developer Survey

xpath

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: MIT Imports: 6 Imported by: 0

README

XPath Extractor Modifier (xp)

This plugin provides an XPath modifier for spelunk. It allows you to extract specific values from XML secrets.

Usage

package main

import (
	"context"
	"fmt"

	"github.com/detro/spelunk"
	"github.com/detro/spelunk/plugin/modifier/xpath"
)

func main() {
	s, _ := spelunk.NewSpelunker(xpath.WithXPath())
	
	// Assuming `plain://...` contains `<data><foo>bar</foo></data>`
	res, _ := s.DigUp(context.Background(), "plain://.../?xp=//foo")
	
	fmt.Println(res) // Outputs: bar
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrXPathFailed         = fmt.Errorf("failed to apply XPath")
	ErrXPathMatchingFailed = fmt.Errorf("failed to match XPath")
	ErrSecretNotXML        = fmt.Errorf("secret is not a valid XML")
)

Functions

func WithXPath

func WithXPath() spelunk.SpelunkerOption

WithXPath adds the XPath modifier to a Spelunker.

Types

type SecretModifierXPath

type SecretModifierXPath struct{}

SecretModifierXPath is a modifier that can extract a specific field out of an XML stored in a secret value. After the secret has been dug-up, the modifier digs further at the provided XPath, and returns the inner text found there.

func (*SecretModifierXPath) Modify

func (s *SecretModifierXPath) Modify(
	_ context.Context,
	secretValue string,
	mod string,
) (string, error)

func (*SecretModifierXPath) Type

func (s *SecretModifierXPath) Type() string

Directories

Path Synopsis
module

Jump to

Keyboard shortcuts

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