Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BED-4718 Bump go version to v1.23.0 #811

Merged
merged 10 commits into from
Aug 28, 2024
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '^1.21.0'
go-version: '^1.23.0'

- name: Install Python
uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-code-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "^1.21.0"
go-version: "^1.23.0"

- name: Install Node
uses: actions/setup-node@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

# go binaries
bin
packages/go/stbernard/stbernard
packages/go/schemagen/schemagen
cmd/api/src/cmd/bhapi/bhapi

Expand Down
2 changes: 1 addition & 1 deletion DEVREADME.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ More detailed information regarding [contributing](https://github.com/SpecterOps

- [Just](https://github.com/casey/just)
- [Python 3.10](https://www.python.org/downloads/)
- [Go 1.21](https://go.dev/dl/)
- [Go 1.23](https://go.dev/dl/)
- [Node 20](https://nodejs.dev/en/download/)
- [Yarn 3.6](https://yarnpkg.com/getting-started/install)
- [Docker Desktop](https://www.docker.com/products/docker-desktop/) (or Docker/Docker Compose compatible runtime)
Expand Down
25 changes: 13 additions & 12 deletions cmd/api/src/api/agi.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package api

import (
"errors"
"fmt"
"slices"
"sort"
Expand All @@ -43,7 +44,7 @@ type AssetGroupMembers []AssetGroupMember
func (s AssetGroupMembers) SortBy(columns []string) (AssetGroupMembers, error) {
for _, column := range columns {
if column == "" {
return AssetGroupMembers{}, fmt.Errorf(ErrorResponseEmptySortParameter)
return AssetGroupMembers{}, errors.New(ErrorResponseEmptySortParameter)
}

descending := false
Expand Down Expand Up @@ -78,7 +79,7 @@ func (s AssetGroupMembers) SortBy(columns []string) (AssetGroupMembers, error) {
return s[i].Name < s[j].Name
})
default:
return AssetGroupMembers{}, fmt.Errorf(ErrorResponseDetailsNotSortable)
return AssetGroupMembers{}, errors.New(ErrorResponseDetailsNotSortable)
}

if descending {
Expand Down Expand Up @@ -118,62 +119,62 @@ func (s AssetGroupMembers) BuildFilteringConditional(column string, operator mod
} else if operator == model.NotEquals {
return func(t AssetGroupMember) bool { return t.ObjectID != value }, nil
} else {
return nil, fmt.Errorf(ErrorResponseDetailsFilterPredicateNotSupported)
return nil, errors.New(ErrorResponseDetailsFilterPredicateNotSupported)
}
case "primary_kind":
if operator == model.Equals {
return func(t AssetGroupMember) bool { return t.PrimaryKind == value }, nil
} else if operator == model.NotEquals {
return func(t AssetGroupMember) bool { return t.PrimaryKind != value }, nil
} else {
return nil, fmt.Errorf(ErrorResponseDetailsFilterPredicateNotSupported)
return nil, errors.New(ErrorResponseDetailsFilterPredicateNotSupported)
}
case "environment_id":
if operator == model.Equals {
return func(t AssetGroupMember) bool { return t.EnvironmentID == value }, nil
} else if operator == model.NotEquals {
return func(t AssetGroupMember) bool { return t.EnvironmentID != value }, nil
} else {
return nil, fmt.Errorf(ErrorResponseDetailsFilterPredicateNotSupported)
return nil, errors.New(ErrorResponseDetailsFilterPredicateNotSupported)
}
case "environment_kind":
if operator == model.Equals {
return func(t AssetGroupMember) bool { return t.EnvironmentKind == value }, nil
} else if operator == model.NotEquals {
return func(t AssetGroupMember) bool { return t.EnvironmentKind != value }, nil
} else {
return nil, fmt.Errorf(ErrorResponseDetailsFilterPredicateNotSupported)
return nil, errors.New(ErrorResponseDetailsFilterPredicateNotSupported)
}
case "name":
if operator == model.Equals {
return func(t AssetGroupMember) bool { return t.Name == value }, nil
} else if operator == model.NotEquals {
return func(t AssetGroupMember) bool { return t.Name != value }, nil
} else {
return nil, fmt.Errorf(ErrorResponseDetailsFilterPredicateNotSupported)
return nil, errors.New(ErrorResponseDetailsFilterPredicateNotSupported)
}
case "asset_group_id":
if intValue, err := strconv.Atoi(value); err != nil {
return nil, fmt.Errorf(ErrorResponseDetailsBadQueryParameterFilters)
return nil, errors.New(ErrorResponseDetailsBadQueryParameterFilters)
} else if operator == model.Equals {
return func(t AssetGroupMember) bool { return t.AssetGroupID == intValue }, nil
} else if operator == model.NotEquals {
return func(t AssetGroupMember) bool { return t.AssetGroupID != intValue }, nil
} else {
return nil, fmt.Errorf(ErrorResponseDetailsFilterPredicateNotSupported)
return nil, errors.New(ErrorResponseDetailsFilterPredicateNotSupported)
}
case "custom_member":
if boolValue, err := strconv.ParseBool(value); err != nil {
return nil, fmt.Errorf(ErrorResponseDetailsBadQueryParameterFilters)
return nil, errors.New(ErrorResponseDetailsBadQueryParameterFilters)
} else if operator == model.Equals {
return func(t AssetGroupMember) bool { return t.CustomMember == boolValue }, nil
} else if operator == model.NotEquals {
return func(t AssetGroupMember) bool { return t.CustomMember != boolValue }, nil
} else {
return nil, fmt.Errorf(ErrorResponseDetailsFilterPredicateNotSupported)
return nil, errors.New(ErrorResponseDetailsFilterPredicateNotSupported)
}
default:
return nil, fmt.Errorf(ErrorResponseDetailsColumnNotFilterable)
return nil, errors.New(ErrorResponseDetailsColumnNotFilterable)
}
}

Expand Down
16 changes: 8 additions & 8 deletions cmd/api/src/api/v2/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestManagementResource_PutUserAuthSecret(t *testing.T) {
WithContext(bhCtx).
WithMethod(http.MethodPut).
WithHeader(headers.RequestID.String(), "requestID").
WithURL(fmt.Sprintf(updateUserSecretPathFmt, goodUser.ID.String())).
WithURL(fmt.Sprintf(updateUserSecretPathFmt, goodUser.ID.String())). //nolint:govet // Ignore non-constant format string failure because it's test code
WithURLPathVars(map[string]string{"user_id": goodUser.ID.String()}).
WithBody(v2.SetUserSecretRequest{
CurrentSecret: currentPassword,
Expand All @@ -110,7 +110,7 @@ func TestManagementResource_PutUserAuthSecret(t *testing.T) {
WithContext(bhCtx).
WithMethod(http.MethodPut).
WithHeader(headers.RequestID.String(), "requestID").
WithURL(fmt.Sprintf(updateUserSecretPathFmt, goodUser.ID.String())).
WithURL(fmt.Sprintf(updateUserSecretPathFmt, goodUser.ID.String())). //nolint:govet // Ignore non-constant format string failure because it's test code
WithURLPathVars(map[string]string{"user_id": otherUser.ID.String()}).
WithBody(v2.SetUserSecretRequest{
Secret: "tesT12345!@#$",
Expand All @@ -126,7 +126,7 @@ func TestManagementResource_PutUserAuthSecret(t *testing.T) {
WithContext(bhCtx).
WithMethod(http.MethodPut).
WithHeader(headers.RequestID.String(), "requestID").
WithURL(fmt.Sprintf(updateUserSecretPathFmt, badUser.ID.String())).
WithURL(fmt.Sprintf(updateUserSecretPathFmt, badUser.ID.String())). //nolint:govet // Ignore non-constant format string failure because it's test code
WithURLPathVars(map[string]string{"user_id": badUser.ID.String()}).
WithBody(v2.SetUserSecretRequest{
Secret: "tesT12345!@#$",
Expand All @@ -146,7 +146,7 @@ func TestManagementResource_PutUserAuthSecret(t *testing.T) {
WithContext(bhCtx).
WithMethod(http.MethodPut).
WithHeader(headers.RequestID.String(), "requestID").
WithURL(fmt.Sprintf(updateUserSecretPathFmt, goodUser.ID.String())).
WithURL(fmt.Sprintf(updateUserSecretPathFmt, goodUser.ID.String())). //nolint:govet // Ignore non-constant format string failure because it's test code
WithURLPathVars(map[string]string{"user_id": goodUser.ID.String()}).
WithBody(v2.SetUserSecretRequest{
CurrentSecret: "wrongPassword",
Expand Down Expand Up @@ -184,7 +184,7 @@ func TestManagementResource_EnableUserSAML(t *testing.T) {
// Happy path
test.Request(t).
WithMethod(http.MethodPut).
WithURL(fmt.Sprintf(updateUserPathFmt, goodUserID.String())).
WithURL(fmt.Sprintf(updateUserPathFmt, goodUserID.String())). //nolint:govet // Ignore non-constant format string failure because it's test code
WithURLPathVars(map[string]string{
"user_id": goodUserID.String(),
}).
Expand All @@ -200,7 +200,7 @@ func TestManagementResource_EnableUserSAML(t *testing.T) {
// Negative path where a user already has an auth secret set
test.Request(t).
WithMethod(http.MethodPut).
WithURL(fmt.Sprintf(updateUserPathFmt, badUserID.String())).
WithURL(fmt.Sprintf(updateUserPathFmt, badUserID.String())). //nolint:govet // Ignore non-constant format string failure because it's test code
WithURLPathVars(map[string]string{
"user_id": badUserID.String(),
}).
Expand Down Expand Up @@ -251,7 +251,7 @@ func TestManagementResource_DeleteSAMLProvider(t *testing.T) {
// Happy path
test.Request(t).
WithMethod(http.MethodDelete).
WithURL(fmt.Sprintf(samlProviderPathFmt, goodSAMLProvider.ID)).
WithURL(fmt.Sprintf(samlProviderPathFmt, goodSAMLProvider.ID)). //nolint:govet // Ignore non-constant format string failure because it's test code
WithURLPathVars(map[string]string{
api.URIPathVariableSAMLProviderID: fmt.Sprintf("%d", goodSAMLProvider.ID),
}).
Expand All @@ -262,7 +262,7 @@ func TestManagementResource_DeleteSAMLProvider(t *testing.T) {
// Negative path where a provider has attached users
test.Request(t).
WithMethod(http.MethodDelete).
WithURL(fmt.Sprintf(samlProviderPathFmt, samlProviderWithUsers.ID)).
WithURL(fmt.Sprintf(samlProviderPathFmt, samlProviderWithUsers.ID)). //nolint:govet // Ignore non-constant format string failure because it's test code
WithURLPathVars(map[string]string{
api.URIPathVariableSAMLProviderID: fmt.Sprintf("%d", samlProviderWithUsers.ID),
}).
Expand Down
7 changes: 4 additions & 3 deletions cmd/api/src/api/v2/saved_queries_permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ package v2

import (
"encoding/json"
"net/http"
"slices"
"strconv"

"github.com/gofrs/uuid"
"github.com/gorilla/mux"
"github.com/specterops/bloodhound/src/api"
"github.com/specterops/bloodhound/src/auth"
ctx2 "github.com/specterops/bloodhound/src/ctx"
"github.com/specterops/bloodhound/src/model"
"net/http"
"slices"
"strconv"
)

// DeleteSavedQueryPermissionsRequest represents the payload sent to the unshare endpoint
Expand Down
7 changes: 4 additions & 3 deletions cmd/api/src/api/v2/saved_queries_permissions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ package v2_test

import (
"fmt"
"net/http"
"net/http/httptest"
"testing"

uuid2 "github.com/gofrs/uuid"
"github.com/google/uuid"
"github.com/gorilla/mux"
Expand All @@ -32,9 +36,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
"net/http"
"net/http/httptest"
"testing"
)

func TestResources_DeleteSavedQueryPermissions(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion cmd/api/src/database/saved_queries_permissions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ package database_test

import (
"context"
"github.com/gofrs/uuid"
"testing"

"github.com/gofrs/uuid"

"github.com/specterops/bloodhound/src/database"
"github.com/specterops/bloodhound/src/model"
"github.com/specterops/bloodhound/src/test/integration"
Expand Down
3 changes: 2 additions & 1 deletion cmd/api/src/database/saved_queries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ package database_test
import (
"context"
"fmt"
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"

"github.com/gofrs/uuid"
"github.com/specterops/bloodhound/src/model"
"github.com/specterops/bloodhound/src/test/integration"
Expand Down
3 changes: 2 additions & 1 deletion cmd/api/src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module github.com/specterops/bloodhound/src

go 1.21
go 1.23

require (
github.com/beevik/etree v1.2.0
Expand All @@ -28,6 +28,7 @@ require (
github.com/gobeam/stringy v0.0.6
github.com/gofrs/uuid v4.4.0+incompatible
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/google/uuid v1.3.0
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/gorilla/schema v1.4.1
Expand Down
1 change: 1 addition & 0 deletions cmd/api/src/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
Expand Down
2 changes: 1 addition & 1 deletion cmd/api/src/go.tools.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module github.com/specterops/bloodhound/src

go 1.21
go 1.23

require (
go.uber.org/mock v1.5.0 // indirect
Expand Down
6 changes: 2 additions & 4 deletions cmd/api/src/model/saved_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

package model

import (
"fmt"
)
import "errors"

type SavedQuery struct {
UserID string `json:"user_id" gorm:"index:,unique,composite:compositeIndex"`
Expand Down Expand Up @@ -77,7 +75,7 @@ func (s SavedQueries) GetFilterableColumns() []string {

func (s SavedQueries) GetValidFilterPredicatesAsStrings(column string) ([]string, error) {
if predicates, validColumn := s.ValidFilters()[column]; !validColumn {
return []string{}, fmt.Errorf(ErrorResponseDetailsColumnNotFilterable)
return []string{}, errors.New(ErrorResponseDetailsColumnNotFilterable)
} else {
var stringPredicates = make([]string, 0)
for _, predicate := range predicates {
Expand Down
14 changes: 7 additions & 7 deletions cmd/api/src/model/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package model

import (
"fmt"
"errors"
"net/http"
"net/url"
"slices"
Expand Down Expand Up @@ -76,7 +76,7 @@ func (s DomainSelectors) GetFilterableColumns() []string {

func (s DomainSelectors) GetValidFilterPredicatesAsStrings(column string) ([]string, error) {
if predicates, validColumn := s.ValidFilters()[column]; !validColumn {
return []string{}, fmt.Errorf(ErrorResponseDetailsColumnNotFilterable)
return []string{}, errors.New(ErrorResponseDetailsColumnNotFilterable)
} else {
var stringPredicates = make([]string, 0)
for _, predicate := range predicates {
Expand Down Expand Up @@ -118,7 +118,7 @@ func (s DomainSelectors) GetOrderCriteria(params url.Values) (OrderCriteria, err
criterion.Property = column

if !s.IsSortable(column) {
return OrderCriteria{}, fmt.Errorf(ErrorResponseDetailsColumnNotSortable)
return OrderCriteria{}, errors.New(ErrorResponseDetailsColumnNotSortable)
}

orderCriteria = append(orderCriteria, criterion)
Expand All @@ -133,18 +133,18 @@ func (s DomainSelectors) GetFilterCriteria(request *http.Request) (graph.Criteri
)

if queryFilters, err := queryParameterFilterParser.ParseQueryParameterFilters(request); err != nil {
return nil, fmt.Errorf(ErrorResponseDetailsBadQueryParameterFilters)
return nil, errors.New(ErrorResponseDetailsBadQueryParameterFilters)
} else {
for name, filters := range queryFilters {
if valid := slices.Contains(s.GetFilterableColumns(), name); !valid {
return nil, fmt.Errorf(ErrorResponseDetailsColumnNotFilterable)
return nil, errors.New(ErrorResponseDetailsColumnNotFilterable)
}
if validPredicates, err := s.GetValidFilterPredicatesAsStrings(name); err != nil {
return nil, fmt.Errorf(ErrorResponseDetailsColumnNotFilterable)
return nil, errors.New(ErrorResponseDetailsColumnNotFilterable)
} else {
for i, filter := range filters {
if !slices.Contains(validPredicates, string(filter.Operator)) {
return nil, fmt.Errorf(ErrorResponseDetailsFilterPredicateNotSupported)
return nil, errors.New(ErrorResponseDetailsFilterPredicateNotSupported)
}
queryFilters[name][i].IsStringData = s.IsString(filter.Name)
}
Expand Down
2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//
// SPDX-License-Identifier: Apache-2.0

go 1.21.3
go 1.23

use (
./cmd/api/src
Expand Down
2 changes: 1 addition & 1 deletion packages/go/analysis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module github.com/specterops/bloodhound/analysis

go 1.21
go 1.23

require (
github.com/RoaringBitmap/roaring v1.3.0
Expand Down
Loading
Loading