Skip to content
This repository was archived by the owner on Jul 20, 2026. It is now read-only.
This repository was archived by the owner on Jul 20, 2026. It is now read-only.

findValOfKey regex silently truncates JSON values  #63

Description

@mdryaaan

Description

findValOfKey in tests/e2e/common.go extracts JSON values using a regex:

keystr := "\"" + key + "\":[^,;\\]}]*"

The character class [^,;\\]}]* stops at the first comma, semicolon, ], or }. This silently truncates any value containing those characters, returning wrong data without any error.

Steps to Reproduce

cd /mnt/c/Users/alikh/Desktop/Projects/urunc_test
go test ./tests/e2e/ -run TestFindValOfKey -v

Output:

Image

Expected Behavior

findValOfKey should return the correct value for any valid JSON, regardless of value complexity.

Current Behavior

The regex stops at the first comma inside a string value ("foo,bar"foo) and at the first } in a nested object, then the split-on-colon further mangles the result ({"IPAddress":"172.17.0.2"}{IPAddress).

Proposed Solution

Replace the regex with encoding/json unmarshalling and a recursive key search.

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