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
This commit is contained in:
Tomas Touceda 2022-09-12 20:32:43 -03:00 committed by GitHub
parent 9eafecd95e
commit 8457e55b53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 126 additions and 113 deletions

View File

@ -31,7 +31,7 @@ jobs:
- name: Set up Go - name: Set up Go
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2
with: with:
go-version: 1.17.8 go-version: 1.19.1
- name: Install Go Dependencies - name: Install Go Dependencies
run: make deps-go run: make deps-go

View File

@ -17,7 +17,7 @@ jobs:
- name: Install Go - name: Install Go
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2
with: with:
go-version: 1.17 go-version: 1.19.1
- name: Checkout Code - name: Checkout Code
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v2 uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v2
@ -71,4 +71,4 @@ jobs:
- uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v2 - uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v2
with: with:
name: build name: build
path: build/ path: build/

View File

@ -42,7 +42,7 @@ jobs:
timeout-minutes: 60 timeout-minutes: 60
strategy: strategy:
matrix: matrix:
go-version: ['^1.17.0'] go-version: ['^1.19.1']
mysql: ['mysql:5.7'] mysql: ['mysql:5.7']
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: gen needs: gen
@ -132,7 +132,7 @@ jobs:
timeout-minutes: 60 timeout-minutes: 60
strategy: strategy:
matrix: matrix:
go-version: ['^1.17.0'] go-version: ['^1.19.1']
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: gen needs: gen
steps: steps:
@ -180,7 +180,7 @@ jobs:
timeout-minutes: 60 timeout-minutes: 60
strategy: strategy:
matrix: 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. # We can only generate all (PKG, MSI, DEB, RPM) packages from a macOS host.
runs-on: macos-latest runs-on: macos-latest
needs: gen needs: gen

View File

@ -37,7 +37,7 @@ jobs:
matrix: matrix:
# Doesn't work on Windows because Linux Docker containers are not supported. # Doesn't work on Windows because Linux Docker containers are not supported.
os: [ubuntu-latest, macos-latest] os: [ubuntu-latest, macos-latest]
go-version: ['1.17.9'] go-version: ['1.19.1']
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:

View File

@ -27,7 +27,7 @@ jobs:
- name: Install Go - name: Install Go
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2
with: with:
go-version: '^1.17.0' go-version: '^1.19.1'
- name: Checkout - name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v2 uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v2
@ -73,7 +73,7 @@ jobs:
- name: Install Go - name: Install Go
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2
with: with:
go-version: '^1.17.0' go-version: '^1.19.1'
- name: Checkout - name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v2 uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v2
@ -96,7 +96,7 @@ jobs:
- name: Install Go - name: Install Go
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2
with: with:
go-version: '^1.17.0' go-version: '^1.19.1'
- name: Checkout - name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v2 uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v2

View File

@ -9,6 +9,7 @@ on:
pull_request: pull_request:
paths: paths:
- '**.go' - '**.go'
- '.github/workflows/golangci-lint.yml'
workflow_dispatch: # Manual workflow_dispatch: # Manual
permissions: permissions:
@ -26,7 +27,7 @@ jobs:
- uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a - uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a
with: with:
go-version: '1.17' go-version: '1.19.1'
- name: Run go lint - name: Run go lint
run: | run: |

View File

@ -29,7 +29,7 @@ jobs:
- name: Set up Go - name: Set up Go
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2
with: with:
go-version: 1.17.8 go-version: 1.19.1
- name: Install JS Dependencies - name: Install JS Dependencies
run: make deps-js run: make deps-js

View File

@ -42,7 +42,7 @@ jobs:
- name: Set up Go - name: Set up Go
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2
with: with:
go-version: 1.19.0 go-version: 1.19.1
- name: Run GoReleaser - name: Run GoReleaser
run: go run github.com/goreleaser/goreleaser@v1.9.2 release --rm-dist -f orbit/.goreleaser.yml run: go run github.com/goreleaser/goreleaser@v1.9.2 release --rm-dist -f orbit/.goreleaser.yml

View File

@ -27,7 +27,7 @@ jobs:
- name: Set up Go - name: Set up Go
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2
with: with:
go-version: 1.17.8 go-version: 1.19.1
- name: Install Dependencies - name: Install Dependencies
run: make deps run: make deps

View File

@ -14,6 +14,7 @@ on:
- '**.go' - '**.go'
- 'go.mod' - 'go.mod'
- 'go.sum' - 'go.sum'
- '.github/workflows/test-go.yaml'
workflow_dispatch: # Manual workflow_dispatch: # Manual
schedule: schedule:
- cron: '0 4 * * *' - cron: '0 4 * * *'
@ -26,7 +27,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest] os: [ubuntu-latest]
go-version: ['^1.17.8'] go-version: ['^1.19.1']
mysql: ["mysql:5.7.21", "mysql:8.0.28"] mysql: ["mysql:5.7.21", "mysql:8.0.28"]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}

View File

@ -33,7 +33,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu-latest, macos-latest] os: [ubuntu-latest, macos-latest]
go-version: ['^1.17.8'] go-version: ['^1.19.1']
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:

View File

@ -22,7 +22,7 @@ jobs:
- name: Install Go - name: Install Go
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2
with: with:
go-version: '^1.17.8' go-version: '^1.19.1'
- name: Checkout Code - name: Checkout Code
uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5 # v2 uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5 # v2

View File

@ -31,7 +31,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu-latest] os: [ubuntu-latest]
go-version: ['^1.17.8'] go-version: ['^1.19.1']
fleet-tier: [free, premium] fleet-tier: [free, premium]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:

View File

@ -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 <hello@fleetdm.com>" LABEL maintainer="Fleet Developers <hello@fleetdm.com>"
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \

View File

@ -1,4 +1,4 @@
FROM golang:1.19.0-alpine FROM golang:1.19.1-alpine
ARG ENROLL_SECRET ARG ENROLL_SECRET
ARG HOST_COUNT ARG HOST_COUNT
@ -13,4 +13,4 @@ WORKDIR /osquery-perf/
RUN go mod download RUN go mod download
RUN go build -o osquery-perf RUN go build -o osquery-perf
CMD ./osquery-perf -enroll_secret $ENROLL_SECRET -host_count $HOST_COUNT -server_url $SERVER_URL CMD ./osquery-perf -enroll_secret $ENROLL_SECRET -host_count $HOST_COUNT -server_url $SERVER_URL

View File

@ -1,7 +1,7 @@
FROM golang:1.19.0 FROM golang:1.19.1
ARG TAG ARG TAG
RUN apt update && apt upgrade -y && apt install npm yarnpkg -y && ln -s /usr/bin/yarnpkg /usr/bin/yarn 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 . 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 COPY --from=0 /go/fleet/cmd/osquery-perf/osquery-perf /go/osquery-perf

View File

@ -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 RUN apk update && apk add --no-cache git curl openssl unzip
WORKDIR /build WORKDIR /build
COPY . . COPY . .

View File

@ -11,7 +11,7 @@ import (
type OptionsStruct struct { type OptionsStruct struct {
LambdaExecutionEnv string `long:"lambda-execution-environment" env:"AWS_EXECUTION_ENV"` 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{} var options = OptionsStruct{}
@ -56,16 +56,16 @@ func runTerraform(workspace string) error {
"-no-color", "-no-color",
}) })
if err != nil { if err != nil {
return err return err
} }
err = runCmd([]string{ err = runCmd([]string{
"workspace", "workspace",
"select", "select",
"default", "default",
}) })
if err != nil { if err != nil {
return err return err
} }
err = runCmd([]string{ err = runCmd([]string{
"workspace", "workspace",
"delete", "delete",

View File

@ -1,4 +1,4 @@
FROM golang:1.19-alpine AS builder FROM golang:1.19.1-alpine AS builder
WORKDIR /build WORKDIR /build
COPY . . COPY . .
RUN go get -d -v RUN go get -d -v

View File

@ -15,8 +15,8 @@ import (
"github.com/aws/aws-sdk-go/service/dynamodb" "github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute" "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
"github.com/aws/aws-sdk-go/service/sfn" "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/pkg/spec"
"github.com/fleetdm/fleet/v4/server/service"
"github.com/loopfz/gadgeto/tonic" "github.com/loopfz/gadgeto/tonic"
"github.com/wI2L/fizz" "github.com/wI2L/fizz"
"github.com/wI2L/fizz/openapi" "github.com/wI2L/fizz/openapi"
@ -24,9 +24,9 @@ import (
_ "go.elastic.co/apm/v2" _ "go.elastic.co/apm/v2"
"log" "log"
"math/rand" "math/rand"
"os"
"strings" "strings"
"time" "time"
"os"
) )
type OptionsStruct struct { type OptionsStruct struct {
@ -39,7 +39,7 @@ type OptionsStruct struct {
var options = OptionsStruct{} 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 var client *service.Client
if client, err = service.NewClient(url, false, "", ""); err != nil { if client, err = service.NewClient(url, false, "", ""); err != nil {
log.Print(err) 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") buf, err := os.ReadFile("standard-query-library.yml")
if err != nil { if err != nil {
log.Print(err) log.Print(err)
return return
} }
specs, err := spec.GroupFromBytes(buf) specs, err := spec.GroupFromBytes(buf)
if err != nil { if err != nil {
return return

View File

@ -1,4 +1,4 @@
FROM golang:1.19-alpine AS builder FROM golang:1.19.1-alpine AS builder
WORKDIR /build WORKDIR /build
COPY . . COPY . .
RUN go get -d -v RUN go get -d -v

View File

@ -6,7 +6,7 @@ RUN cargo install --version 0.16.0 apple-codesign \
&& curl -sSf $transporter_url -o transporter_install.sh \ && curl -sSf $transporter_url -o transporter_install.sh \
&& sh transporter_install.sh --target transporter --accept --noexec && sh transporter_install.sh --target transporter --accept --noexec
FROM golang:1.19.0-bullseye FROM golang:1.19.1-bullseye
RUN apt-get update \ RUN apt-get update \
&& dpkg --add-architecture i386 \ && dpkg --add-architecture i386 \

View File

@ -95,11 +95,11 @@ func getLoginUID() (*user, error) {
// parseUsersOutput parses the output of the `users' command. // parseUsersOutput parses the output of the `users' command.
// //
// `users' command prints on a single line a blank-separated list of user names of // `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 // 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 // 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 // session, that user's name will appear the same number of times in the
// output. // output.
// //
// Returns the list of usernames. // Returns the list of usernames.
func parseUsersOutput(s string) []string { func parseUsersOutput(s string) []string {

View File

@ -99,11 +99,11 @@ const (
// It sets the environment of the current process so that it gets inherited by // It sets the environment of the current process so that it gets inherited by
// the child process (see call to CreateEnvironmentBlock). // the child process (see call to CreateEnvironmentBlock).
// From https://docs.microsoft.com/en-us/windows/win32/procthread/changing-environment-variables: // 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, // 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 // 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." // restore the saved values using SetEnvironmentVariable, as shown in the following example."
//
func run(path string, opts eopts) error { func run(path string, opts eopts) error {
for _, nv := range opts.env { for _, nv := range opts.env {
os.Setenv(nv[0], nv[1]) os.Setenv(nv[0], nv[1])

View File

@ -70,7 +70,7 @@ launchctl kickstart "system/${DAEMON_LABEL}"
// TODO set Nice? // 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 // `/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 // access to, and running that binary with launchd can become a privilege
// escalation vector. // escalation vector.

View File

@ -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. // 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 // This file copied from https://raw.githubusercontent.com/osquery/osquery/master/tools/deployment/certs.pem
//
//go:embed certs.pem //go:embed certs.pem
var osqueryCerts []byte var osqueryCerts []byte

View File

@ -1,4 +1,5 @@
//+build windows //go:build windows
// +build windows
package platform package platform

View File

@ -26,6 +26,7 @@ type Authorizer struct {
} }
// Load the policy from policy.rego in this directory. // Load the policy from policy.rego in this directory.
//
//go:embed policy.rego //go:embed policy.rego
var policy string var policy string

View File

@ -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: // SearchHosts performs a search on the hosts table using the following criteria:
// - Use the provided team filter. // - Use the provided team filter.
// - Search hostname, uuid, hardware_serial, and primary_ip using LIKE (mimics ListHosts behavior) // - Search hostname, uuid, hardware_serial, and primary_ip using LIKE (mimics ListHosts behavior)
// - An optional list of IDs to omit from the search. // - 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) { func (ds *Datastore) SearchHosts(ctx context.Context, filter fleet.TeamFilter, matchQuery string, omit ...uint) ([]*fleet.Host, error) {
query := `SELECT query := `SELECT
h.*, h.*,
@ -2552,8 +2552,8 @@ func (ds *Datastore) ListHostBatteries(ctx context.Context, hid uint) ([]*fleet.
// Notes: // Notes:
// - We use `2 * interval`, because of the artificial jitter added to the intervals in Fleet. // - We use `2 * interval`, because of the artificial jitter added to the intervals in Fleet.
// - Default values for: // - Default values for:
// - host.DistributedInterval is usually 10s. // - host.DistributedInterval is usually 10s.
// - svc.config.Osquery.DetailUpdateInterval is usually 1h. // - svc.config.Osquery.DetailUpdateInterval is usually 1h.
// - Count only includes hosts seen during the last 7 days. // - 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, func countHostsNotRespondingDB(ctx context.Context, db sqlx.QueryerContext, logger log.Logger, config config.FleetConfig) (int, error,
) { ) {

View File

@ -992,9 +992,9 @@ type parameterizedStmt struct {
// for a unique key that is more likely to already exist (i.e. the insert // 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). // should be infrequent, the read should succeed most of the time).
// It proceeds as follows: // It proceeds as follows:
// 1. Try to read the ID from the read replica. // 1. Try to read the ID from the read replica.
// 2. If it does not exist, try to insert the row in the primary. // 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 // 3. If it fails due to a duplicate key, try to read the ID again, this
// time from the primary. // time from the primary.
// //
// The read statement must only SELECT the id column. // The read statement must only SELECT the id column.

View File

@ -101,19 +101,20 @@ func (ds *Datastore) SavePolicy(ctx context.Context, p *fleet.Policy) error {
} }
// FlippingPoliciesForHost fetches previous policy membership results and returns: // FlippingPoliciesForHost fetches previous policy membership results and returns:
// - a list of "new" failing policies; "new" here means those that fail on their first // - 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. // 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 // - a list of "new" passing policies; "new" here means those that failed on a previous
// run and are passing now. // run and are passing now.
// //
// "Failure" here means the policy query executed successfully but didn't return any rows, // "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. // so policies that did not execute (incomingResults with nil bool) are ignored.
// //
// NOTES(lucas): // NOTES(lucas):
// - If a policy has been deleted (also deleted on `policy_membership` via cascade) // - 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 // and osquery agents bring in new failing results from them then those will be returned here
// (in newFailing or newPassing). // (in newFailing or newPassing).
// - Similar in case a host was deleted. // - Similar in case a host was deleted.
//
// Trying to filter those out here would make this operation more expensive (fetch policies from the // Trying to filter those out here would make this operation more expensive (fetch policies from the
// `policies` table and querying the `hosts` table). // `policies` table and querying the `hosts` table).
func (ds *Datastore) FlippingPoliciesForHost( func (ds *Datastore) FlippingPoliciesForHost(

View File

@ -1,7 +1,7 @@
// Package live_query implements an interface for storing and // Package live_query implements an interface for storing and
// retrieving live queries. // retrieving live queries.
// //
// Design // # Design
// //
// This package operates by storing a single redis key for host // This package operates by storing a single redis key for host
// targeting information. This key has a known prefix, and the data // 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 // number of live queries targeting all of them. This was a big
// factor in choosing this implementation. // factor in choosing this implementation.
// //
// Implementation // # Implementation
// //
// As mentioned in the Design section, there are three keys for each // 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 // live query: the bitfield, the SQL of the query and the set containing
// the IDs of all active live queries: // the IDs of all active live queries:
// //
// livequery:<ID> is the bitfield that indicates the hosts // livequery:<ID> is the bitfield that indicates the hosts
// sql:livequery:<ID> is the SQL of the query. // sql:livequery:<ID> is the SQL of the query.
// livequery:active is the set containing the active live query IDs // livequery:active is the set containing the active live query IDs
// //
// Both the bitfield and sql keys have an expiration, and <ID> is the campaign // Both the bitfield and sql keys have an expiration, and <ID> is the campaign
// ID of the query. To make efficient use of Redis Cluster (without impacting // 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 // 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 // increased activity due to that. Should that become a significant problem, an
// alternative approach will be required. // alternative approach will be required.
//
package live_query package live_query
import ( 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: // returns the base name part of a target key, i.e. so that this is true:
// tkey, _ := generateKeys(name) //
// baseName := extractTargetKeyName(tkey) // tkey, _ := generateKeys(name)
// baseName == name // baseName := extractTargetKeyName(tkey)
// baseName == name
func extractTargetKeyName(key string) string { func extractTargetKeyName(key string) string {
name := strings.TrimPrefix(key, queryKeyPrefix) name := strings.TrimPrefix(key, queryKeyPrefix)
if len(name) > 0 && name[0] == '{' { if len(name) > 0 && name[0] == '{' {

View File

@ -9,9 +9,9 @@ import (
"github.com/fleetdm/fleet/v4/server/fleet" "github.com/fleetdm/fleet/v4/server/fleet"
) )
///////////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////////
// Fleet Desktop endpoints // Fleet Desktop endpoints
///////////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////////
type getFleetDesktopResponse struct { type getFleetDesktopResponse struct {
Err error `json:"error,omitempty"` Err error `json:"error,omitempty"`
FailingPolicies *uint `json:"failing_policies_count,omitempty"` FailingPolicies *uint `json:"failing_policies_count,omitempty"`

View File

@ -68,8 +68,8 @@ var statusMap = map[string]int{
// //
// Most of the items here come from: // Most of the items here come from:
// //
// - https://docs.ldap.com/specs/rfc2798.txt // - 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.microsoft.com/en-us/windows-server/identity/ad-fs/technical-reference/the-role-of-claims
var validDisplayNameAttrs = map[string]struct{}{ var validDisplayNameAttrs = map[string]struct{}{
"name": {}, "name": {},
"displayname": {}, "displayname": {},

View File

@ -221,17 +221,17 @@ func (r *regexpCache) Get(pattern string) (*regexp.Regexp, error) {
// //
// Example: // Example:
// //
// [ // [
// { // {
// "match": { // "match": {
// "bundle_identifier": ["com.1password.1password"] // "bundle_identifier": ["com.1password.1password"]
// }, // },
// "translation": { // "translation": {
// "product": ["1password"], // "product": ["1password"],
// "vendor": ["agilebits"] // "vendor": ["agilebits"]
// } // }
// } // }
// ] // ]
type CPETranslations []CPETranslationItem type CPETranslations []CPETranslationItem
func (c CPETranslations) Translate(reCache *regexpCache, s *fleet.Software) (CPETranslation, bool, error) { func (c CPETranslations) Translate(reCache *regexpCache, s *fleet.Software) (CPETranslation, bool, error) {

View File

@ -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: // Test objects can define their 'name' in one of two ways:
// 1. Inline: // 1. Inline:
// <:object ...> // <:object ...>
// <:name>software name</:name> //
// <:name>software name</:name>
//
// </:object> // </:object>
// //
// 2. As a variable reference: // 2. As a variable reference:
// <:object ...> // <:object ...>
// <:name var_ref="var:200224390000000" var_check="at least one" /> //
// <:name var_ref="var:200224390000000" var_check="at least one" />
//
// </:object> // </:object>
func mapPackageInfoTestObject( func mapPackageInfoTestObject(
obj oval_input.PackageInfoTestObjectXML, obj oval_input.PackageInfoTestObjectXML,

View File

@ -35,9 +35,10 @@ func (t *DpkgInfoTest) Eval(packages []fleet.Software) ([]fleet.Software, error)
} }
// Returns: // 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. // nObjects: How many items in the set defined by the OVAL Object set exists in the system.
// Slice with software matching both the object and state criteria. // 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) { func (t *DpkgInfoTest) matches(software []fleet.Software) (int, int, []fleet.Software, error) {
var nObjects int var nObjects int
var nState int var nState int

View File

@ -35,9 +35,10 @@ func (t *RpmInfoTest) Eval(packages []fleet.Software) ([]fleet.Software, error)
} }
// Returns: // 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. // nObjects: How many items in the set defined by the OVAL Object set exists in the system.
// Slice with software matching both the object and state criteria. // 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) { func (t *RpmInfoTest) matches(software []fleet.Software) (int, int, []fleet.Software, error) {
var nObjects int var nObjects int
var nState int var nState int

View File

@ -7,17 +7,18 @@ import (
) )
// Rpmvercmp Compares two evr strings (EPOCH:VERSION-RELEASE) by looking at each part in order: // 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, // - EPOCHs are compared based on their numeric values, if missing then '0' is assumed,
// if equal then VERSIONs are compared. // if equal then VERSIONs are compared.
// - VERSIONS are compared according to librpm's rpmvercmp algo // - 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 // (see http://ftp.rpm.org/api/4.4.2.2/rpmvercmp_8c-source.html), if equal RELEASEs are
// compared. // compared.
// - RELEASEs are compared using the rpmvercmp algo, if equal then both are equal. // - RELEASEs are compared using the rpmvercmp algo, if equal then both are equal.
// //
// Returns: // 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 { func Rpmvercmp(a, b string) int {
epoch1 := epoch(a) epoch1 := epoch(a)
epoch2 := epoch(b) epoch2 := epoch(b)

View File

@ -3,15 +3,15 @@
// the configuration get properly passed down to the pool creation. // the configuration get properly passed down to the pool creation.
// //
// To run a TLS redis server: // To run a TLS redis server:
// * Build redis from source with `make BUILD_TLS=yes` (https://redis.io/topics/encryption) // - Build redis from source with `make BUILD_TLS=yes` (https://redis.io/topics/encryption)
// * Generate certificates and keys with `./utils/gen-test-certs.sh` // - Generate certificates and keys with `./utils/gen-test-certs.sh`
// (the generated files will be under ./tests/tls/) // (the generated files will be under ./tests/tls/)
// * Run `./src/redis-server --tls-port 7379 --port 0 --tls-ca-cert-file // - 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/ca.crt --tls-cert-file ./tests/tls/redis.crt --tls-key-file
// ./tests/tls/redis.key` // ./tests/tls/redis.key`
// * Run this command to test connection, e.g.: // - Run this command to test connection, e.g.:
// `go run ./tools/redis-tests/tlsconnect.go -- -addr localhost:7379 -cacert ./tests/tls/ca.crt // `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 // -cert ./tests/tls/redis.crt -key ./tests/tls/redis.key PING` -skip
package main package main
import ( import (