Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-3306

Investigate using Ruby's internal random utility instead of rand for ObjectId's

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • bson-5.0.0
    • Affects Version/s: None
    • Component/s: BSON
    • None

      In order to satisfy the ObjectId generation spec, the native C extension uses arc4random if it is available, and falls back to using the stdlib rand function otherwise.

      GitHub user midnight-wonderer suggested using Ruby's internal random utility instead, which is used to implement Ruby's SecureRandom module. It's worth taking a look, as this would make the ObjectId generation more spec-compliant.

      The investigation could start here: https://github.com/ruby/ruby/blob/7380c7/internal/random.h . If the random implementation there meets our needs, it shouldn't be difficult to change the native extension to use it.

            Assignee:
            jamis.buck@mongodb.com Jamis Buck
            Reporter:
            jamis.buck@mongodb.com Jamis Buck
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: