mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 12:44:22 +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
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.25
|
go-version: 1.24
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: go build ./...
|
run: go build ./...
|
||||||
|
|||||||
+16
-5
@@ -1,3 +1,5 @@
|
|||||||
|
version: 2
|
||||||
|
|
||||||
project_name: gitleaks
|
project_name: gitleaks
|
||||||
|
|
||||||
builds:
|
builds:
|
||||||
@@ -15,17 +17,26 @@ builds:
|
|||||||
goarm:
|
goarm:
|
||||||
- "6"
|
- "6"
|
||||||
- "7"
|
- "7"
|
||||||
|
ignore:
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm
|
||||||
tags:
|
tags:
|
||||||
- gore2regex
|
- gore2regex
|
||||||
ldflags:
|
ldflags:
|
||||||
- -s -w -X=github.com/zricethezav/gitleaks/v8/version.Version={{.Version}}
|
- -s -w -X=github.com/zricethezav/gitleaks/v8/version.Version={{.Version}}
|
||||||
archives:
|
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:
|
format_overrides:
|
||||||
- goos: windows
|
- goos: windows
|
||||||
format: zip
|
formats: [zip]
|
||||||
replacements:
|
|
||||||
amd64: x64
|
|
||||||
386: x32
|
|
||||||
release:
|
release:
|
||||||
prerelease: true
|
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
|
WORKDIR /go/src/github.com/zricethezav/gitleaks
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN VERSION=$(git describe --tags --abbrev=0) && \
|
RUN VERSION=$(git describe --tags --abbrev=0) && \
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package codec
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"regexp"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -2,10 +2,11 @@ package codec
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"regexp"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module github.com/zricethezav/gitleaks/v8
|
module github.com/zricethezav/gitleaks/v8
|
||||||
|
|
||||||
go 1.25.4
|
go 1.24.11
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/BobuSumisu/aho-corasick v1.0.3
|
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.
|
// TODO: Add helper functions like escaping for JSON, XML, etc.
|
||||||
t := template.New("custom")
|
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)
|
t, err = t.Parse(templateText)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error parsing file: %w", err)
|
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