Skip to content

Risky Time.Now() Usage #1358

Description

@Hellobloc

Introduction

In this following code,the usage of time.Now in the key length is not a good practice for Non-determinism risk. In a wrong system time, the key length could be 30.

https://github.com/desmos-labs/desmos/blob/f6e7642a635cd0c0b7f6f2daf627c4aa11d924c9/x/posts/types/keys.go#L153C2-L153C54

Recommend Code

[-]var lenTime = len(sdk.FormatTimeBytes(time.Now()))
// The lenTime default is 29.
[+]var lenTime = 29

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions