codec

package
v0.163.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 8 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

Overview

Package codec decodes base64, hex, percent, and unicode escapes in place so the rules can run on the decoded text, and maps decoded matches back to their location in the original text.

It is copied from detect/codec in gitleaks v8.30.1 (MIT License, see ../LICENSE-gitleaks) so gk reports the decoded secrets gitleaks reports. Changes: the standard regexp package replaces the gitleaks regexp wrapper, debug logging is removed, the test uses the standard testing package, and EncodedSegment.DecodedRange exposes where a segment sits in its pass.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdjustMatchIndex

func AdjustMatchIndex(segments []*EncodedSegment, matchIndex []int) []int

AdjustMatchIndex maps a match index from the current decode pass back to its location in the original text

func CurrentLine

func CurrentLine(segments []*EncodedSegment, currentRaw string) string

CurrentLine returns from the start of the line containing the segments to the end of the line where the segment ends.

func Tags

func Tags(segments []*EncodedSegment) []string

Tags returns additional meta data tags related to the types of segments

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder decodes various types of data in place

func NewDecoder

func NewDecoder() *Decoder

NewDecoder creates a default decoder struct

func (*Decoder) Decode

func (d *Decoder) Decode(data string, predecessors []*EncodedSegment) (string, []*EncodedSegment)

Decode returns the data with the values decoded in place along with the encoded segment meta data for the next pass of decoding

type EncodedSegment

type EncodedSegment struct {
	// contains filtered or unexported fields
}

EncodedSegment represents a portion of text that is encoded in some way.

func SegmentsWithDecodedOverlap

func SegmentsWithDecodedOverlap(segments []*EncodedSegment, start, end int) []*EncodedSegment

SegmentsWithDecodedOverlap the segments where the start and end overlap its decoded range

func (*EncodedSegment) DecodedRange

func (s *EncodedSegment) DecodedRange() (start, end int)

DecodedRange returns where the segment's decoded value sits in the text of its decoding pass.

Jump to

Keyboard shortcuts

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