Audit Node driver to find implicit buffer-to-string conversions

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Use Case

      As a... Node Driver developer
      I want... to ensure we aren't making implicit toString calls against Buffers
      So that... the Driver continues to work in non-Node envs (like Deno)

      User Experience

      • Node Driver works without issues in non-Node envs, like Deno
      • Avoid situation like https://jira.mongodb.org/browse/NODE-7548
      • lint rule no-base-to-string is almost what we want, except the rule flags types whose toString() declaration lives on the Object interface — types that inherit Object.prototype.toString and produce [object Something]. But Uint8Array in TypeScript's lib has its own toString() declaration (not on Object), so the rule considers it fine.
      • Add modified version of the no-base-to-string lint rule that checks for Uint8Array toString calls
      • The tricky part for this repo: .eslintrc.json (legacy format) doesn't support inline plugins easily. We'd need either a local eslint-plugin-mongodb package in the repo, or migrate the config to the new flat config format (which supports inline plugin objects directly).
      • Might be a good time to update our eslint format

      Dependencies

      • None

      Risks/Unknowns

      • We may uncover a lot of problematic cases
      • We may uncover cases that we can't (easily) fix
      • Eslint format upgrade may identify eslint issues

      Acceptance Criteria

      Implementation Requirements

      • We have verified that we have no more implicit toString calls made on Buffer structure
      • We have mechanisms in place to notify us (eg build break) that we have introduced an implicit toString call

      Testing Requirements

      • all tests are passing
      • if an implicit toString is added, tests should fail

      Documentation Requirements

      • Mention that this type of bug is gone and non-Node envs should be better supported now

      Follow Up Requirements

      • None

            Assignee:
            Unassigned
            Reporter:
            Pavel Safronov
            None
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: