Skip to content

refactor(application): share bounded JSON traversal logic for workspace and evidence bundle readers #193

Closed

Description

@morluto

Problem

InvestigationWorkspaceStore and BoundedJsonFiles both enforce EvidenceFilePolicy limits through their own stack-based JSON traversal. The logic is currently duplicated across two modules and has already been the source of a real enforcement bug in one path in this codebase.

Evidence

  • src/application/BoundedJsonFiles.ts (readBoundedJson)
  • src/application/InvestigationWorkspaceStore.ts (withinJsonLimits)

Both implementations are separate and easy to drift, so a policy bug can reappear in one consumer without test coverage in the other.

Impact

  • Risk of inconsistent enforcement of maxDepth / maxNodes / maxStringLength between evidence bundle reads and investigation workspace reads.
  • Increased maintenance burden as constraints evolve.

Suggested fix

  • Extract a shared bounded-json validator utility and use it from both modules.
  • Add regression tests in both read paths to cover nested object/array traversal and depth/node limits.

Activity

  1. added
    enhancement
    area: evidence
    on Oct 12, 2026
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

    area: evidenceenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions