From 2883ea9cb96d2418568b9b9c33b3f8e7207bef71 Mon Sep 17 00:00:00 2001 From: Javier Marcos <1271349+javuto@users.noreply.github.com> Date: Fri, 3 Apr 2026 10:33:09 +0200 Subject: [PATCH 1/5] Configuration endpoints to receive osquery configuration from gitOps --- .pre-commit-config.yaml | 2 +- cmd/admin/handlers/post.go | 5 ++ cmd/admin/templates/conf.html | 59 ++++++++++++---- cmd/tls/handlers/handlers.go | 9 +++ cmd/tls/handlers/post.go | 113 +++++++++++++++++++++++++++++++ cmd/tls/main.go | 24 ++++--- cmd/tls/utils.go | 1 + pkg/config/flags.go | 9 +++ pkg/config/types.go | 34 +++++++--- pkg/config/utils.go | 23 ++++--- pkg/environments/environments.go | 2 + pkg/types/types.go | 6 ++ 12 files changed, 244 insertions(+), 43 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 115d88ff..a4b75594 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: - id: go-unit-tests - repo: https://github.com/golangci/golangci-lint - rev: v1.62.2 + rev: v2.11.4 hooks: - id: golangci-lint args: [--config=.golangci.yml] diff --git a/cmd/admin/handlers/post.go b/cmd/admin/handlers/post.go index 7c6477e5..78d63381 100644 --- a/cmd/admin/handlers/post.go +++ b/cmd/admin/handlers/post.go @@ -442,6 +442,11 @@ func (h *HandlersAdmin) ConfPOSTHandler(w http.ResponseWriter, r *http.Request) adminErrorResponse(w, "invalid CSRF token", http.StatusInternalServerError, nil) return } + // Check if configuration is read-only + if h.OsqueryValues.ReadOnly { + adminErrorResponse(w, "configuration is read-only", http.StatusForbidden, nil) + return + } if c.ConfigurationB64 != "" { // Base64 decode received configuration // TODO verify configuration diff --git a/cmd/admin/templates/conf.html b/cmd/admin/templates/conf.html index 1b4457fb..f0c268b7 100644 --- a/cmd/admin/templates/conf.html +++ b/cmd/admin/templates/conf.html @@ -98,7 +98,12 @@