Skip to content

Conversation

@niranjanivivek
Copy link

@niranjanivivek niranjanivivek commented Nov 7, 2025

This code implements the Pathz feature which is the policy-based authorization for gNMI read/write access.

Backend Base PR : #183 (Must be merged first)
Backend Incremental PR : #196
Current PR : #537

gNSI Pathz UT Results:

=== RUN TestGnsiPathzRotation
=== RUN TestGnsiPathzRotation/RotateOpenClose
=== RUN TestGnsiPathzRotation/RotateAuthenticationFailure
=== RUN TestGnsiPathzRotation/RotateStreamRecvError
=== RUN TestGnsiPathzRotation/RotateStreamSendError
=== RUN TestGnsiPathzRotation/RotatePolicyEmptyUploadRequest
=== RUN TestGnsiPathzRotation/RotatePolicyEmptyRequest
=== RUN TestGnsiPathzRotation/RotatePolicyWrongPolicyProto
=== RUN TestGnsiPathzRotation/RotatePolicyNoVersion
=== RUN TestGnsiPathzRotation/RotatePolicySuccess
=== RUN TestGnsiPathzRotation/RotatePolicyNoFinalize
=== RUN TestGnsiPathzRotation/FinalizeNoRotate
=== RUN TestGnsiPathzRotation/RotateTheSamePolicyTwice
=== RUN TestGnsiPathzRotation/RotateTheSamePolicyTwiceWithForceOverwrite
=== RUN TestGnsiPathzRotation/ParallelRotationCalls
--- PASS: TestGnsiPathzRotation (5.24s)
--- PASS: TestGnsiPathzRotation/RotateOpenClose (0.04s)
--- PASS: TestGnsiPathzRotation/RotateAuthenticationFailure (0.01s)
--- PASS: TestGnsiPathzRotation/RotateStreamRecvError (0.03s)
--- PASS: TestGnsiPathzRotation/RotateStreamSendError (0.01s)
--- PASS: TestGnsiPathzRotation/RotatePolicyEmptyUploadRequest (0.05s)
--- PASS: TestGnsiPathzRotation/RotatePolicyEmptyRequest (0.02s)
--- PASS: TestGnsiPathzRotation/RotatePolicyWrongPolicyProto (0.03s)
--- PASS: TestGnsiPathzRotation/RotatePolicyNoVersion (0.02s)
--- PASS: TestGnsiPathzRotation/RotatePolicySuccess (0.03s)
--- PASS: TestGnsiPathzRotation/RotatePolicyNoFinalize (0.03s)
--- PASS: TestGnsiPathzRotation/FinalizeNoRotate (0.02s)
--- PASS: TestGnsiPathzRotation/RotateTheSamePolicyTwice (0.05s)
--- PASS: TestGnsiPathzRotation/RotateTheSamePolicyTwiceWithForceOverwrite (0.05s)
--- PASS: TestGnsiPathzRotation/ParallelRotationCalls (0.05s)
=== RUN TestGnsiPathzUnimplemented
=== RUN TestGnsiPathzUnimplemented/ProbeUnimplemented
=== RUN TestGnsiPathzUnimplemented/GetUnimplemented
--- PASS: TestGnsiPathzUnimplemented (1.72s)
--- PASS: TestGnsiPathzUnimplemented/ProbeUnimplemented (0.01s)
--- PASS: TestGnsiPathzUnimplemented/GetUnimplemented (0.00s)
=== RUN TestGnsiPathzMisc
=== RUN TestGnsiPathzMisc/PathzCopyFile
=== RUN TestGnsiPathzMisc/PathzCopyNonRegularFile
=== RUN TestGnsiPathzMisc/PathzCopyFileDstErr
=== RUN TestGnsiPathzMisc/PathzCopyFileSrcErr
=== RUN TestGnsiPathzMisc/PathzFileCheckNonRegularFile
--- PASS: TestGnsiPathzMisc (1.05s)
--- PASS: TestGnsiPathzMisc/PathzCopyFile (0.00s)
--- PASS: TestGnsiPathzMisc/PathzCopyNonRegularFile (0.00s)
--- PASS: TestGnsiPathzMisc/PathzCopyFileDstErr (0.00s)
--- PASS: TestGnsiPathzMisc/PathzCopyFileSrcErr (0.00s)
--- PASS: TestGnsiPathzMisc/PathzFileCheckNonRegularFile (0.00s)
=== RUN TestWriteCredentialsMetadataToDB
=== RUN TestWriteCredentialsMetadataToDB/Success_NoKey
=== RUN TestWriteCredentialsMetadataToDB/Success_WithKey
=== RUN TestWriteCredentialsMetadataToDB/Failure_GetRedisDBClientError
=== RUN TestWriteCredentialsMetadataToDB/Failure_HSetError
--- PASS: TestWriteCredentialsMetadataToDB (0.00s)
--- PASS: TestWriteCredentialsMetadataToDB/Success_NoKey (0.00s)
--- PASS: TestWriteCredentialsMetadataToDB/Success_WithKey (0.00s)
--- PASS: TestWriteCredentialsMetadataToDB/Failure_GetRedisDBClientError (0.00s)
--- PASS: TestWriteCredentialsMetadataToDB/Failure_HSetError (0.00s)
=== RUN TestGetRedisDBClientReal
=== RUN TestGetRedisDBClientReal/Success
=== RUN TestGetRedisDBClientReal/NewClientNil
=== RUN TestGetRedisDBClientReal/PingError
--- PASS: TestGetRedisDBClientReal (0.00s)
--- PASS: TestGetRedisDBClientReal/Success (0.00s)
--- PASS: TestGetRedisDBClientReal/NewClientNil (0.00s)
--- PASS: TestGetRedisDBClientReal/PingError (0.00s)
=== RUN TestGetKey
=== RUN TestGetKey/Empty
=== RUN TestGetKey/Single
=== RUN TestGetKey/Multiple
=== RUN TestGetKey/WithEmpty
--- PASS: TestGetKey (0.00s)
--- PASS: TestGetKey/Empty (0.00s)
--- PASS: TestGetKey/Single (0.00s)
--- PASS: TestGetKey/Multiple (0.00s)
--- PASS: TestGetKey/WithEmpty (0.00s)
=== RUN TestCopyFile
=== RUN TestCopyFile/Success
=== RUN TestCopyFile/SrcNotExist
=== RUN TestCopyFile/SrcIsNotRegularFile
=== RUN TestCopyFile/DstParentNotExist
--- PASS: TestCopyFile (0.00s)
--- PASS: TestCopyFile/Success (0.00s)
--- PASS: TestCopyFile/SrcNotExist (0.00s)
--- PASS: TestCopyFile/SrcIsNotRegularFile (0.00s)
--- PASS: TestCopyFile/DstParentNotExist (0.00s)
=== RUN TestFileCheck
=== RUN TestFileCheck/RegularFile
=== RUN TestFileCheck/NonExistentFile
=== RUN TestFileCheck/IsDirectory
=== RUN TestFileCheck/SymlinkToFile
=== RUN TestFileCheck/SymlinkToDir
--- PASS: TestFileCheck (0.00s)
--- PASS: TestFileCheck/RegularFile (0.00s)
--- PASS: TestFileCheck/NonExistentFile (0.00s)
--- PASS: TestFileCheck/IsDirectory (0.00s)
--- PASS: TestFileCheck/SymlinkToFile (0.00s)
--- PASS: TestFileCheck/SymlinkToDir (0.00s)

gNSI Pathz Authorization UT Results:
=== RUN TestGnsiPathzPolicyConfigError
--- PASS: TestGnsiPathzPolicyConfigError (0.00s)
=== RUN TestGnsiPathzPolicyChecker
=== RUN TestGnsiPathzPolicyChecker/Undefined_mode
=== RUN TestGnsiPathzPolicyChecker/No_matched_rule
=== RUN TestGnsiPathzPolicyChecker/No_matched_prefix_rule
=== RUN TestGnsiPathzPolicyChecker/Exact_path_match_with_no_key
=== RUN TestGnsiPathzPolicyChecker/Group_match
=== RUN TestGnsiPathzPolicyChecker/Prefix_match
=== RUN TestGnsiPathzPolicyChecker/Root_match
=== RUN TestGnsiPathzPolicyChecker/Root_request
=== RUN TestGnsiPathzPolicyChecker/Wildcard_Key_match
=== RUN TestGnsiPathzPolicyChecker/User_match
=== RUN TestGnsiPathzPolicyChecker/Exact_Key_match
=== RUN TestGnsiPathzPolicyChecker/Deny_overwrites_permit
=== RUN TestGnsiPathzPolicyChecker/Exact_key_match_on_first_key
=== RUN TestGnsiPathzPolicyChecker/Deny_overwrites_permit_in_group
=== RUN TestGnsiPathzPolicyChecker/Multiple_key_match
=== RUN TestGnsiPathzPolicyChecker/Multiple_key_match_wildcard
--- PASS: TestGnsiPathzPolicyChecker (0.00s)
--- PASS: TestGnsiPathzPolicyChecker/Undefined_mode (0.00s)
--- PASS: TestGnsiPathzPolicyChecker/No_matched_rule (0.00s)
--- PASS: TestGnsiPathzPolicyChecker/No_matched_prefix_rule (0.00s)
--- PASS: TestGnsiPathzPolicyChecker/Exact_path_match_with_no_key (0.00s)
--- PASS: TestGnsiPathzPolicyChecker/Group_match (0.00s)
--- PASS: TestGnsiPathzPolicyChecker/Prefix_match (0.00s)
--- PASS: TestGnsiPathzPolicyChecker/Root_match (0.00s)
--- PASS: TestGnsiPathzPolicyChecker/Root_request (0.00s)
--- PASS: TestGnsiPathzPolicyChecker/Wildcard_Key_match (0.00s)
--- PASS: TestGnsiPathzPolicyChecker/User_match (0.00s)
--- PASS: TestGnsiPathzPolicyChecker/Exact_Key_match (0.00s)
--- PASS: TestGnsiPathzPolicyChecker/Deny_overwrites_permit (0.00s)
--- PASS: TestGnsiPathzPolicyChecker/Exact_key_match_on_first_key (0.00s)
--- PASS: TestGnsiPathzPolicyChecker/Deny_overwrites_permit_in_group (0.00s)
--- PASS: TestGnsiPathzPolicyChecker/Multiple_key_match (0.00s)
--- PASS: TestGnsiPathzPolicyChecker/Multiple_key_match_wildcard (0.00s)
=== RUN TestGnsiPathzPolicyNil
=== RUN TestGnsiPathzPolicyNil/Authorize
=== RUN TestGnsiPathzPolicyNil/AuthorizeWithPrefix
=== RUN TestGnsiPathzPolicyNil/UpdatePolicyFromFile
=== RUN TestGnsiPathzPolicyNil/UpdatePolicyFromProto
=== RUN TestGnsiPathzPolicyNil/GetPolicy
=== RUN TestGnsiPathzPolicyNil/insertPath
=== RUN TestGnsiPathzPolicyNil/authorize
=== RUN TestGnsiPathzPolicyNil/updatePermission
--- PASS: TestGnsiPathzPolicyNil (0.00s)
--- PASS: TestGnsiPathzPolicyNil/Authorize (0.00s)
--- PASS: TestGnsiPathzPolicyNil/AuthorizeWithPrefix (0.00s)
--- PASS: TestGnsiPathzPolicyNil/UpdatePolicyFromFile (0.00s)
--- PASS: TestGnsiPathzPolicyNil/UpdatePolicyFromProto (0.00s)
--- PASS: TestGnsiPathzPolicyNil/GetPolicy (0.00s)
--- PASS: TestGnsiPathzPolicyNil/insertPath (0.00s)
--- PASS: TestGnsiPathzPolicyNil/authorize (0.00s)
--- PASS: TestGnsiPathzPolicyNil/updatePermission (0.00s)

Why I did it

How I did it

How to verify it

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)

@mssonicbld
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@niranjanivivek
Copy link
Author

niranjanivivek commented Dec 26, 2025

Hi @ndas7 and @rlucus , @kishanps Please review .

@niranjanivivek
Copy link
Author

/azp run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 537 in repo sonic-net/sonic-gnmi

Signed-off-by: Niranjani Vivek <niranjaniv@google.com>
@mssonicbld
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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.

4 participants