From 8457e55b537376c872879ff157cd96c45d46e38e Mon Sep 17 00:00:00 2001 From: Tomas Touceda Date: Mon, 12 Sep 2022 20:32:43 -0300 Subject: [PATCH] Bump go to 1.19.1 (#7690) * Bump go to 1.19.1 * Bump remaining go-version to the 1.19.1 * Add extra paths for test-go * Oops, putting the right path in the right place * gofmt file * gofmt ALL THE THINGS * Moar changes * Actually, go.mod doesn't like minor versions --- .../build-and-push-fleetctl-docker.yml | 2 +- .github/workflows/build-binaries.yaml | 4 ++-- .github/workflows/fleet-and-orbit.yml | 6 ++--- .github/workflows/fleetctl-preview-latest.yml | 2 +- .../workflows/generate-desktop-targets.yml | 6 ++--- .github/workflows/golangci-lint.yml | 3 ++- .github/workflows/goreleaser-fleet.yaml | 2 +- .github/workflows/goreleaser-orbit.yaml | 2 +- .../workflows/goreleaser-snapshot-fleet.yaml | 2 +- .github/workflows/test-go.yaml | 3 ++- .github/workflows/test-packaging.yml | 2 +- .github/workflows/test-schema-changes.yml | 2 +- .github/workflows/test.yml | 2 +- Dockerfile-desktop-linux | 2 +- Dockerfile.osquery-perf | 4 ++-- .../terraform/docker/loadtest.Dockerfile | 4 ++-- .../JITProvisioner/deprovisioner/Dockerfile | 2 +- .../JITProvisioner/deprovisioner/main.go | 10 ++++----- .../sandbox/JITProvisioner/lambda/Dockerfile | 2 +- .../sandbox/JITProvisioner/lambda/main.go | 12 +++++----- .../sandbox/Monitoring/lambda/Dockerfile | 2 +- .../sandbox/PreProvisioner/lambda/Dockerfile | 2 +- orbit/pkg/execuser/execuser_linux.go | 10 ++++----- orbit/pkg/execuser/execuser_windows.go | 4 ++-- orbit/pkg/packaging/macos_templates.go | 2 +- orbit/pkg/packaging/packaging.go | 1 + orbit/pkg/platform/platform_windows.go | 3 ++- server/authz/authz.go | 1 + server/datastore/mysql/hosts.go | 10 ++++----- server/datastore/mysql/mysql.go | 6 ++--- server/datastore/mysql/policies.go | 17 +++++++------- server/live_query/redis_live_query.go | 18 +++++++-------- server/service/devices.go | 4 ++-- server/sso/authorization_response.go | 4 ++-- server/vulnerabilities/cpe.go | 22 +++++++++---------- server/vulnerabilities/oval/mappers.go | 8 +++++-- .../oval/parsed/dpkg_infotest.go | 7 +++--- .../oval/parsed/rpm_infotest.go | 7 +++--- .../vulnerabilities/oval/parsed/rpmvercmp.go | 19 ++++++++-------- tools/redis-tests/tlsconnect.go | 18 +++++++-------- 40 files changed, 126 insertions(+), 113 deletions(-) diff --git a/.github/workflows/build-and-push-fleetctl-docker.yml b/.github/workflows/build-and-push-fleetctl-docker.yml index c8529b466..61728b3f5 100644 --- a/.github/workflows/build-and-push-fleetctl-docker.yml +++ b/.github/workflows/build-and-push-fleetctl-docker.yml @@ -31,7 +31,7 @@ jobs: - name: Set up Go uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 with: - go-version: 1.17.8 + go-version: 1.19.1 - name: Install Go Dependencies run: make deps-go diff --git a/.github/workflows/build-binaries.yaml b/.github/workflows/build-binaries.yaml index ef6179cde..8d848d66a 100644 --- a/.github/workflows/build-binaries.yaml +++ b/.github/workflows/build-binaries.yaml @@ -17,7 +17,7 @@ jobs: - name: Install Go uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 with: - go-version: 1.17 + go-version: 1.19.1 - name: Checkout Code uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v2 @@ -71,4 +71,4 @@ jobs: - uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v2 with: name: build - path: build/ \ No newline at end of file + path: build/ diff --git a/.github/workflows/fleet-and-orbit.yml b/.github/workflows/fleet-and-orbit.yml index 50c35d975..997704d37 100644 --- a/.github/workflows/fleet-and-orbit.yml +++ b/.github/workflows/fleet-and-orbit.yml @@ -42,7 +42,7 @@ jobs: timeout-minutes: 60 strategy: matrix: - go-version: ['^1.17.0'] + go-version: ['^1.19.1'] mysql: ['mysql:5.7'] runs-on: ubuntu-latest needs: gen @@ -132,7 +132,7 @@ jobs: timeout-minutes: 60 strategy: matrix: - go-version: ['^1.17.0'] + go-version: ['^1.19.1'] runs-on: ubuntu-latest needs: gen steps: @@ -180,7 +180,7 @@ jobs: timeout-minutes: 60 strategy: matrix: - go-version: ['^1.17.0'] + go-version: ['^1.19.1'] # We can only generate all (PKG, MSI, DEB, RPM) packages from a macOS host. runs-on: macos-latest needs: gen diff --git a/.github/workflows/fleetctl-preview-latest.yml b/.github/workflows/fleetctl-preview-latest.yml index 9a23a1603..064ccf17e 100644 --- a/.github/workflows/fleetctl-preview-latest.yml +++ b/.github/workflows/fleetctl-preview-latest.yml @@ -37,7 +37,7 @@ jobs: matrix: # Doesn't work on Windows because Linux Docker containers are not supported. os: [ubuntu-latest, macos-latest] - go-version: ['1.17.9'] + go-version: ['1.19.1'] runs-on: ${{ matrix.os }} steps: diff --git a/.github/workflows/generate-desktop-targets.yml b/.github/workflows/generate-desktop-targets.yml index 0881f0650..d2f132f56 100644 --- a/.github/workflows/generate-desktop-targets.yml +++ b/.github/workflows/generate-desktop-targets.yml @@ -27,7 +27,7 @@ jobs: - name: Install Go uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 with: - go-version: '^1.17.0' + go-version: '^1.19.1' - name: Checkout uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v2 @@ -73,7 +73,7 @@ jobs: - name: Install Go uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 with: - go-version: '^1.17.0' + go-version: '^1.19.1' - name: Checkout uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v2 @@ -96,7 +96,7 @@ jobs: - name: Install Go uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 with: - go-version: '^1.17.0' + go-version: '^1.19.1' - name: Checkout uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v2 diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 4b768b95a..aa98621eb 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -9,6 +9,7 @@ on: pull_request: paths: - '**.go' + - '.github/workflows/golangci-lint.yml' workflow_dispatch: # Manual permissions: @@ -26,7 +27,7 @@ jobs: - uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a with: - go-version: '1.17' + go-version: '1.19.1' - name: Run go lint run: | diff --git a/.github/workflows/goreleaser-fleet.yaml b/.github/workflows/goreleaser-fleet.yaml index a16c2b4ee..afe9b51e9 100644 --- a/.github/workflows/goreleaser-fleet.yaml +++ b/.github/workflows/goreleaser-fleet.yaml @@ -29,7 +29,7 @@ jobs: - name: Set up Go uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 with: - go-version: 1.17.8 + go-version: 1.19.1 - name: Install JS Dependencies run: make deps-js diff --git a/.github/workflows/goreleaser-orbit.yaml b/.github/workflows/goreleaser-orbit.yaml index cf41d8d1b..a4f07379b 100644 --- a/.github/workflows/goreleaser-orbit.yaml +++ b/.github/workflows/goreleaser-orbit.yaml @@ -42,7 +42,7 @@ jobs: - name: Set up Go uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 with: - go-version: 1.19.0 + go-version: 1.19.1 - name: Run GoReleaser run: go run github.com/goreleaser/goreleaser@v1.9.2 release --rm-dist -f orbit/.goreleaser.yml diff --git a/.github/workflows/goreleaser-snapshot-fleet.yaml b/.github/workflows/goreleaser-snapshot-fleet.yaml index 9cc6800a6..f94df9a22 100644 --- a/.github/workflows/goreleaser-snapshot-fleet.yaml +++ b/.github/workflows/goreleaser-snapshot-fleet.yaml @@ -27,7 +27,7 @@ jobs: - name: Set up Go uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 with: - go-version: 1.17.8 + go-version: 1.19.1 - name: Install Dependencies run: make deps diff --git a/.github/workflows/test-go.yaml b/.github/workflows/test-go.yaml index 95a7a5d94..af05e6dc5 100644 --- a/.github/workflows/test-go.yaml +++ b/.github/workflows/test-go.yaml @@ -14,6 +14,7 @@ on: - '**.go' - 'go.mod' - 'go.sum' + - '.github/workflows/test-go.yaml' workflow_dispatch: # Manual schedule: - cron: '0 4 * * *' @@ -26,7 +27,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - go-version: ['^1.17.8'] + go-version: ['^1.19.1'] mysql: ["mysql:5.7.21", "mysql:8.0.28"] runs-on: ${{ matrix.os }} diff --git a/.github/workflows/test-packaging.yml b/.github/workflows/test-packaging.yml index 2ef11d1ba..bce29db26 100644 --- a/.github/workflows/test-packaging.yml +++ b/.github/workflows/test-packaging.yml @@ -33,7 +33,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] - go-version: ['^1.17.8'] + go-version: ['^1.19.1'] runs-on: ${{ matrix.os }} steps: diff --git a/.github/workflows/test-schema-changes.yml b/.github/workflows/test-schema-changes.yml index e505c272d..2e8ceb859 100644 --- a/.github/workflows/test-schema-changes.yml +++ b/.github/workflows/test-schema-changes.yml @@ -22,7 +22,7 @@ jobs: - name: Install Go uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 with: - go-version: '^1.17.8' + go-version: '^1.19.1' - name: Checkout Code uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5 # v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ccccdbd23..432b25aa0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,7 +31,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - go-version: ['^1.17.8'] + go-version: ['^1.19.1'] fleet-tier: [free, premium] runs-on: ${{ matrix.os }} steps: diff --git a/Dockerfile-desktop-linux b/Dockerfile-desktop-linux index a52708511..9bd483c45 100644 --- a/Dockerfile-desktop-linux +++ b/Dockerfile-desktop-linux @@ -1,4 +1,4 @@ -FROM --platform=linux/amd64 golang:1.19.0-bullseye +FROM --platform=linux/amd64 golang:1.19.1-bullseye LABEL maintainer="Fleet Developers " RUN apt-get update && apt-get install -y \ diff --git a/Dockerfile.osquery-perf b/Dockerfile.osquery-perf index e08b8f60d..f31acceea 100644 --- a/Dockerfile.osquery-perf +++ b/Dockerfile.osquery-perf @@ -1,4 +1,4 @@ -FROM golang:1.19.0-alpine +FROM golang:1.19.1-alpine ARG ENROLL_SECRET ARG HOST_COUNT @@ -13,4 +13,4 @@ WORKDIR /osquery-perf/ RUN go mod download RUN go build -o osquery-perf -CMD ./osquery-perf -enroll_secret $ENROLL_SECRET -host_count $HOST_COUNT -server_url $SERVER_URL \ No newline at end of file +CMD ./osquery-perf -enroll_secret $ENROLL_SECRET -host_count $HOST_COUNT -server_url $SERVER_URL diff --git a/infrastructure/loadtesting/terraform/docker/loadtest.Dockerfile b/infrastructure/loadtesting/terraform/docker/loadtest.Dockerfile index 0dde2a2cb..cc4214d23 100644 --- a/infrastructure/loadtesting/terraform/docker/loadtest.Dockerfile +++ b/infrastructure/loadtesting/terraform/docker/loadtest.Dockerfile @@ -1,7 +1,7 @@ -FROM golang:1.19.0 +FROM golang:1.19.1 ARG TAG RUN apt update && apt upgrade -y && apt install npm yarnpkg -y && ln -s /usr/bin/yarnpkg /usr/bin/yarn RUN git clone -b $TAG https://github.com/fleetdm/fleet.git && cd /go/fleet/cmd/osquery-perf/ && go build . -FROM golang:1.19.0 +FROM golang:1.19.1 COPY --from=0 /go/fleet/cmd/osquery-perf/osquery-perf /go/osquery-perf diff --git a/infrastructure/sandbox/JITProvisioner/deprovisioner/Dockerfile b/infrastructure/sandbox/JITProvisioner/deprovisioner/Dockerfile index d0f017ba0..6346ead4f 100644 --- a/infrastructure/sandbox/JITProvisioner/deprovisioner/Dockerfile +++ b/infrastructure/sandbox/JITProvisioner/deprovisioner/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19-alpine AS builder +FROM golang:1.19.1-alpine AS builder RUN apk update && apk add --no-cache git curl openssl unzip WORKDIR /build COPY . . diff --git a/infrastructure/sandbox/JITProvisioner/deprovisioner/main.go b/infrastructure/sandbox/JITProvisioner/deprovisioner/main.go index 078dfad39..53a1e3c7f 100644 --- a/infrastructure/sandbox/JITProvisioner/deprovisioner/main.go +++ b/infrastructure/sandbox/JITProvisioner/deprovisioner/main.go @@ -11,7 +11,7 @@ import ( type OptionsStruct struct { LambdaExecutionEnv string `long:"lambda-execution-environment" env:"AWS_EXECUTION_ENV"` - InstanceID string `long:"instance-id" env:"INSTANCE_ID" required:"true"` + InstanceID string `long:"instance-id" env:"INSTANCE_ID" required:"true"` } var options = OptionsStruct{} @@ -56,16 +56,16 @@ func runTerraform(workspace string) error { "-no-color", }) if err != nil { - return err - } + return err + } err = runCmd([]string{ "workspace", "select", "default", }) if err != nil { - return err - } + return err + } err = runCmd([]string{ "workspace", "delete", diff --git a/infrastructure/sandbox/JITProvisioner/lambda/Dockerfile b/infrastructure/sandbox/JITProvisioner/lambda/Dockerfile index 5c22c6f49..a015206e4 100644 --- a/infrastructure/sandbox/JITProvisioner/lambda/Dockerfile +++ b/infrastructure/sandbox/JITProvisioner/lambda/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19-alpine AS builder +FROM golang:1.19.1-alpine AS builder WORKDIR /build COPY . . RUN go get -d -v diff --git a/infrastructure/sandbox/JITProvisioner/lambda/main.go b/infrastructure/sandbox/JITProvisioner/lambda/main.go index b192b9843..75c3202ad 100644 --- a/infrastructure/sandbox/JITProvisioner/lambda/main.go +++ b/infrastructure/sandbox/JITProvisioner/lambda/main.go @@ -15,8 +15,8 @@ import ( "github.com/aws/aws-sdk-go/service/dynamodb" "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute" "github.com/aws/aws-sdk-go/service/sfn" - "github.com/fleetdm/fleet/v4/server/service" "github.com/fleetdm/fleet/v4/pkg/spec" + "github.com/fleetdm/fleet/v4/server/service" "github.com/loopfz/gadgeto/tonic" "github.com/wI2L/fizz" "github.com/wI2L/fizz/openapi" @@ -24,9 +24,9 @@ import ( _ "go.elastic.co/apm/v2" "log" "math/rand" + "os" "strings" "time" - "os" ) type OptionsStruct struct { @@ -39,7 +39,7 @@ type OptionsStruct struct { var options = OptionsStruct{} -func applyConfig(c* gin.Context, url, token string) (err error) { +func applyConfig(c *gin.Context, url, token string) (err error) { var client *service.Client if client, err = service.NewClient(url, false, "", ""); err != nil { log.Print(err) @@ -49,9 +49,9 @@ func applyConfig(c* gin.Context, url, token string) (err error) { buf, err := os.ReadFile("standard-query-library.yml") if err != nil { - log.Print(err) - return - } + log.Print(err) + return + } specs, err := spec.GroupFromBytes(buf) if err != nil { return diff --git a/infrastructure/sandbox/Monitoring/lambda/Dockerfile b/infrastructure/sandbox/Monitoring/lambda/Dockerfile index 963e1cb9b..30854faa4 100644 --- a/infrastructure/sandbox/Monitoring/lambda/Dockerfile +++ b/infrastructure/sandbox/Monitoring/lambda/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19-alpine AS builder +FROM golang:1.19.1-alpine AS builder WORKDIR /build COPY . . RUN go get -d -v diff --git a/infrastructure/sandbox/PreProvisioner/lambda/Dockerfile b/infrastructure/sandbox/PreProvisioner/lambda/Dockerfile index f0307fafc..2b5c8959b 100644 --- a/infrastructure/sandbox/PreProvisioner/lambda/Dockerfile +++ b/infrastructure/sandbox/PreProvisioner/lambda/Dockerfile @@ -6,7 +6,7 @@ RUN cargo install --version 0.16.0 apple-codesign \ && curl -sSf $transporter_url -o transporter_install.sh \ && sh transporter_install.sh --target transporter --accept --noexec -FROM golang:1.19.0-bullseye +FROM golang:1.19.1-bullseye RUN apt-get update \ && dpkg --add-architecture i386 \ diff --git a/orbit/pkg/execuser/execuser_linux.go b/orbit/pkg/execuser/execuser_linux.go index baadb03ca..dc95667d1 100644 --- a/orbit/pkg/execuser/execuser_linux.go +++ b/orbit/pkg/execuser/execuser_linux.go @@ -95,11 +95,11 @@ func getLoginUID() (*user, error) { // parseUsersOutput parses the output of the `users' command. // -// `users' command prints on a single line a blank-separated list of user names of -// users currently logged in to the current host. Each user name -// corresponds to a login session, so if a user has more than one login -// session, that user's name will appear the same number of times in the -// output. +// `users' command prints on a single line a blank-separated list of user names of +// users currently logged in to the current host. Each user name +// corresponds to a login session, so if a user has more than one login +// session, that user's name will appear the same number of times in the +// output. // // Returns the list of usernames. func parseUsersOutput(s string) []string { diff --git a/orbit/pkg/execuser/execuser_windows.go b/orbit/pkg/execuser/execuser_windows.go index adc45eb94..4fe515748 100644 --- a/orbit/pkg/execuser/execuser_windows.go +++ b/orbit/pkg/execuser/execuser_windows.go @@ -99,11 +99,11 @@ const ( // It sets the environment of the current process so that it gets inherited by // the child process (see call to CreateEnvironmentBlock). // From https://docs.microsoft.com/en-us/windows/win32/procthread/changing-environment-variables: -// "If you want the child process to inherit most of the parent's environment with +// +// "If you want the child process to inherit most of the parent's environment with // only a few changes, retrieve the current values using GetEnvironmentVariable, save these values, // create an updated block for the child process to inherit, create the child process, and then // restore the saved values using SetEnvironmentVariable, as shown in the following example." -// func run(path string, opts eopts) error { for _, nv := range opts.env { os.Setenv(nv[0], nv[1]) diff --git a/orbit/pkg/packaging/macos_templates.go b/orbit/pkg/packaging/macos_templates.go index a8d64644c..90e54aed9 100644 --- a/orbit/pkg/packaging/macos_templates.go +++ b/orbit/pkg/packaging/macos_templates.go @@ -70,7 +70,7 @@ launchctl kickstart "system/${DAEMON_LABEL}" // TODO set Nice? // -//Note it's important not to start the orbit binary in +// Note it's important not to start the orbit binary in // `/usr/local/bin/orbit` because this is a path that users usually have write // access to, and running that binary with launchd can become a privilege // escalation vector. diff --git a/orbit/pkg/packaging/packaging.go b/orbit/pkg/packaging/packaging.go index 3dee9a268..c891d34eb 100644 --- a/orbit/pkg/packaging/packaging.go +++ b/orbit/pkg/packaging/packaging.go @@ -227,6 +227,7 @@ func writeOsqueryFlagfile(opt Options, orbitRoot string) error { // Embed the certs file that osquery uses so that we can drop it into our installation packages. // This file copied from https://raw.githubusercontent.com/osquery/osquery/master/tools/deployment/certs.pem +// //go:embed certs.pem var osqueryCerts []byte diff --git a/orbit/pkg/platform/platform_windows.go b/orbit/pkg/platform/platform_windows.go index 9aa273799..4d268e77b 100644 --- a/orbit/pkg/platform/platform_windows.go +++ b/orbit/pkg/platform/platform_windows.go @@ -1,4 +1,5 @@ -//+build windows +//go:build windows +// +build windows package platform diff --git a/server/authz/authz.go b/server/authz/authz.go index 81f627ff9..b7abe2ff4 100644 --- a/server/authz/authz.go +++ b/server/authz/authz.go @@ -26,6 +26,7 @@ type Authorizer struct { } // Load the policy from policy.rego in this directory. +// //go:embed policy.rego var policy string diff --git a/server/datastore/mysql/hosts.go b/server/datastore/mysql/hosts.go index a77e88607..2f2f016f0 100644 --- a/server/datastore/mysql/hosts.go +++ b/server/datastore/mysql/hosts.go @@ -918,9 +918,9 @@ func (ds *Datastore) MarkHostsSeen(ctx context.Context, hostIDs []uint, t time.T } // SearchHosts performs a search on the hosts table using the following criteria: -// - Use the provided team filter. -// - Search hostname, uuid, hardware_serial, and primary_ip using LIKE (mimics ListHosts behavior) -// - An optional list of IDs to omit from the search. +// - Use the provided team filter. +// - Search hostname, uuid, hardware_serial, and primary_ip using LIKE (mimics ListHosts behavior) +// - An optional list of IDs to omit from the search. func (ds *Datastore) SearchHosts(ctx context.Context, filter fleet.TeamFilter, matchQuery string, omit ...uint) ([]*fleet.Host, error) { query := `SELECT h.*, @@ -2552,8 +2552,8 @@ func (ds *Datastore) ListHostBatteries(ctx context.Context, hid uint) ([]*fleet. // Notes: // - We use `2 * interval`, because of the artificial jitter added to the intervals in Fleet. // - Default values for: -// - host.DistributedInterval is usually 10s. -// - svc.config.Osquery.DetailUpdateInterval is usually 1h. +// - host.DistributedInterval is usually 10s. +// - svc.config.Osquery.DetailUpdateInterval is usually 1h. // - Count only includes hosts seen during the last 7 days. func countHostsNotRespondingDB(ctx context.Context, db sqlx.QueryerContext, logger log.Logger, config config.FleetConfig) (int, error, ) { diff --git a/server/datastore/mysql/mysql.go b/server/datastore/mysql/mysql.go index 74c267934..087664233 100644 --- a/server/datastore/mysql/mysql.go +++ b/server/datastore/mysql/mysql.go @@ -992,9 +992,9 @@ type parameterizedStmt struct { // for a unique key that is more likely to already exist (i.e. the insert // should be infrequent, the read should succeed most of the time). // It proceeds as follows: -// 1. Try to read the ID from the read replica. -// 2. If it does not exist, try to insert the row in the primary. -// 3. If it fails due to a duplicate key, try to read the ID again, this +// 1. Try to read the ID from the read replica. +// 2. If it does not exist, try to insert the row in the primary. +// 3. If it fails due to a duplicate key, try to read the ID again, this // time from the primary. // // The read statement must only SELECT the id column. diff --git a/server/datastore/mysql/policies.go b/server/datastore/mysql/policies.go index 054133a4c..4e4d89f59 100644 --- a/server/datastore/mysql/policies.go +++ b/server/datastore/mysql/policies.go @@ -101,19 +101,20 @@ func (ds *Datastore) SavePolicy(ctx context.Context, p *fleet.Policy) error { } // FlippingPoliciesForHost fetches previous policy membership results and returns: -// - a list of "new" failing policies; "new" here means those that fail on their first -// run, and those that were passing on the previous run and are failing on the incoming execution. -// - a list of "new" passing policies; "new" here means those that failed on a previous -// run and are passing now. +// - a list of "new" failing policies; "new" here means those that fail on their first +// run, and those that were passing on the previous run and are failing on the incoming execution. +// - a list of "new" passing policies; "new" here means those that failed on a previous +// run and are passing now. // // "Failure" here means the policy query executed successfully but didn't return any rows, // so policies that did not execute (incomingResults with nil bool) are ignored. // // NOTES(lucas): -// - If a policy has been deleted (also deleted on `policy_membership` via cascade) -// and osquery agents bring in new failing results from them then those will be returned here -// (in newFailing or newPassing). -// - Similar in case a host was deleted. +// - If a policy has been deleted (also deleted on `policy_membership` via cascade) +// and osquery agents bring in new failing results from them then those will be returned here +// (in newFailing or newPassing). +// - Similar in case a host was deleted. +// // Trying to filter those out here would make this operation more expensive (fetch policies from the // `policies` table and querying the `hosts` table). func (ds *Datastore) FlippingPoliciesForHost( diff --git a/server/live_query/redis_live_query.go b/server/live_query/redis_live_query.go index baf0c35c5..6156a1944 100644 --- a/server/live_query/redis_live_query.go +++ b/server/live_query/redis_live_query.go @@ -1,7 +1,7 @@ // Package live_query implements an interface for storing and // retrieving live queries. // -// Design +// # Design // // This package operates by storing a single redis key for host // targeting information. This key has a known prefix, and the data @@ -21,15 +21,15 @@ // number of live queries targeting all of them. This was a big // factor in choosing this implementation. // -// Implementation +// # Implementation // // As mentioned in the Design section, there are three keys for each // live query: the bitfield, the SQL of the query and the set containing // the IDs of all active live queries: // -// livequery: is the bitfield that indicates the hosts -// sql:livequery: is the SQL of the query. -// livequery:active is the set containing the active live query IDs +// livequery: is the bitfield that indicates the hosts +// sql:livequery: is the SQL of the query. +// livequery:active is the set containing the active live query IDs // // Both the bitfield and sql keys have an expiration, and is the campaign // ID of the query. To make efficient use of Redis Cluster (without impacting @@ -42,7 +42,6 @@ // live on a single node in cluster mode (a "hot key"), and that node will see // increased activity due to that. Should that become a significant problem, an // alternative approach will be required. -// package live_query import ( @@ -84,9 +83,10 @@ func generateKeys(name string) (targetsKey, sqlKey string) { } // returns the base name part of a target key, i.e. so that this is true: -// tkey, _ := generateKeys(name) -// baseName := extractTargetKeyName(tkey) -// baseName == name +// +// tkey, _ := generateKeys(name) +// baseName := extractTargetKeyName(tkey) +// baseName == name func extractTargetKeyName(key string) string { name := strings.TrimPrefix(key, queryKeyPrefix) if len(name) > 0 && name[0] == '{' { diff --git a/server/service/devices.go b/server/service/devices.go index 5e0038a4d..5bc3e88bf 100644 --- a/server/service/devices.go +++ b/server/service/devices.go @@ -9,9 +9,9 @@ import ( "github.com/fleetdm/fleet/v4/server/fleet" ) -///////////////////////////////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////////////////////////////// // Fleet Desktop endpoints -///////////////////////////////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////////////////////////////// type getFleetDesktopResponse struct { Err error `json:"error,omitempty"` FailingPolicies *uint `json:"failing_policies_count,omitempty"` diff --git a/server/sso/authorization_response.go b/server/sso/authorization_response.go index a61b3f6b1..0a0b6f17f 100644 --- a/server/sso/authorization_response.go +++ b/server/sso/authorization_response.go @@ -68,8 +68,8 @@ var statusMap = map[string]int{ // // Most of the items here come from: // -// - https://docs.ldap.com/specs/rfc2798.txt -// - https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/technical-reference/the-role-of-claims +// - https://docs.ldap.com/specs/rfc2798.txt +// - https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/technical-reference/the-role-of-claims var validDisplayNameAttrs = map[string]struct{}{ "name": {}, "displayname": {}, diff --git a/server/vulnerabilities/cpe.go b/server/vulnerabilities/cpe.go index 48e8c9fb7..a33e06a82 100644 --- a/server/vulnerabilities/cpe.go +++ b/server/vulnerabilities/cpe.go @@ -221,17 +221,17 @@ func (r *regexpCache) Get(pattern string) (*regexp.Regexp, error) { // // Example: // -// [ -// { -// "match": { -// "bundle_identifier": ["com.1password.1password"] -// }, -// "translation": { -// "product": ["1password"], -// "vendor": ["agilebits"] -// } -// } -// ] +// [ +// { +// "match": { +// "bundle_identifier": ["com.1password.1password"] +// }, +// "translation": { +// "product": ["1password"], +// "vendor": ["agilebits"] +// } +// } +// ] type CPETranslations []CPETranslationItem func (c CPETranslations) Translate(reCache *regexpCache, s *fleet.Software) (CPETranslation, bool, error) { diff --git a/server/vulnerabilities/oval/mappers.go b/server/vulnerabilities/oval/mappers.go index d3b2e2701..e39f461e8 100644 --- a/server/vulnerabilities/oval/mappers.go +++ b/server/vulnerabilities/oval/mappers.go @@ -72,12 +72,16 @@ func mapCriteria(i oval_input.CriteriaXML) (*oval_parsed.Criteria, error) { // Test objects can define their 'name' in one of two ways: // 1. Inline: // <:object ...> -// <:name>software name +// +// <:name>software name +// // // // 2. As a variable reference: // <:object ...> -// <:name var_ref="var:200224390000000" var_check="at least one" /> +// +// <:name var_ref="var:200224390000000" var_check="at least one" /> +// // func mapPackageInfoTestObject( obj oval_input.PackageInfoTestObjectXML, diff --git a/server/vulnerabilities/oval/parsed/dpkg_infotest.go b/server/vulnerabilities/oval/parsed/dpkg_infotest.go index 7ebefbd5d..55c538e02 100644 --- a/server/vulnerabilities/oval/parsed/dpkg_infotest.go +++ b/server/vulnerabilities/oval/parsed/dpkg_infotest.go @@ -35,9 +35,10 @@ func (t *DpkgInfoTest) Eval(packages []fleet.Software) ([]fleet.Software, error) } // Returns: -// nObjects: How many items in the set defined by the OVAL Object set exists in the system. -// nStates: How many items in the set defined by the OVAL Object set satisfy the state requirements. -// Slice with software matching both the object and state criteria. +// +// nObjects: How many items in the set defined by the OVAL Object set exists in the system. +// nStates: How many items in the set defined by the OVAL Object set satisfy the state requirements. +// Slice with software matching both the object and state criteria. func (t *DpkgInfoTest) matches(software []fleet.Software) (int, int, []fleet.Software, error) { var nObjects int var nState int diff --git a/server/vulnerabilities/oval/parsed/rpm_infotest.go b/server/vulnerabilities/oval/parsed/rpm_infotest.go index df8e63b3f..a228278e8 100644 --- a/server/vulnerabilities/oval/parsed/rpm_infotest.go +++ b/server/vulnerabilities/oval/parsed/rpm_infotest.go @@ -35,9 +35,10 @@ func (t *RpmInfoTest) Eval(packages []fleet.Software) ([]fleet.Software, error) } // Returns: -// nObjects: How many items in the set defined by the OVAL Object set exists in the system. -// nStates: How many items in the set defined by the OVAL Object set satisfy the state requirements. -// Slice with software matching both the object and state criteria. +// +// nObjects: How many items in the set defined by the OVAL Object set exists in the system. +// nStates: How many items in the set defined by the OVAL Object set satisfy the state requirements. +// Slice with software matching both the object and state criteria. func (t *RpmInfoTest) matches(software []fleet.Software) (int, int, []fleet.Software, error) { var nObjects int var nState int diff --git a/server/vulnerabilities/oval/parsed/rpmvercmp.go b/server/vulnerabilities/oval/parsed/rpmvercmp.go index 605c97473..115656e73 100644 --- a/server/vulnerabilities/oval/parsed/rpmvercmp.go +++ b/server/vulnerabilities/oval/parsed/rpmvercmp.go @@ -7,17 +7,18 @@ import ( ) // Rpmvercmp Compares two evr strings (EPOCH:VERSION-RELEASE) by looking at each part in order: -// - EPOCHs are compared based on their numeric values, if missing then '0' is assumed, -// if equal then VERSIONs are compared. -// - VERSIONS are compared according to librpm's rpmvercmp algo -// (see http://ftp.rpm.org/api/4.4.2.2/rpmvercmp_8c-source.html), if equal RELEASEs are -// compared. -// - RELEASEs are compared using the rpmvercmp algo, if equal then both are equal. +// - EPOCHs are compared based on their numeric values, if missing then '0' is assumed, +// if equal then VERSIONs are compared. +// - VERSIONS are compared according to librpm's rpmvercmp algo +// (see http://ftp.rpm.org/api/4.4.2.2/rpmvercmp_8c-source.html), if equal RELEASEs are +// compared. +// - RELEASEs are compared using the rpmvercmp algo, if equal then both are equal. // // Returns: -// -1 if a < b -// 0 if a == b -// 1 if a > b +// +// -1 if a < b +// 0 if a == b +// 1 if a > b func Rpmvercmp(a, b string) int { epoch1 := epoch(a) epoch2 := epoch(b) diff --git a/tools/redis-tests/tlsconnect.go b/tools/redis-tests/tlsconnect.go index ad253a43c..028ef99f9 100644 --- a/tools/redis-tests/tlsconnect.go +++ b/tools/redis-tests/tlsconnect.go @@ -3,15 +3,15 @@ // the configuration get properly passed down to the pool creation. // // To run a TLS redis server: -// * Build redis from source with `make BUILD_TLS=yes` (https://redis.io/topics/encryption) -// * Generate certificates and keys with `./utils/gen-test-certs.sh` -// (the generated files will be under ./tests/tls/) -// * Run `./src/redis-server --tls-port 7379 --port 0 --tls-ca-cert-file -// ./tests/tls/ca.crt --tls-cert-file ./tests/tls/redis.crt --tls-key-file -// ./tests/tls/redis.key` -// * Run this command to test connection, e.g.: -// `go run ./tools/redis-tests/tlsconnect.go -- -addr localhost:7379 -cacert ./tests/tls/ca.crt -// -cert ./tests/tls/redis.crt -key ./tests/tls/redis.key PING` -skip +// - Build redis from source with `make BUILD_TLS=yes` (https://redis.io/topics/encryption) +// - Generate certificates and keys with `./utils/gen-test-certs.sh` +// (the generated files will be under ./tests/tls/) +// - Run `./src/redis-server --tls-port 7379 --port 0 --tls-ca-cert-file +// ./tests/tls/ca.crt --tls-cert-file ./tests/tls/redis.crt --tls-key-file +// ./tests/tls/redis.key` +// - Run this command to test connection, e.g.: +// `go run ./tools/redis-tests/tlsconnect.go -- -addr localhost:7379 -cacert ./tests/tls/ca.crt +// -cert ./tests/tls/redis.crt -key ./tests/tls/redis.key PING` -skip package main import (