Skip to content

Conversation

Raezil
Copy link
Contributor

@Raezil Raezil commented Aug 17, 2025

Summary by cubic

Adds Basic Auth to the gRPC transport and expands gNMI Subscribe support (list and per-subscription modes, intervals). Also improves gNMI path parsing with key predicates and updates examples and tests.

  • New Features
    • gRPC Basic Auth: attach username/password via per-RPC metadata; respects TLS setting; provider.json and examples updated.
    • gNMI Subscribe: supports list modes ONCE/POLL/STREAM and sub modes SAMPLE/ON_CHANGE/TARGET_DEFINED.
    • Intervals/flags: accepts sample_interval_ns, heartbeat_interval_ns, suppress_redundant.
    • gNMI paths: parse elements with keys like /interfaces/interface[name=eth0]/state/... into Path.Elem with Key.
    • Examples/tests: example servers enforce creds; clients show auth and subscription options; added tests for path parsing and sub mode.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic analysis

3 issues found across 5 files • Review in cubic

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

u := md.Get("username")
p := md.Get("password")
if len(u) == 0 || len(p) == 0 || u[0] != user || p[0] != pass {
return fmt.Errorf("unauthorized")
Copy link
Contributor

Choose a reason for hiding this comment

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

Returning a generic fmt.Errorf here causes gRPC to translate the error to status code "Unknown", so the client cannot properly detect an authentication failure. Use status.Error(codes.Unauthenticated, …) instead to return the correct gRPC status code.

Prompt for AI agents
Address the following comment on examples/grpc_gnmi_client/main.go at line 38:

<comment>Returning a generic fmt.Errorf here causes gRPC to translate the error to status code &quot;Unknown&quot;, so the client cannot properly detect an authentication failure. Use status.Error(codes.Unauthenticated, …) instead to return the correct gRPC status code.</comment>

<file context>
@@ -14,18 +14,43 @@ import (
 	&quot;github.com/universal-tool-calling-protocol/go-utcp/src/repository&quot;
 
 	&quot;google.golang.org/grpc&quot;
+	&quot;google.golang.org/grpc/metadata&quot;
 )
 
 type UnifiedServer struct {
 	grpcpb.UnimplementedUTCPServiceServer
 	gnmi.UnimplementedGNMIServer
</file context>

"auth": {
"auth_type": "basic",
"username": "alice",
"password": "secret"
Copy link
Contributor

Choose a reason for hiding this comment

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

Hard-coded plaintext credential exposes a real-looking password in the repository and risks accidental leakage; replace with a placeholder or environment substitution.

Prompt for AI agents
Address the following comment on examples/grpc_gnmi_client/provider.json at line 13:

<comment>Hard-coded plaintext credential exposes a real-looking password in the repository and risks accidental leakage; replace with a placeholder or environment substitution.</comment>

<file context>
@@ -6,7 +6,12 @@
       &quot;host&quot;: &quot;127.0.0.1&quot;,
       &quot;port&quot;: 9339,
       &quot;service_name&quot;: &quot;gnmi.gNMI&quot;,
-      &quot;method_name&quot;: &quot;Subscribe&quot;
+      &quot;method_name&quot;: &quot;Subscribe&quot;,
+      &quot;auth&quot;: {
+        &quot;auth_type&quot;: &quot;basic&quot;,
+        &quot;username&quot;: &quot;alice&quot;,
+        &quot;password&quot;: &quot;secret&quot;
</file context>
Suggested change
"password": "secret"
"password": "${GNMI_PASSWORD}"

}, nil
}

func (b basicPerRPCCreds) RequireTransportSecurity() bool { return b.requireTLS }
Copy link
Contributor

Choose a reason for hiding this comment

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

Returning the provider’s UseSSL flag here allows the client to transmit basic-auth credentials over an insecure gRPC connection when UseSSL is false, exposing the username/password on the wire. PerRPCCredentials implementations that carry secrets should always require transport security (or otherwise internally enforce encryption) to avoid accidental leakage.

(Based on your team’s feedback about preventing insecure transmission of sensitive data.)

Prompt for AI agents
Address the following comment on src/transports/grpc/grpc_transport.go at line 41:

<comment>Returning the provider’s UseSSL flag here allows the client to transmit basic-auth credentials over an insecure gRPC connection when UseSSL is false, exposing the username/password on the wire. PerRPCCredentials implementations that carry secrets should always require transport security (or otherwise internally enforce encryption) to avoid accidental leakage.

(Based on your team’s feedback about preventing insecure transmission of sensitive data.)</comment>

<file context>
@@ -24,6 +25,21 @@ import (
 	. &quot;github.com/universal-tool-calling-protocol/go-utcp/src/tools&quot;
 )
 
+type basicPerRPCCreds struct {
+	username   string
+	password   string
+	requireTLS bool
+}
+
</file context>
Suggested change
func (b basicPerRPCCreds) RequireTransportSecurity() bool { return b.requireTLS }
func (b basicPerRPCCreds) RequireTransportSecurity() bool { return true }

@Raezil Raezil closed this Aug 17, 2025
@Raezil Raezil deleted the codex/fix-issue-#124-in-go-utcp branch August 17, 2025 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant