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

Add example of JSON pointers using array indexes. #1501

Merged

Conversation

kenfdev
Copy link
Contributor

@kenfdev kenfdev commented Jun 18, 2019

A very small change to the docs but I found the current explanation a bit obscure.

https://www.openpolicyagent.org/docs/latest/decision-logs/#masking-sensitive-data

For people who are familiar with JSON Pointers, I thinks it's obvious to use array indices, but for others, maybe it's better to show examples.

In addition, was thinking about adding a detailed example like below but left it as a simple phrase.

Things I've tested

mask["/input/secrets/0"]

Result (Example of pointers to array not taking effect)

{
  "decision_id": "6b8fda76-ae6c-4b63-b1bb-34384c8c3c7c",
  "erased": ["/input/password"],
  "input": {
    "name": "bob",
    "resource": "user",
    "secrets": [{ "value": "secret1" }, { "value": "secret2" }]
  },
  "labels": {
    "id": "75f51a30-3906-46b5-bb1e-4da3496de0f6",
    "version": "0.13.0-dev"
  },
  "level": "info",
  "metrics": {
    "timer_rego_module_compile_ns": 301,
    "timer_rego_module_parse_ns": 508,
    "timer_rego_query_compile_ns": 433436,
    "timer_rego_query_eval_ns": 64411,
    "timer_rego_query_parse_ns": 476805,
    "timer_server_handler_ns": 3727650
  },
  "msg": "Decision Log",
  "path": "foo/allow",
  "requested_by": "172.17.0.1:51764",
  "result": true,
  "time": "2019-06-18T14:16:36Z",
  "timestamp": "2019-06-18T14:16:36.15410267Z"
}

mask["/input/secrets/0/value"]

Result(Example of pointer to object inside an array which is allowed)

{
  "decision_id": "8f19f901-11d4-47eb-8ba0-3955630161b4",
  "erased": ["/input/secrets/0/value", "/input/password"],
  "input": {
    "name": "bob",
    "resource": "user",
    "secrets": [{}, { "value": "secret2" }]
  },
  "labels": {
    "id": "602eba22-876c-48b5-a484-ce549579b54b",
    "version": "0.13.0-dev"
  },
  "level": "info",
  "metrics": {
    "timer_rego_module_compile_ns": 265,
    "timer_rego_module_parse_ns": 414,
    "timer_rego_query_compile_ns": 202855,
    "timer_rego_query_eval_ns": 52394,
    "timer_rego_query_parse_ns": 659617,
    "timer_server_handler_ns": 2423068
  },
  "msg": "Decision Log",
  "path": "foo/allow",
  "requested_by": "172.17.0.1:51768",
  "result": true,
  "time": "2019-06-18T14:17:29Z",
  "timestamp": "2019-06-18T14:17:29.265131767Z"
}

I would appreciate any feedback :)
Thank you!

Add specific example using array indexes to show what expression is
allowed and what is not explicitly.

Signed-off-by: Ken Fukuyama <kenfdev@gmail.com>
Copy link
Member

@tsandall tsandall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tsandall tsandall merged commit 4412102 into open-policy-agent:master Jun 19, 2019
@tsandall
Copy link
Member

Thanks @kenfdev !

@kenfdev kenfdev deleted the improve-decision-logs-docs branch August 10, 2019 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants