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 (*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.