Skip to content

Conversation

@ishanarya0
Copy link
Member

No description provided.

@ishanarya0
Copy link
Member Author

ishanarya0 commented Jun 21, 2022

This gives one False Negative, but will ensure that the user can't pass a null value.

A few examples of accepted and not-accepted cases:

ACCEPTED
{
  "host": "http:0.0.0.0:1234",
  "insecure": true,
  "token": "token"
}
NOT ACCEPTED
{
  "host": "http:0.0.0.0:1234",
  "insecure": false,
  "token": "token"
}
ACCEPTED
{
  "host": "http:0.0.0.0:1234",
  "insecure": false,
  "cluster_ca_certificate": "c_ca_cert",
  "token": "token"
}
ACCEPTED
{
  "host": "http:0.0.0.0:1234",
  "cluster_ca_certificate": "c_ca_cert",
  "token": "token"
}
ACCEPTED
{
  "host": "http:0.0.0.0:1234",
  "insecure": true,
  "client_key": "c_key",
  "client_certificate": "c_cert"
}
NOT ACCEPTED
{
  "host": "http:0.0.0.0:1234",
  "insecure": true,
  "client_key": "c_key"
}
NOT ACCEPTED
  "host": "http:0.0.0.0:1234",
  "insecure": true,
  "token": "token",
  "client_key": "c_key",
  "client_certificate": "c_cert"
}

(FALSE NEGATIVE - should be accepted since the token value is present)
ACCEPTED
{
  "host": "http:0.0.0.0:1234",
  "insecure": true,
  "token": "token",
  "client_key": "c_key"
}

(NOTE: it doesn't matter if `client_certificate` is not present, as the token value can be used by entropy)

@ishanarya0 ishanarya0 requested review from rohilsurana and spy16 and removed request for spy16 June 21, 2022 14:11
@rohilsurana
Copy link
Member

These test cases are awesome. Can we also write a small test for the json-schema using the test cases mentioned above? This would make sure changes in future can be tested easily as well.

We can do the same for all the other schemas we have in future.

@ishanarya0
Copy link
Member Author

These test cases are awesome. Can we also write a small test for the json-schema using the test cases mentioned above? This would make sure changes in future can be tested easily as well.

We can do the same for all the other schemas we have in future.

Sounds good! I'll add them.

@ishanarya0 ishanarya0 requested a review from rohilsurana June 29, 2022 07:36
@rohilsurana rohilsurana merged commit 4022063 into main Jul 1, 2022
@rohilsurana rohilsurana deleted the jsonschema branch July 1, 2022 07:45
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.

[Module][Kubernetes] Add conditional checks to JSONSchema validation for token vs client key auth

3 participants