mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-27 19:54:24 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83d9cd684c | ||
|
|
8d1f98c796 | ||
|
|
ca20267a84 | ||
|
|
b66ac75e4f |
No files matched your search
@@ -20,7 +20,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.25
|
||||
go-version: 1.24
|
||||
|
||||
- name: Build
|
||||
run: go build ./...
|
||||
|
||||
+16
-5
@@ -1,3 +1,5 @@
|
||||
version: 2
|
||||
|
||||
project_name: gitleaks
|
||||
|
||||
builds:
|
||||
@@ -15,17 +17,26 @@ builds:
|
||||
goarm:
|
||||
- "6"
|
||||
- "7"
|
||||
ignore:
|
||||
- goos: windows
|
||||
goarch: arm
|
||||
tags:
|
||||
- gore2regex
|
||||
ldflags:
|
||||
- -s -w -X=github.com/zricethezav/gitleaks/v8/version.Version={{.Version}}
|
||||
archives:
|
||||
- builds: [gitleaks]
|
||||
- ids: [gitleaks]
|
||||
name_template: >-
|
||||
{{ .ProjectName }}_
|
||||
{{- .Version }}_
|
||||
{{- .Os }}_
|
||||
{{- if eq .Arch "amd64" }}x64
|
||||
{{- else if eq .Arch "386" }}x32
|
||||
{{- else }}{{ .Arch }}{{ end }}
|
||||
{{- with .Arm }}v{{ . }}{{ end }}
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
format: zip
|
||||
replacements:
|
||||
amd64: x64
|
||||
386: x32
|
||||
formats: [zip]
|
||||
release:
|
||||
prerelease: true
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
FROM golang:1.25 AS build
|
||||
FROM golang:1.24 AS build
|
||||
WORKDIR /go/src/github.com/zricethezav/gitleaks
|
||||
COPY . .
|
||||
RUN VERSION=$(git describe --tags --abbrev=0) && \
|
||||
|
||||
@@ -3,8 +3,9 @@ package codec
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -2,10 +2,11 @@ package codec
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module github.com/zricethezav/gitleaks/v8
|
||||
|
||||
go 1.25.4
|
||||
go 1.24.11
|
||||
|
||||
require (
|
||||
github.com/BobuSumisu/aho-corasick v1.0.3
|
||||
|
||||
+7
-1
@@ -29,7 +29,13 @@ func NewTemplateReporter(templatePath string) (*TemplateReporter, error) {
|
||||
|
||||
// TODO: Add helper functions like escaping for JSON, XML, etc.
|
||||
t := template.New("custom")
|
||||
t = t.Funcs(sprig.TxtFuncMap())
|
||||
|
||||
funcMap := sprig.TxtFuncMap()
|
||||
delete(funcMap, "env")
|
||||
delete(funcMap, "expandenv")
|
||||
delete(funcMap, "getHostByName")
|
||||
|
||||
t = t.Funcs(funcMap)
|
||||
t, err = t.Parse(templateText)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error parsing file: %w", err)
|
||||
|
||||
@@ -96,3 +96,52 @@ func TestWriteTemplate(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestTemplateDangerousFunctions(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
template string
|
||||
wantErr string
|
||||
}{
|
||||
{
|
||||
name: "env is blocked",
|
||||
template: `{{ env "SECRET" }}`,
|
||||
wantErr: `function "env" not defined`,
|
||||
},
|
||||
{
|
||||
name: "expandenv is blocked",
|
||||
template: `{{ expandenv "$SECRET" }}`,
|
||||
wantErr: `function "expandenv" not defined`,
|
||||
},
|
||||
{
|
||||
name: "getHostByName is blocked",
|
||||
template: `{{ getHostByName "localhost" }}`,
|
||||
wantErr: `function "getHostByName" not defined`,
|
||||
},
|
||||
{
|
||||
name: "now is allowed (benign)",
|
||||
template: `{{ now | date "2006-01-02" }}`,
|
||||
wantErr: "", // should not error on parse
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tmpfile, err := os.CreateTemp(t.TempDir(), "test*.tmpl")
|
||||
require.NoError(t, err)
|
||||
defer os.Remove(tmpfile.Name())
|
||||
|
||||
_, err = tmpfile.WriteString(tt.template)
|
||||
require.NoError(t, err)
|
||||
tmpfile.Close()
|
||||
|
||||
_, err = NewTemplateReporter(tmpfile.Name())
|
||||
if tt.wantErr != "" {
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), tt.wantErr)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user