@@ -103,6 +103,7 @@ def __init__(  # noqa: PLR0913, PLR0915
103103        trace : bool  =  False ,
104104        quiet : bool  =  False ,
105105        ca_cert : str  =  None ,
106+         grpc_ssl_target : str  =  None ,
106107        api_key : str  =  None ,
107108        ver_details : str  =  None ,
108109        timeout : int  =  600 ,
@@ -132,6 +133,7 @@ def __init__(  # noqa: PLR0913, PLR0915
132133        self .timeout  =  timeout 
133134        self .proxy  =  proxy 
134135        self .grpc_proxy  =  grpc_proxy 
136+         self .grpc_ssl_target  =  grpc_ssl_target 
135137        self .pac  =  pac 
136138        self .req_headers  =  req_headers 
137139        self .metadata  =  []
@@ -171,17 +173,26 @@ def __init__(  # noqa: PLR0913, PLR0915
171173            self .provenance_stub  =  GeoProvenanceStub (grpc .insecure_channel (self .url ))
172174            self .scanning_stub  =  ScanningStub (grpc .insecure_channel (self .url ))
173175        else :
176+             channel_options  =  []
177+             if  self .grpc_ssl_target :
178+                 channel_options .append (('grpc.ssl_target_name_override' , self .grpc_ssl_target ))
179+ 
174180            if  ca_cert  is  not   None :
175181                credentials  =  grpc .ssl_channel_credentials (cert_data )  # secure with specified certificate 
176182            else :
177183                credentials  =  grpc .ssl_channel_credentials ()  # secure connection with default certificate 
178-             self .comp_search_stub  =  ComponentsStub (grpc .secure_channel (self .url , credentials ))
179-             self .crypto_stub  =  CryptographyStub (grpc .secure_channel (self .url , credentials ))
180-             self .dependencies_stub  =  DependenciesStub (grpc .secure_channel (self .url , credentials ))
181-             self .semgrep_stub  =  SemgrepStub (grpc .secure_channel (self .url , credentials ))
182-             self .vuln_stub  =  VulnerabilitiesStub (grpc .secure_channel (self .url , credentials ))
183-             self .provenance_stub  =  GeoProvenanceStub (grpc .secure_channel (self .url , credentials ))
184-             self .scanning_stub  =  ScanningStub (grpc .secure_channel (self .url , credentials ))
184+ 
185+             self .comp_search_stub  =  ComponentsStub (grpc .secure_channel (self .url , credentials , options = channel_options ))
186+             self .crypto_stub  =  CryptographyStub (grpc .secure_channel (self .url , credentials , options = channel_options ))
187+             self .dependencies_stub  =  DependenciesStub (
188+                 grpc .secure_channel (self .url , credentials , options = channel_options )
189+             )
190+             self .semgrep_stub  =  SemgrepStub (grpc .secure_channel (self .url , credentials , options = channel_options ))
191+             self .vuln_stub  =  VulnerabilitiesStub (grpc .secure_channel (self .url , credentials , options = channel_options ))
192+             self .provenance_stub  =  GeoProvenanceStub (
193+                 grpc .secure_channel (self .url , credentials , options = channel_options )
194+             )
195+             self .scanning_stub  =  ScanningStub (grpc .secure_channel (self .url , credentials , options = channel_options ))
185196
186197    @classmethod  
187198    def  _load_cert (cls , cert_file : str ) ->  bytes :
@@ -694,6 +705,7 @@ class GrpcConfig:
694705    timeout : Optional [int ] =  DEFAULT_TIMEOUT 
695706    proxy : Optional [str ] =  None 
696707    grpc_proxy : Optional [str ] =  None 
708+     grpc_ssl_target : Optional [str ] =  None 
697709    pac : Optional [PACFile ] =  None 
698710    req_headers : Optional [dict ] =  None 
699711
@@ -710,4 +722,5 @@ def create_grpc_config_from_args(args) -> GrpcConfig:
710722        timeout = getattr (args , 'timeout' , DEFAULT_TIMEOUT ),
711723        proxy = getattr (args , 'proxy' , None ),
712724        grpc_proxy = getattr (args , 'grpc_proxy' , None ),
725+         grpc_ssl_target = getattr (args , 'grpc_ssl_target' , None ),
713726    )
0 commit comments