Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 132 additions & 11 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,148 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"],
"extends": [
"config:best-practices",
":gitSignOff",
":rebaseStalePrs",
"docker:disableMajor",
"default:pinDigestsDisabled",
"helpers:pinGitHubActionDigests"
],
"labels": [
"kind/dependency upgrade"
],
"baseBranchPatterns": ["main", "/^release-.*/"],
"constraints": {
"go": "1.26"
},
"postUpdateOptions": [
"gomodTidy"
],
"packageRules": [
{
"description": "Disable all updates on release branches by default",
"description": "Disable major updates on release branches",
"matchBaseBranches": ["/^release-.*/"],
"matchUpdateTypes": ["major"],
"enabled": false
},
{
"description": "Re-enable only patch updates on release branches",
"matchBaseBranches": ["/^release-.*/"],
"matchUpdateTypes": ["patch"],
"enabled": true
"enabled": false,
"groupName": "all minor dependencies",
"groupSlug": "all-minor",
"matchPackageNames": [
"*"
],
"matchUpdateTypes": [
"minor"
]
},
{
"description": "Re-enable digest updates for container images on release branches",
"matchBaseBranches": ["/^release-.*/"],
"matchManagers": ["dockerfile"],
"matchUpdateTypes": ["digest"],
"enabled": true
"groupName": "all patch dependencies",
"groupSlug": "all-patch",
"matchPackageNames": [
"*"
],
"matchUpdateTypes": [
"patch"
]
},
{
"description": "Do NOT generate PRs to pin or apply digests to dockerfiles",
"enabled": false,
"matchDatasources": [
"docker"
],
"matchUpdateTypes": [
"pin",
"pinDigest",
"digest"
],
"automerge": false
},
{
"description": "Do generate PRs for minor dockerfile updates",
"enabled": true,
"matchDatasources": [
"docker"
],
"matchUpdateTypes": [
"minor"
],
"matchBaseBranches": [
"main",
"/^release-\\d+\\..*/"
],
Comment thread
rm3l marked this conversation as resolved.
Resolved
"automerge": false
},
{
"description": "Do automerge patch updates to dockerfiles",
"enabled": true,
"matchDatasources": [
"docker"
],
"matchUpdateTypes": [
"patch"
],
"additionalBranchPrefix": "dockerfile ",
"groupName": "All dockerfile images",
"automerge": true,
"pinDigests": false
},
{
"description": "Do NOT generate PRs for major go dependency updates",
"enabled": false,
"matchDatasources": [
"go"
],
"matchUpdateTypes": [
"major"
],
"automerge": false
},
{
"description": "Do automerge go dependency patch updates, except for versions starting with 0",
"enabled": true,
"matchDatasources": [
"go"
],
"matchUpdateTypes": [
"patch"
],
"matchCurrentVersion": "!/^0/",
"automerge": true
},
{
"description": "Do generate PRs for golang version patch bumps, keeping x.yy version the same",
"enabled": true,
"matchDatasources": [
"golang-version"
],
"matchUpdateTypes": [
"patch"
],
"automerge": false
},
{
"description": "Do automerge and pin actions in GH workflows, except for versions starting with 0",
"enabled": true,
"matchDatasources": [
"github-runners"
],
Comment thread
rm3l marked this conversation as resolved.
Resolved
"matchUpdateTypes": [
"minor",
"patch"
],
"matchCurrentVersion": "!/^0/",
"automerge": true
}
],
"vulnerabilityAlerts": {
"enabled": true,
"addLabels": [
"kind/security"
]
},
"osvVulnerabilityAlerts": true,
"customManagers": [
{
"customType": "regex",
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ jobs:
with:
version: v2.14.0

- name: Run Gosec Security Scanner
if: steps.changed-files.outputs.any_changed == 'true'
run: make gosec
# Gosec results are available in workflow logs
# SonarCloud provides Code Scanning integration in the Security tab

e2e-tests:
name: E2E Tests
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ rhdh-must-gather-output.tar.gz
*.test
cover.out

# Security scanning reports
gosec.sarif

14 changes: 14 additions & 0 deletions .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# add test files to analysis scope
sonar.sources = .
sonar.tests= .

# Include test subdirectories in test scope
sonar.test.inclusions = tests/**/*, **/*_test.go

# Exclude test subdirectories from source scope.
# Also drop Dockerfiles: docker:S8431 flags FROM image:tag@sha256:...
# which is the pinDigest form Konflux and "Validate Image Digests" require.
# Dockerfile parsers reject NOSONAR, and sonar.issue.ignore.multicriteria is
# ignored by SonarCloud Automatic Analysis.
# sonar.exclusions is honoured. Hadolint still lints these files.
sonar.exclusions = tests/**/*, **/*_test.go, Containerfile, .rhdh/docker/Containerfile
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ BUILD_ARGS ?=
LABELS ?=
BASE_COLLECTION_PATH ?= ./out

# Tool Binaries
LOCALBIN ?= $(shell pwd)/bin
GOSEC ?= $(LOCALBIN)/gosec

# Tool Versions
GOSEC_VERSION ?= v2.29.0

# Gosec options - default format is sarif so we can integrate with Github code scanning
GOSEC_FMT ?= sarif # for other options, see https://github.com/securego/gosec#output-formats
GOSEC_OUTPUT_FILE ?= gosec.sarif

# Go configuration
GO ?= go
GO_MODULE := github.com/redhat-developer/rhdh-must-gather
Expand Down Expand Up @@ -86,6 +97,11 @@ test: ## Run unit tests
lint: ## Run linter (golangci-lint)
golangci-lint run ./...

.PHONY: gosec
gosec: addgosec ## Run the gosec scanner for non-test files in this repo
# we let the report content trigger a failure using the GitHub Security features.
$(GOSEC) -no-fail -exclude-generated -fmt $(GOSEC_FMT) -out $(GOSEC_OUTPUT_FILE) ./...

##@ Build

.PHONY: image-build
Expand Down Expand Up @@ -147,6 +163,32 @@ clean: clean-out ## Remove built images, binary, and test output
-rm -rf "$(TEST_RESULTS_DIR)"
@echo "Cleanup complete"

##@ Dependencies

.PHONY: addgosec
addgosec: $(GOSEC) ## Download gosec locally if necessary.
$(GOSEC): $(LOCALBIN)
$(call go-install-tool,$(GOSEC),github.com/securego/gosec/v2/cmd/gosec,$(GOSEC_VERSION))

$(LOCALBIN):
mkdir -p $(LOCALBIN)

# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
# $1 - target path with name of binary (ideally with version)
# $2 - package url which can be installed
# $3 - specific version of package
define go-install-tool
@[ -f "$(1)-$(3)" ] || { \
set -e; \
package=$(2)@$(3) ;\
echo "Downloading $${package}" ;\
rm -f $(1) || true ;\
GOBIN=$(LOCALBIN) go install $${package} ;\
mv $(1) $(1)-$(3) ;\
} ;\
ln -sf $(1)-$(3) $(1)
endef

##@ General

.PHONY: help
Expand Down