@ -19,9 +19,9 @@ try:
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					except  ImportError : 
 
					 
					 
					 
					except  ImportError : 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    import  json 
 
					 
					 
					 
					    import  json 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					import  readline 
 
					 
					 
					 
					import  readline 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					from  socket  import  socket ,  AF_UNIX ,  error 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					import  select 
 
					 
					 
					 
					import  select 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					import  sys 
 
					 
					 
					 
					import  sys 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					from  socket  import  AF_UNIX ,  error ,  socket 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					from  suricata . sc . specs  import  argsd 
 
					 
					 
					 
					from  suricata . sc . specs  import  argsd 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -92,8 +92,8 @@ class SuricataSC:
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                " iface-list " , 
 
					 
					 
					 
					                " iface-list " , 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                ] 
 
					 
					 
					 
					                ] 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        self . fn_commands  =  [ 
 
					 
					 
					 
					        self . fn_commands  =  [ 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                " pcap-file   " , 
 
					 
					 
					 
					                " pcap-file " , 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
					                " pcap-file-continuous   " , 
 
					 
					 
					 
					                " pcap-file-continuous " , 
 
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					                " iface-stat " , 
 
					 
					 
					 
					                " iface-stat " , 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                " conf-get " , 
 
					 
					 
					 
					                " conf-get " , 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                " unregister-tenant-handler " , 
 
					 
					 
					 
					                " unregister-tenant-handler " , 
 
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -198,21 +198,27 @@ class SuricataSC:
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        full_cmd  =  command . split ( ) 
 
					 
					 
					 
					        full_cmd  =  command . split ( ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        cmd  =  full_cmd [ 0 ] 
 
					 
					 
					 
					        cmd  =  full_cmd [ 0 ] 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        cmd_specs  =  argsd [ cmd ] 
 
					 
					 
					 
					        cmd_specs  =  argsd [ cmd ] 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					        required_args_count  =  len ( [ d [ " required " ]  for  d  in  cmd_specs  if  d [ " required " ]  and  not  " val "  in  d ] ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        arguments  =  dict ( ) 
 
					 
					 
					 
					        arguments  =  dict ( ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        for  c ,  spec  in  enumerate ( cmd_specs ,  1 ) : 
 
					 
					 
					 
					        for  c ,  spec  in  enumerate ( cmd_specs ,  1 ) : 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            spec_type  =  str  if  " type "  not  in  spec  else  spec [ " type " ] 
 
					 
					 
					 
					            spec_type  =  str  if  " type "  not  in  spec  else  spec [ " type " ] 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  spec [ " required " ] : 
 
					 
					 
					 
					            if  spec [ " required " ] : 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                if  spec . get ( " val " ) : 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                    arguments [ spec [ " name " ] ]  =  spec_type ( spec [ " val " ] ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                    continue 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                try : 
 
					 
					 
					 
					                try : 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    arguments [ spec [ " name " ] ]  =  spec_type ( full_cmd [ c ] ) 
 
					 
					 
					 
					                    arguments [ spec [ " name " ] ]  =  spec_type ( full_cmd [ c ] ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                except  IndexError : 
 
					 
					 
					 
					                except  IndexError : 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                    raise  SuricataCommandException ( " Missing arguments " ) 
 
					 
					 
					 
					                    phrase  =  "  at least "  if  required_args_count  !=  len ( cmd_specs )  else  " " 
 
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                    msg  =  " Missing arguments: expected {}   {} " . format ( phrase ,  required_args_count ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                    raise  SuricataCommandException ( msg ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            elif  c  <  len ( full_cmd ) : 
 
					 
					 
					 
					            elif  c  <  len ( full_cmd ) : 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                arguments [ spec [ " name " ] ]  =  spec_type ( full_cmd [ c ] ) 
 
					 
					 
					 
					                arguments [ spec [ " name " ] ]  =  spec_type ( full_cmd [ c ] ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        return  cmd ,  arguments 
 
					 
					 
					 
					        return  cmd ,  arguments 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					    def  parse_command ( self ,  command ) : 
 
					 
					 
					 
					    def  parse_command ( self ,  command ) : 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        arguments  =  None 
 
					 
					 
					 
					        arguments  =  None 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					        cmd  =  command . split ( maxsplit = 2) [ 0 ]  
 
					 
					 
					 
					        cmd  =  command . split ( maxsplit = 1) [ 0 ]  if  command  else  None  
 
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					        if  cmd  in  self . cmd_list : 
 
					 
					 
					 
					        if  cmd  in  self . cmd_list : 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					            if  cmd  in  self . fn_commands : 
 
					 
					 
					 
					            if  cmd  in  self . fn_commands : 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                cmd ,  arguments  =  getattr ( self ,  " execute " ) ( command = command ) 
 
					 
					 
					 
					                cmd ,  arguments  =  getattr ( self ,  " execute " ) ( command = command )