Skip to content

TranslClient: use PathValidator to sanitize the request paths#112

Merged
anand-kumar-subramanian merged 5 commits intosonic-net:masterfrom
sachinholla:use_path_validator
Jun 16, 2023
Merged

TranslClient: use PathValidator to sanitize the request paths#112
anand-kumar-subramanian merged 5 commits intosonic-net:masterfrom
sachinholla:use_path_validator

Conversation

@sachinholla
Copy link
Contributor

@sachinholla sachinholla commented May 24, 2023

Why I did it

gNMI specification allows the clients to use both fully qualified and bare yang paths. It also allows omitting wildcard keys. But all translib APIs expect fully qualified yang paths, with wildcard keys explicitly set. Server is expected to set the missing module prefixes and wildcard keys.
Today telemetry server directly passes the paths from the request to translib APIs. Hence it works only if the client uses fully qualified paths.

Part of the gNMI subscription enhancements discussed in HLD sonic-net/SONiC#1287

How I did it

Enhanced the TranslClient to use the PathValidator utility to preprocess get, set and subscribe request paths before calling translib APIs. PathValidator is setup to performs following actions:

  • Verify the get/set/subscribe paths are known to translib
  • Insert missing module name prefixes in get/set/subscribe paths
  • Insert missing wildcard keys in subscribe paths

How to verify it

Gotests

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

TranslClient now uses the PathValidator utility to preprocess get, set
and subscribe request paths before calling translib APIs.
PathValidator is setup to performs following actions:

* Verify the get/set/subscribe paths are known to translib
* Insert missing module name prefixes in get/set/subscribe paths.
  gNMI allows the clients to omit them but translib APIs need them
* Insert missing wildcard keys in subscribe paths

Signed-off-by: Sachin Holla <sachin.holla@broadcom.com>
ayelrod
ayelrod previously approved these changes May 30, 2023
Copy link

@ayelrod ayelrod left a comment

Choose a reason for hiding this comment

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

LGTM

@tomek-US
Copy link
Contributor

tomek-US commented Jun 1, 2023

Please fix the build.

@sachinholla sachinholla force-pushed the use_path_validator branch 10 times, most recently from edf889f to d80fc23 Compare June 2, 2023 14:53
- Set ENABLE_TRANSLIB_WRITE=y during pipeline tests to enable all
  TranslClient based write tests. They were skipped earlier
- Setup correct translib test env in makefile 'check_gotest' target
- Fixed path & payload of existing TranslClient based write tests
- Added more get and set tests to cover path validator calls with
  prefixed and unprefixed paths
- Skip unsupported gNOI tests
@sachinholla sachinholla force-pushed the use_path_validator branch from d80fc23 to 796a459 Compare June 2, 2023 15:18
@sachinholla sachinholla requested a review from ayelrod June 8, 2023 09:35
@zhangyanzhao
Copy link

@ayelrod can you please help to approve this PR? Thanks.

@anand-kumar-subramanian anand-kumar-subramanian merged commit 87d8eb3 into sonic-net:master Jun 16, 2023
zbud-msft added a commit that referenced this pull request Jun 16, 2023
@sachinholla sachinholla deleted the use_path_validator branch August 16, 2023 15:34
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.

5 participants