Skip to content

Commit

Permalink
Update Dependencies for Envoy (#1174)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbengfort authored Jul 22, 2024
1 parent dba93b8 commit a8aa033
Show file tree
Hide file tree
Showing 48 changed files with 632 additions and 758 deletions.
38 changes: 19 additions & 19 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: 1.22.x

- name: Install Staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@v0.3.3
run: go install honnef.co/go/tools/cmd/staticcheck@2023.1.7

- name: Checkout Code
uses: actions/checkout@v4
Expand All @@ -38,12 +38,12 @@ jobs:
working-directory: ${{ env.GOPATH }}/src/github.com/trisacrypto/directory
steps:
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: 1.22.x

- name: Cache Speedup
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand All @@ -56,18 +56,18 @@ jobs:
path: ${{ env.GOPATH }}/src/github.com/trisacrypto/directory

- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
version: "3.x"
version: "27.x"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Dependencies
run: |
go version
go install github.com/kevinburke/go-bindata/[email protected]
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3
go install github.com/swaggo/swag/cmd/swag@v1.8.12
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.2
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.4.0
go install github.com/swaggo/swag/cmd/swag@v1.16.3
- name: Clone TRISA repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -170,12 +170,12 @@ jobs:
working-directory: ${{ env.GOPATH }}/src/github.com/trisacrypto/directory
steps:
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: 1.22.x

- name: Cache Speedup
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand All @@ -188,18 +188,18 @@ jobs:
path: ${{ env.GOPATH }}/src/github.com/trisacrypto/directory

- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
version: "3.x"
version: "27.x"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Dependencies
run: |
go version
go install github.com/kevinburke/go-bindata/[email protected]
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3
go install github.com/swaggo/swag/cmd/swag@v1.8.12
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.2
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.4.0
go install github.com/swaggo/swag/cmd/swag@v1.16.3
- name: Clone TRISA repository
uses: actions/checkout@v4
Expand Down
64 changes: 35 additions & 29 deletions cmd/bffutil/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ func createOrgs(c *cli.Context) (err error) {
testname = "N/A"
}

if user, err = auth0.User.Read(c.String("user")); err != nil {
if user, err = auth0.User.Read(ctx, c.String("user")); err != nil {
return cli.Exit(err, 1)
}

Expand All @@ -613,7 +613,7 @@ func createOrgs(c *cli.Context) (err error) {
return cli.Exit(err, 1)
}

if permissions, err = auth0.User.Permissions(*user.ID); err != nil {
if permissions, err = auth0.User.Permissions(ctx, *user.ID); err != nil {
return cli.Exit(err, 1)
}

Expand Down Expand Up @@ -732,7 +732,7 @@ func createOrgs(c *cli.Context) (err error) {

// Add the user to the organization
appdata.AddOrganization(org.Id)
if err = SaveAppMetadata(*user.ID, *appdata); err != nil {
if err = SaveAppMetadata(ctx, *user.ID, *appdata); err != nil {
return cli.Exit(err, 1)
}
return nil
Expand Down Expand Up @@ -846,6 +846,9 @@ func deleteOrgs(c *cli.Context) (err error) {
return cli.Exit("can only delete one organization at a time", 1)
}

ctx, cancel := utils.WithDeadline(context.Background())
defer cancel()

var org *models.Organization
if org, err = GetOrg(c.Args().Get(0)); err != nil {
return cli.Exit(err, 1)
Expand All @@ -861,7 +864,7 @@ func deleteOrgs(c *cli.Context) (err error) {
}

var user *management.User
if user, err = auth0.User.Read(collaborator.UserId); err != nil {
if user, err = auth0.User.Read(ctx, collaborator.UserId); err != nil {
return cli.Exit(fmt.Errorf("could not fetch user for %s", collaborator.Email), 1)
}

Expand Down Expand Up @@ -904,14 +907,11 @@ func deleteOrgs(c *cli.Context) (err error) {
}
}

if err = SaveAppMetadata(uid, *umeta); err != nil {
if err = SaveAppMetadata(ctx, uid, *umeta); err != nil {
return cli.Exit(err, 1)
}
}

ctx, cancel := utils.WithDeadline(context.Background())
defer cancel()

// Last step: delete the organization from the database
if err = db.DeleteOrganization(ctx, org.UUID()); err != nil {
return cli.Exit(err, 1)
Expand Down Expand Up @@ -1007,7 +1007,7 @@ func cleanupOrgs(c *cli.Context) (err error) {
}

var user *management.User
if user, err = auth0.User.Read(collaborator.UserId); err != nil {
if user, err = auth0.User.Read(ctx, collaborator.UserId); err != nil {
fmt.Printf("could not get user details for %q: %s\n", collaborator.UserId, err)
continue
}
Expand Down Expand Up @@ -1063,9 +1063,12 @@ func addCollab(c *cli.Context) (err error) {
return cli.Exit(err, 1)
}

ctx, cancel := utils.WithDeadline(context.Background())
defer cancel()

// Fetch the user from auth0.
var user *management.User
if user, err = auth0.User.Read(c.String("user")); err != nil {
if user, err = auth0.User.Read(ctx, c.String("user")); err != nil {
return cli.Exit(err, 1)
}

Expand All @@ -1076,12 +1079,12 @@ func addCollab(c *cli.Context) (err error) {
}

var roles *management.RoleList
if roles, err = auth0.User.Roles(*user.ID); err != nil {
if roles, err = auth0.User.Roles(ctx, *user.ID); err != nil {
return cli.Exit(err, 1)
}

var permissions *management.PermissionList
if permissions, err = auth0.User.Permissions(*user.ID); err != nil {
if permissions, err = auth0.User.Permissions(ctx, *user.ID); err != nil {
return cli.Exit(err, 1)
}

Expand All @@ -1108,9 +1111,6 @@ func addCollab(c *cli.Context) (err error) {
return cli.Exit(err, 1)
}

ctx, cancel := utils.WithDeadline(context.Background())
defer cancel()

if err = db.UpdateOrganization(ctx, org); err != nil {
return cli.Exit(fmt.Errorf("could not update organization: %w", err), 1)
}
Expand Down Expand Up @@ -1145,7 +1145,7 @@ func addCollab(c *cli.Context) (err error) {

// Update user's app metadata to reflect the user's currently selected organization.
appdata.UpdateOrganization(org)
if err = SaveAppMetadata(*user.ID, *appdata); err != nil {
if err = SaveAppMetadata(ctx, *user.ID, *appdata); err != nil {
return cli.Exit(err, 1)
}
return nil
Expand All @@ -1158,9 +1158,12 @@ func deleteCollab(c *cli.Context) (err error) {
return cli.Exit(err, 1)
}

ctx, cancel := utils.WithDeadline(context.Background())
defer cancel()

// Fetch the user from auth0.
var user *management.User
if user, err = auth0.User.Read(c.String("user")); err != nil {
if user, err = auth0.User.Read(ctx, c.String("user")); err != nil {
return cli.Exit(err, 1)
}

Expand All @@ -1171,12 +1174,12 @@ func deleteCollab(c *cli.Context) (err error) {
}

var roles *management.RoleList
if roles, err = auth0.User.Roles(*user.ID); err != nil {
if roles, err = auth0.User.Roles(ctx, *user.ID); err != nil {
return cli.Exit(err, 1)
}

var permissions *management.PermissionList
if permissions, err = auth0.User.Permissions(*user.ID); err != nil {
if permissions, err = auth0.User.Permissions(ctx, *user.ID); err != nil {
return cli.Exit(err, 1)
}

Expand All @@ -1195,9 +1198,6 @@ func deleteCollab(c *cli.Context) (err error) {
return cli.Exit("canceled at request of user", 0)
}

ctx, cancel := utils.WithDeadline(context.Background())
defer cancel()

// Remove collaborator from the organization (won't error if not exists)
org.DeleteCollaborator(*user.Email)
if err = db.UpdateOrganization(ctx, org); err != nil {
Expand All @@ -1209,7 +1209,7 @@ func deleteCollab(c *cli.Context) (err error) {
appdata.OrgID = appdata.Organizations[0]
}

if err = SaveAppMetadata(*user.ID, *appdata); err != nil {
if err = SaveAppMetadata(ctx, *user.ID, *appdata); err != nil {
return cli.Exit(err, 1)
}

Expand Down Expand Up @@ -1271,9 +1271,12 @@ func exportEmails(c *cli.Context) (err error) {
}

func sortAppdataOrgs(c *cli.Context) (err error) {
ctx, cancel := utils.WithDeadline(context.Background())
defer cancel()

// Get all users in the tenant
var users *management.UserList
if users, err = auth0.User.List(); err != nil {
if users, err = auth0.User.List(ctx); err != nil {
return cli.Exit(err, 1)
}

Expand Down Expand Up @@ -1303,7 +1306,7 @@ func sortAppdataOrgs(c *cli.Context) (err error) {

// Update the user's app metadata on the Auth0 tenant
if !c.Bool("dry-run") {
if err = SaveAppMetadata(*user.ID, *appdata); err != nil {
if err = SaveAppMetadata(ctx, *user.ID, *appdata); err != nil {
return cli.Exit(err, 1)
}
fmt.Printf("updated app metadata for user %s (%s)\n", *user.Email, *user.ID)
Expand All @@ -1319,9 +1322,12 @@ func sortAppdataOrgs(c *cli.Context) (err error) {
}

func dedupeAppdataOrgs(c *cli.Context) (err error) {
ctx, cancel := utils.WithDeadline(context.Background())
defer cancel()

// Get all users in the tenant
var users *management.UserList
if users, err = auth0.User.List(); err != nil {
if users, err = auth0.User.List(ctx); err != nil {
return cli.Exit(err, 1)
}

Expand Down Expand Up @@ -1353,7 +1359,7 @@ func dedupeAppdataOrgs(c *cli.Context) (err error) {
fmt.Printf("current org list for user %s (%s): %v\n", *user.Email, *user.ID, appdata.Organizations)

if !c.Bool("dry-run") {
if err = SaveAppMetadata(*user.ID, *appdata); err != nil {
if err = SaveAppMetadata(ctx, *user.ID, *appdata); err != nil {
return cli.Exit(err, 1)
}
}
Expand Down Expand Up @@ -1461,14 +1467,14 @@ func HasPermission(perm string, permissions *management.PermissionList) bool {
return false
}

func SaveAppMetadata(uid string, appdata auth.AppMetadata) (err error) {
func SaveAppMetadata(ctx context.Context, uid string, appdata auth.AppMetadata) (err error) {
// Create a blank user with no data but the app data
user := &management.User{}
if user.AppMetadata, err = appdata.Dump(); err != nil {
return err
}

if err = auth0.User.Update(uid, user); err != nil {
if err = auth0.User.Update(ctx, uid, user); err != nil {
return err
}
return nil
Expand Down
10 changes: 4 additions & 6 deletions cmd/trtlsim/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
crand "crypto/rand"
"crypto/tls"
"crypto/x509"
"errors"
Expand All @@ -28,10 +29,6 @@ import (
"google.golang.org/grpc/status"
)

func init() {
rand.Seed(time.Now().UTC().UnixNano())
}

const (
interval = 10 * time.Second // the ticker interval, default to 5 seconds
sigma = 200 * time.Millisecond // the amount of jitter, default to 100 ms
Expand Down Expand Up @@ -173,7 +170,7 @@ func (s *Simulator) connect() (_ pb.TrtlClient, err error) {

// Connect the replica client
var cc *grpc.ClientConn
if cc, err = grpc.Dial(s.Endpoint, opts...); err != nil {
if cc, err = grpc.NewClient(s.Endpoint, opts...); err != nil {
return nil, err
}
log.Printf("connected to trtl server at %s\n", s.Endpoint)
Expand Down Expand Up @@ -637,6 +634,7 @@ func (t *TRISAModel) reissuer(wg *sync.WaitGroup) {
// User updater randomly updates users' profiles
// This writer may generate stomps, but it's unlikely
func (t *TRISAModel) userProfiles(wg *sync.WaitGroup) {
defer wg.Done()
ticker := jitter.New(reissueInterval, reissueSigma)
for {
<-ticker.C
Expand Down Expand Up @@ -735,7 +733,7 @@ func (t *TRISAModel) Iter(namespace string) (err error) {
func (t *TRISAModel) Put(key, namespace string, nbytes int) (err error) {
// Create a random value of the specified length
value := make([]byte, nbytes)
if _, err = rand.Read(value); err != nil {
if _, err = crand.Read(value); err != nil {
return fmt.Errorf("could not create random value: %v", err)
}

Expand Down
4 changes: 2 additions & 2 deletions containers/bff/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Dynamic Builds
ARG BUILDER_IMAGE=golang:1.19-bullseye
ARG FINAL_IMAGE=debian:bullseye-slim
ARG BUILDER_IMAGE=golang:1.22-bookworm
ARG FINAL_IMAGE=debian:bookworm-slim

# Build Stage
FROM --platform=${BUILDPLATFORM} ${BUILDER_IMAGE} as builder
Expand Down
4 changes: 2 additions & 2 deletions containers/cathy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Dynamic Builds
ARG BUILDER_IMAGE=golang:1.19-bullseye
ARG FINAL_IMAGE=debian:bullseye-slim
ARG BUILDER_IMAGE=golang:1.22-bookworm
ARG FINAL_IMAGE=debian:bookworm-slim

# Build Stage
FROM --platform=${BUILDPLATFORM} ${BUILDER_IMAGE} as builder
Expand Down
4 changes: 2 additions & 2 deletions containers/gds/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Dynamic Builds
ARG BUILDER_IMAGE=golang:1.19-bullseye
ARG FINAL_IMAGE=debian:bullseye-slim
ARG BUILDER_IMAGE=golang:1.22-bookworm
ARG FINAL_IMAGE=debian:bookworm-slim

# Build stage
FROM --platform=${BUILDPLATFORM} ${BUILDER_IMAGE} as builder
Expand Down
Loading

0 comments on commit a8aa033

Please sign in to comment.