Skip to content

Commit

Permalink
fix: correct lengths on random.Generate
Browse files Browse the repository at this point in the history
  • Loading branch information
abelanger5 committed Jun 25, 2024
1 parent 771054a commit 1ef1c46
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion api/v1/server/authn/session_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (s *SessionHelpers) SaveOAuthState(
c echo.Context,
integration string,
) (string, error) {
state, err := random.Generate(16)
state, err := random.Generate(32)

if err != nil {
return "", err
Expand Down
4 changes: 2 additions & 2 deletions cmd/hatchet-admin/cli/quickstart.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ func setupCerts(generated *generatedConfigFiles) error {
func generateKeys(generated *generatedConfigFiles) error {
color.New(color.FgGreen).Printf("Generating encryption keys for Hatchet server\n")

cookieHashKey, err := random.Generate(8)
cookieHashKey, err := random.Generate(16)

if err != nil {
return fmt.Errorf("could not generate hash key for instance: %w", err)
}

cookieBlockKey, err := random.Generate(8)
cookieBlockKey, err := random.Generate(16)

if err != nil {
return fmt.Errorf("could not generate block key for instance: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion internal/msgqueue/rabbitmq/rabbitmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func (t *MessageQueueImpl) initQueue(sub session, q msgqueue.Queue) (string, err
name := q.Name()

if q.FanoutExchangeKey() != "" {
suffix, err := random.Generate(4)
suffix, err := random.Generate(8)

if err != nil {
t.l.Error().Msgf("error generating random bytes: %v", err)
Expand Down
6 changes: 3 additions & 3 deletions internal/msgqueue/rabbitmq/rabbitmq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestMessageQueueIntegration(t *testing.T) {

require.NotNil(t, tq, "task queue implementation should not be nil")

id, _ := random.Generate(4) // nolint: errcheck
id, _ := random.Generate(8) // nolint: errcheck

// Test adding a task to a static queue
staticQueue := msgqueue.EVENT_PROCESSING_QUEUE
Expand Down Expand Up @@ -116,7 +116,7 @@ func TestDeadLetteringSuccess(t *testing.T) {

require.NotNil(t, tq, "task queue implementation should not be nil")

id, _ := random.Generate(4) // nolint: errcheck
id, _ := random.Generate(8) // nolint: errcheck

// Test adding a task to a static queue
staticQueue := msgqueue.EVENT_PROCESSING_QUEUE
Expand Down Expand Up @@ -174,7 +174,7 @@ func TestDeadLetteringExceedRetriesFailure(t *testing.T) {

require.NotNil(t, tq, "task queue implementation should not be nil")

id, _ := random.Generate(4) // nolint: errcheck
id, _ := random.Generate(8) // nolint: errcheck

// Test adding a task to a static queue
staticQueue := msgqueue.EVENT_PROCESSING_QUEUE
Expand Down
2 changes: 1 addition & 1 deletion internal/services/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func (w *WorkerImpl) handleStartPullRequest(ctx worker.HatchetContext) error {
return true
})

prSuffix, err := random.Generate(4)
prSuffix, err := random.Generate(8)

if err != nil {
return fmt.Errorf("could not generate random bytes: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/repository/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewGithubWebhookCreateOpts(
repoOwner string,
repoName string,
) (opts *CreateGithubWebhookOpts, signingSecret string, err error) {
signingSecret, err = random.Generate(16)
signingSecret, err = random.Generate(32)

if err != nil {
return nil, "", fmt.Errorf("failed to generate signing secret: %s", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion pkg/repository/workflow_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func GetCreateWorkflowRunOptsFromSchedule(
}

func getWorkflowRunDisplayName(workflowName string) string {
workflowSuffix, _ := random.Generate(3)
workflowSuffix, _ := random.Generate(6)

return workflowName + "-" + workflowSuffix
}
Expand Down

0 comments on commit 1ef1c46

Please sign in to comment.