MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / detect_plugin

Function detect_plugin

keepercommander/plugins/plugin_manager.py:74–104  ·  view source on GitHub ↗

Attempt detection of plugin name without "cmdr:plugin" fields This function also returns the corresponding kwargs for the detected plugin Return plugin_name and plugin_kwargs

(record, plugin_kwargs)

Source from the content-addressed store, hash-verified

72
73
74def detect_plugin(record, plugin_kwargs):
75 """Attempt detection of plugin name without "cmdr:plugin" fields
76
77 This function also returns the corresponding kwargs for the detected plugin
78 Return plugin_name and plugin_kwargs
79 """
80 plugin_name = None
81 if record.get_version() == 3:
82 # Search for host field in v3 record
83 host_field = get_host_field_dict(record)
84 if host_field and host_field['port'].isnumeric() and int(host_field['port']) in PORT_TO_PLUGIN:
85 plugin_name = PORT_TO_PLUGIN[int(host_field['port'])]
86 if 'host' not in plugin_kwargs:
87 plugin_kwargs['host'] = host_field['hostName']
88 if 'port' not in plugin_kwargs:
89 plugin_kwargs['port'] = int(host_field['port'])
90 if not plugin_name and 'url' in plugin_kwargs:
91 url = urlparse(plugin_kwargs['url'])
92 if url.port in PORT_TO_PLUGIN:
93 plugin_name = PORT_TO_PLUGIN[url.port]
94 if 'host' not in plugin_kwargs:
95 plugin_kwargs['host'] = url.hostname
96 if 'port' not in plugin_kwargs:
97 plugin_kwargs['port'] = url.port
98 if url.scheme in URL_SCHEME_TO_PLUGIN:
99 plugin_name = URL_SCHEME_TO_PLUGIN[url.scheme]
100 if 'host' not in plugin_kwargs:
101 plugin_kwargs['host'] = url.hostname
102 if 'port' not in plugin_kwargs and url.port:
103 plugin_kwargs['port'] = url.port
104 return plugin_name
105
106
107def detect_kwargs(record, plugin_name, plugin_kwargs):

Callers 1

get_pluginFunction · 0.85

Calls 2

get_host_field_dictFunction · 0.85
get_versionMethod · 0.45

Tested by

no test coverage detected