Add support for CSV lists of key vaults to check, so the plugin can check more than one key vault.
This commit is contained in:
		
							parent
							
								
									9ec90446a5
								
							
						
					
					
						commit
						92a4ca33d6
					
				| @ -8,13 +8,16 @@ from cmk.base.plugins.agent_based.agent_based_api.v1 import register, Result, Se | |||||||
| # Convert JSON entries into dictionaries indexed by certificate name. | # Convert JSON entries into dictionaries indexed by certificate name. | ||||||
| def parse_keyvault(string_table): | def parse_keyvault(string_table): | ||||||
|     raw_json = "" |     raw_json = "" | ||||||
|  |     cert_data = [] | ||||||
| 
 | 
 | ||||||
|     for row in string_table: |     for row in string_table: | ||||||
|         raw_json += row[0] |         line = row[0] | ||||||
|  |         raw_json += line | ||||||
|  |         if line == "]": | ||||||
|  |           cert_data.extend(json.loads(raw_json)) | ||||||
|  |           raw_json = "" | ||||||
| 
 | 
 | ||||||
|     lookup = {} |     lookup = {} | ||||||
|     cert_data = json.loads(raw_json) |  | ||||||
| 
 |  | ||||||
|     for cert in cert_data: |     for cert in cert_data: | ||||||
|         lookup[cert["name"]] = cert |         lookup[cert["name"]] = cert | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,4 +1,7 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
| 
 | 
 | ||||||
| echo "<<<azure_keyvault:sep(0)>>>" | echo "<<<azure_keyvault:sep(0)>>>" | ||||||
| ~/az "${@:1}" | 
 | ||||||
|  | for vault in "${@:1}"; do | ||||||
|  |   ~/az keyvault certificate list --vault-name="$vault" | ||||||
|  | done | ||||||
|  | |||||||
| @ -2,6 +2,11 @@ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def agent_azure_keyvault(params, hostname, ipaddress): | def agent_azure_keyvault(params, hostname, ipaddress): | ||||||
|     return ["keyvault", "certificate", "list", "--vault-name", params["vault_name"]] |     args = [] | ||||||
|  | 
 | ||||||
|  |     for vault in params["vault_name"].split(","): | ||||||
|  |         args.extend([vault.strip()]) | ||||||
|  | 
 | ||||||
|  |     return args | ||||||
| 
 | 
 | ||||||
| special_agent_info["azure_keyvault"] = agent_azure_keyvault | special_agent_info["azure_keyvault"] = agent_azure_keyvault | ||||||
|  | |||||||
| @ -53,9 +53,9 @@ def _valuespec_special_agents_azure_keyvault_discovery(): | |||||||
|             ( |             ( | ||||||
|                 "vault_name", |                 "vault_name", | ||||||
|                 TextInput( |                 TextInput( | ||||||
|                     title=_("Key Vault Name"), |                     title=_("Key Vault Names (CSV)"), | ||||||
|                     help=_( |                     help=_( | ||||||
|                         "The name of the Azure Key Vault to perform checks on" |                         "Comma-separated list of all the name of the Azure key vaults to perform certificate checks on. E.g. to check just the vault 'mkdev', enter 'mkdev'; to check 'mkdev' and 'mkdev2', enter 'mkdev,mkdev2'" | ||||||
|                     ), |                     ), | ||||||
|                 ), |                 ), | ||||||
|             ), |             ), | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user