Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a JSON redactor #1457

Open
banjoh opened this issue Feb 6, 2024 · 1 comment
Open

Create a JSON redactor #1457

banjoh opened this issue Feb 6, 2024 · 1 comment
Labels
type::feature New feature or request

Comments

@banjoh
Copy link
Member

banjoh commented Feb 6, 2024

Describe the rationale for the suggested feature.

Troubleshoot has a YAML redactor that is used to redact values in a YAML file selected using this yamlPath selector syntax. Since we collect JSON files in support bundles, having a similar redactor that behaves the same as the YAML redactor would be beneficial

Describe the feature

Given the below input

{
  "abc": {
    "a": {
      "alpha": "bravo",
      "charlie": "delta"
    },
    "c": {
      "charlie": "delta",
      "echo": "foxtrot"
    }
  },
  "xyz": [
    {
      "xray": "yankee",
      "zulu": "alpha"
    },
    {
      "zulu": "alpha",
      "bravo": "charlie"
    }
  ]
}

A redactor of abc.*.charlie would remove the values for abc.a.charlie and abc.c.charlie, yielding

{
  "abc": {
    "a": {
      "alpha": "bravo",
      "charlie": "***HIDDEN***"
    },
    "c": {
      "charlie": "***HIDDEN***",
      "echo": "foxtrot"
    }
  },
  "xyz": [
    {
      "xray": "yankee",
      "zulu": "alpha"
    },
    {
      "zulu": "alpha",
      "bravo": "charlie"
    }
  ]
}

Describe alternatives you've considered

Using the current set of redactors such as the regex redactor to craft complex redactors for extracting values

Additional context

This redactor will behave the same as the YAML redactor. The implementation will be quite similar, the deference being conversions from JSON to Go objects and back. Some of the code such a redactYaml which is used to search for elements in the extracted Go structure should be reused.

@banjoh banjoh added the type::feature New feature or request label Feb 6, 2024
@banjoh
Copy link
Member Author

banjoh commented Feb 6, 2024

Once this feature is implemented, we need to add a default redactor to redact kURL installer specs of JSON type

Refer to #1455 bug for context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type::feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant