mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-08-03 05:13:10 +00:00
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [github.com/ulikunitz/xz](https://github.com/ulikunitz/xz) | `v0.5.10` → `v0.5.15` |  |  | --- ### github.com/ulikunitz/xz leaks memory when decoding a corrupted multiple LZMA archives [CVE-2025-58058](https://nvd.nist.gov/vuln/detail/CVE-2025-58058) / [GHSA-jc7w-c686-c4v9](https://github.com/advisories/GHSA-jc7w-c686-c4v9) / [GO-2025-3922](https://pkg.go.dev/vuln/GO-2025-3922) <details> <summary>More information</summary> #### Details ##### Summary It is possible to put data in front of an LZMA-encoded byte stream without detecting the situation while reading the header. This can lead to increased memory consumption because the current implementation allocates the full decoding buffer directly after reading the header. The LZMA header doesn't include a magic number or has a checksum to detect such an issue according to the [specification](https://github.com/jljusten/LZMA-SDK/blob/master/DOC/lzma-specification.txt). Note that the code recognizes the issue later while reading the stream, but at this time the memory allocation has already been done. ##### Mitigations The release v0.5.15 includes following mitigations: - The ReaderConfig DictCap field is now interpreted as a limit for the dictionary size. - The default is 2 Gigabytes - 1 byte (2^31-1 bytes). - Users can check with the [Reader.Header] method what the actual values are in their LZMA files and set a smaller limit using ReaderConfig. - The dictionary size will not exceed the larger of the file size and the minimum dictionary size. This is another measure to prevent huge memory allocations for the dictionary. - The code supports stream sizes only up to a pebibyte (1024^5). Note that the original v0.5.14 version had a compiler error for 32 bit platforms, which has been fixed by v0.5.15. ##### Methods affected Only software that uses [lzma.NewReader](https://pkg.go.dev/github.com/ulikunitz/xz/lzma#NewReader) or [lzma.ReaderConfig.NewReader](https://pkg.go.dev/github.com/ulikunitz/xz/lzma#ReaderConfig.NewReader) is affected. There is no issue for software using the xz functionality. I thank @​GregoryBuligin for his report, which is provided below. ##### Summary When unpacking a large number of LZMA archives, even in a single goroutine, if the first byte of the archive file is 0 (a zero byte added to the beginning), an error __writeMatch: distance out of range__ occurs. Memory consumption spikes sharply, and the GC clearly cannot handle this situation. ##### Details Judging by the error __writeMatch: distance out of range__, the problems occur in the code around this function.c8314b8f21/lzma/decoderdict.go (L81)##### PoC Run a function similar to this one in 1 or several goroutines on a multitude of LZMA archives that have a 0 (a zero byte) added to the beginning. ``` const ProjectLocalPath = "some/path" const TmpDir = "tmp" func UnpackLZMA(lzmaFile string) error { file, err := os.Open(lzmaFile) if err != nil { return err } defer file.Close() reader, err := lzma.NewReader(bufio.NewReader(file)) if err != nil { return err } tmpFile, err := os.CreateTemp(TmpDir, TmpLZMAPrefix) if err != nil { return err } defer func() { tmpFile.Close() _ = os.Remove(tmpFile.Name()) }() sha256Hasher := sha256.New() multiWriter := io.MultiWriter(tmpFile, sha256Hasher) if _, err = io.Copy(multiWriter, reader); err != nil { return err } unpackHash := hex.EncodeToString(sha256Hasher.Sum(nil)) unpackDir := filepath.Join( ProjectLocalPath, unpackHash[:2], ) _ = os.MkdirAll(unpackDir, DirPerm) unpackPath := filepath.Join(unpackDir, unpackHash) return os.Rename(tmpFile.Name(), unpackPath) } ``` ##### Impact Servers with a small amount of RAM that download and unpack a large number of unverified LZMA archives #### Severity - CVSS Score: 5.3 / 10 (Medium) - Vector String: `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L` #### References - [https://github.com/ulikunitz/xz/security/advisories/GHSA-jc7w-c686-c4v9](https://github.com/ulikunitz/xz/security/advisories/GHSA-jc7w-c686-c4v9) - [https://nvd.nist.gov/vuln/detail/CVE-2025-58058](https://nvd.nist.gov/vuln/detail/CVE-2025-58058) - [88ddf1d0d9) - [https://github.com/ulikunitz/xz](https://github.com/ulikunitz/xz) This data is provided by [OSV](https://osv.dev/vulnerability/GHSA-jc7w-c686-c4v9) and the [GitHub Advisory Database](https://github.com/github/advisory-database) ([CC-BY 4.0](https://github.com/github/advisory-database/blob/main/LICENSE.md)). </details> --- ### Memory leaks when decoding a corrupted multiple LZMA archives in github.com/ulikunitz/xz [CVE-2025-58058](https://nvd.nist.gov/vuln/detail/CVE-2025-58058) / [GHSA-jc7w-c686-c4v9](https://github.com/advisories/GHSA-jc7w-c686-c4v9) / [GO-2025-3922](https://pkg.go.dev/vuln/GO-2025-3922) <details> <summary>More information</summary> #### Details Memory leaks when decoding a corrupted multiple LZMA archives in github.com/ulikunitz/xz #### Severity Unknown #### References - [https://github.com/ulikunitz/xz/security/advisories/GHSA-jc7w-c686-c4v9](https://github.com/ulikunitz/xz/security/advisories/GHSA-jc7w-c686-c4v9) - [88ddf1d0d9) This data is provided by [OSV](https://osv.dev/vulnerability/GO-2025-3922) and the [Go Vulnerability Database](https://github.com/golang/vulndb) ([CC-BY 4.0](https://github.com/golang/vulndb#license)). </details> --- ### Release Notes <details> <summary>ulikunitz/xz (github.com/ulikunitz/xz)</summary> ### [`v0.5.15`](https://github.com/ulikunitz/xz/compare/v0.5.14...v0.5.15) [Compare Source](https://github.com/ulikunitz/xz/compare/v0.5.14...v0.5.15) ### [`v0.5.14`](https://github.com/ulikunitz/xz/compare/v0.5.13...v0.5.14) [Compare Source](https://github.com/ulikunitz/xz/compare/v0.5.13...v0.5.14) ### [`v0.5.13`](https://github.com/ulikunitz/xz/compare/v0.5.12...v0.5.13) [Compare Source](https://github.com/ulikunitz/xz/compare/v0.5.12...v0.5.13) ### [`v0.5.12`](https://github.com/ulikunitz/xz/compare/v0.5.11...v0.5.12) [Compare Source](https://github.com/ulikunitz/xz/compare/v0.5.11...v0.5.12) ### [`v0.5.11`](https://github.com/ulikunitz/xz/compare/v0.5.10...v0.5.11) [Compare Source](https://github.com/ulikunitz/xz/compare/v0.5.10...v0.5.11) </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - "" - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xOTEuMiIsInVwZGF0ZWRJblZlciI6IjQzLjE5MS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Reviewed-on: https://gitea.com/gitea/runner/pulls/1127 Reviewed-by: silverwind <2021+silverwind@noreply.gitea.com> Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
237 lines
7.6 KiB
Makefile
237 lines
7.6 KiB
Makefile
DIST := dist
|
|
EXECUTABLE := gitea-runner
|
|
DIST_DIRS := $(DIST)/binaries $(DIST)/release
|
|
GO ?= go
|
|
SHASUM ?= shasum -a 256
|
|
HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
|
|
XGO_PACKAGE ?= src.techknowlogick.com/xgo@v1.9.0 # renovate: datasource=go
|
|
XGO_VERSION := go-1.26.x
|
|
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.15 # renovate: datasource=go
|
|
|
|
LINUX_ARCHS ?= linux/amd64,linux/arm64
|
|
DARWIN_ARCHS ?= darwin-12/amd64,darwin-12/arm64
|
|
WINDOWS_ARCHS ?= windows/amd64
|
|
GOFILES := $(shell find . -type f -name "*.go" -o -name "go.mod" ! -name "generated.*")
|
|
|
|
DOCKER_IMAGE ?= gitea/runner
|
|
DOCKER_TAG ?= nightly
|
|
DOCKER_REF := $(DOCKER_IMAGE):$(DOCKER_TAG)
|
|
DOCKER_ROOTLESS_REF := $(DOCKER_IMAGE):$(DOCKER_TAG)-dind-rootless
|
|
|
|
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2 # renovate: datasource=go
|
|
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1.3.0 # renovate: datasource=go
|
|
|
|
GOTEST_FLAGS ?= -race -timeout 20m -parallel 8
|
|
|
|
STATIC ?=
|
|
EXTLDFLAGS ?=
|
|
ifneq ($(STATIC),)
|
|
EXTLDFLAGS = -extldflags "-static"
|
|
endif
|
|
|
|
ifeq ($(HAS_GO), GO)
|
|
GOPATH ?= $(shell $(GO) env GOPATH)
|
|
export PATH := $(GOPATH)/bin:$(PATH)
|
|
|
|
CGO_EXTRA_CFLAGS := -DSQLITE_MAX_VARIABLE_NUMBER=32766
|
|
CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS) $(CGO_EXTRA_CFLAGS)
|
|
endif
|
|
|
|
ifeq ($(OS), Windows_NT)
|
|
GOFLAGS := -v -buildmode=exe
|
|
EXECUTABLE ?= $(EXECUTABLE).exe
|
|
GO_ENV_WINDOWS := set GOOS=windows&&
|
|
else ifeq ($(OS), Windows)
|
|
GOFLAGS := -v -buildmode=exe
|
|
EXECUTABLE ?= $(EXECUTABLE).exe
|
|
GO_ENV_WINDOWS := set GOOS=windows&&
|
|
else
|
|
GOFLAGS := -v
|
|
EXECUTABLE ?= $(EXECUTABLE)
|
|
GO_ENV_WINDOWS := GOOS=windows
|
|
endif
|
|
|
|
STORED_VERSION_FILE := VERSION
|
|
|
|
ifneq ($(DRONE_TAG),)
|
|
VERSION ?= $(subst v,,$(DRONE_TAG))
|
|
RELASE_VERSION ?= $(VERSION)
|
|
else
|
|
ifneq ($(DRONE_BRANCH),)
|
|
VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
|
|
else
|
|
VERSION ?= main
|
|
endif
|
|
|
|
STORED_VERSION=$(shell cat $(STORED_VERSION_FILE) 2>/dev/null)
|
|
ifneq ($(STORED_VERSION),)
|
|
RELASE_VERSION ?= $(STORED_VERSION)
|
|
else
|
|
RELASE_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
|
|
endif
|
|
endif
|
|
|
|
TAGS ?=
|
|
LDFLAGS ?= -X "gitea.com/gitea/runner/internal/pkg/ver.version=v$(RELASE_VERSION)"
|
|
|
|
.PHONY: all
|
|
all: build
|
|
|
|
.PHONY: help
|
|
help: Makefile ## print Makefile help information.
|
|
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m[TARGETS] default target: build\033[0m\n\n\033[35mTargets:\033[0m\n"} /^[0-9A-Za-z._-]+:.*?##/ { printf " \033[36m%-45s\033[0m %s\n", $$1, $$2 }' Makefile
|
|
|
|
.PHONY: fmt
|
|
fmt: ## format the Go code
|
|
$(GO) run $(GOLANGCI_LINT_PACKAGE) fmt
|
|
|
|
.PHONY: go-check
|
|
go-check:
|
|
$(eval MIN_GO_VERSION_STR := $(shell grep -Eo '^go\s+[0-9]+\.[0-9]+' go.mod | cut -d' ' -f2))
|
|
$(eval MIN_GO_VERSION := $(shell printf "%03d%03d" $(shell echo '$(MIN_GO_VERSION_STR)' | tr '.' ' ')))
|
|
$(eval GO_VERSION := $(shell printf "%03d%03d" $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9]+' | tr '.' ' ');))
|
|
@if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \
|
|
echo "Gitea Runner requires Go $(MIN_GO_VERSION_STR) or greater to build. You can get it at https://go.dev/dl/"; \
|
|
exit 1; \
|
|
fi
|
|
|
|
.PHONY: fmt-check
|
|
fmt-check: fmt
|
|
@diff=$$(git diff --color=always -- '*.go'); \
|
|
if [ -n "$$diff" ]; then \
|
|
echo "Please run 'make fmt' and commit the result:"; \
|
|
printf "%s" "$${diff}"; \
|
|
exit 1; \
|
|
fi
|
|
|
|
.PHONY: deps-tools
|
|
deps-tools: ## install tool dependencies
|
|
$(GO) install $(GOLANGCI_LINT_PACKAGE) & \
|
|
$(GO) install $(GXZ_PACKAGE) & \
|
|
$(GO) install $(XGO_PACKAGE) & \
|
|
$(GO) install $(GOVULNCHECK_PACKAGE) & \
|
|
wait
|
|
|
|
.PHONY: checks
|
|
checks: tidy-check fmt-check security-check ## run the non-lint source checks
|
|
|
|
.PHONY: lint
|
|
lint: lint-go lint-go-windows ## lint everything
|
|
|
|
.PHONY: lint-go
|
|
lint-go: ## lint go files
|
|
$(GO) run $(GOLANGCI_LINT_PACKAGE) run
|
|
|
|
.PHONY: lint-go-windows
|
|
lint-go-windows: ## lint Windows go files
|
|
$(GO) install $(GOLANGCI_LINT_PACKAGE)
|
|
$(GO_ENV_WINDOWS) golangci-lint run
|
|
|
|
.PHONY: lint-go-fix
|
|
lint-go-fix: ## lint go files and fix issues
|
|
$(GO) run $(GOLANGCI_LINT_PACKAGE) run --fix
|
|
|
|
.PHONY: lint-pr-title
|
|
lint-pr-title: ## lint PR title against Conventional Commits (set PR_TITLE=...)
|
|
@node ./tools/lint-pr-title.ts
|
|
|
|
.PHONY: security-check
|
|
security-check:
|
|
GOEXPERIMENT= $(GO) run $(GOVULNCHECK_PACKAGE) -show color ./... || true
|
|
|
|
.PHONY: tidy
|
|
tidy: ## run go mod tidy
|
|
$(GO) mod tidy
|
|
|
|
.PHONY: tidy-check
|
|
tidy-check: tidy
|
|
@diff=$$(git diff --color=always -- go.mod go.sum); \
|
|
if [ -n "$$diff" ]; then \
|
|
echo "Please run 'make tidy' and commit the result:"; \
|
|
printf "%s" "$${diff}"; \
|
|
exit 1; \
|
|
fi
|
|
|
|
.PHONY: test
|
|
test: ## test everything (integration tests self-skip without docker/network)
|
|
@$(GO) test $(GOTEST_FLAGS) -cover -coverprofile coverage.txt ./... && echo "\n==>\033[32m Ok\033[m\n" || exit 1
|
|
|
|
.PHONY: coverage-report
|
|
coverage-report: ## turn coverage.txt from `make test` into .tmp/coverage.md
|
|
@mkdir -p .tmp
|
|
@node ./tools/coverage-report.ts -i coverage.txt -o .tmp/coverage.md
|
|
@echo "Wrote .tmp/coverage.md"
|
|
|
|
.PHONY: test-dind
|
|
test-dind: ## run the daemon-facing tests against the built dind image (TARGET=dind|dind-rootless)
|
|
@./scripts/test-dind.sh $(TARGET)
|
|
|
|
.PHONY: install
|
|
install: $(GOFILES) ## install the runner binary via `go install`
|
|
$(GO) install -v -tags '$(TAGS)' -ldflags '-s -w $(EXTLDFLAGS) $(LDFLAGS)'
|
|
|
|
.PHONY: build
|
|
build: go-check $(EXECUTABLE) ## build the runner binary
|
|
|
|
$(EXECUTABLE): $(GOFILES)
|
|
$(GO) build -v -tags '$(TAGS)' -ldflags '-s -w $(EXTLDFLAGS) $(LDFLAGS)' -o $@
|
|
|
|
.PHONY: deps-backend
|
|
deps-backend: ## install backend dependencies
|
|
$(GO) mod download
|
|
|
|
.PHONY: release
|
|
release: release-windows release-linux release-darwin release-copy release-compress release-check ## build release artifacts
|
|
|
|
$(DIST_DIRS):
|
|
mkdir -p $(DIST_DIRS)
|
|
|
|
.PHONY: release-windows
|
|
release-windows: | $(DIST_DIRS)
|
|
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-s -w -linkmode external -extldflags "-static" $(LDFLAGS)' -targets '$(WINDOWS_ARCHS)' -out $(EXECUTABLE)-$(VERSION) .
|
|
ifeq ($(CI),true)
|
|
cp -r /build/* $(DIST)/binaries/
|
|
endif
|
|
|
|
.PHONY: release-linux
|
|
release-linux: | $(DIST_DIRS)
|
|
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-s -w -linkmode external -extldflags "-static" $(LDFLAGS)' -targets '$(LINUX_ARCHS)' -out $(EXECUTABLE)-$(VERSION) .
|
|
ifeq ($(CI),true)
|
|
cp -r /build/* $(DIST)/binaries/
|
|
endif
|
|
|
|
.PHONY: release-darwin
|
|
release-darwin: | $(DIST_DIRS)
|
|
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-s -w $(LDFLAGS)' -targets '$(DARWIN_ARCHS)' -out $(EXECUTABLE)-$(VERSION) .
|
|
ifeq ($(CI),true)
|
|
cp -r /build/* $(DIST)/binaries/
|
|
endif
|
|
|
|
.PHONY: release-copy
|
|
release-copy: | $(DIST_DIRS)
|
|
cd $(DIST); for file in `find . -type f -name "*"`; do cp $${file} ./release/; done;
|
|
|
|
.PHONY: release-check
|
|
release-check: | $(DIST_DIRS)
|
|
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "checksumming $${file}" && $(SHASUM) `echo $${file} | sed 's/^..//'` > $${file}.sha256; done;
|
|
|
|
.PHONY: release-compress
|
|
release-compress: | $(DIST_DIRS)
|
|
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && $(GO) run $(GXZ_PACKAGE) -k -9 $${file}; done;
|
|
|
|
.PHONY: docker
|
|
docker: ## build the docker image
|
|
if ! docker buildx version >/dev/null 2>&1; then \
|
|
ARG_DISABLE_CONTENT_TRUST=--disable-content-trust=false; \
|
|
fi; \
|
|
docker build $${ARG_DISABLE_CONTENT_TRUST} -t $(DOCKER_REF) .
|
|
|
|
.PHONY: clean
|
|
clean: ## delete binary and coverage files
|
|
$(GO) clean -x -i ./...
|
|
rm -rf coverage.txt .tmp $(EXECUTABLE) $(DIST)
|
|
|
|
.PHONY: version
|
|
version: ## print the version
|
|
@echo $(VERSION)
|