Skip to content

Commit 048decf

Browse files
committed
fix for copilot findings.
1 parent 298b342 commit 048decf

File tree

8 files changed

+28
-29
lines changed

8 files changed

+28
-29
lines changed

application/single_app/functions_keyvault.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ def retrieve_secret_from_key_vault(secret_name, scope_value, scope="global", sou
6666
raise ValueError(f"Scope '{scope}' is not supported. Supported scopes: {supported_scopes}")
6767

6868
full_secret_name = build_full_secret_name(secret_name, scope_value, source, scope)
69-
return retrieve_secret_from_keyvault_by_full_name(full_secret_name)
69+
return retrieve_secret_from_key_vault_by_full_name(full_secret_name)
7070

71-
def retrieve_secret_from_keyvault_by_full_name(full_secret_name):
71+
def retrieve_secret_from_key_vault_by_full_name(full_secret_name):
7272
"""
7373
Retrieve a secret from Key Vault using a preformatted full secret name.
7474
@@ -83,14 +83,14 @@ def retrieve_secret_from_keyvault_by_full_name(full_secret_name):
8383
settings = get_settings()
8484
enable_key_vault_secret_storage = settings.get("enable_key_vault_secret_storage", False)
8585
if not enable_key_vault_secret_storage:
86-
return value
86+
return full_secret_name
8787

8888
key_vault_name = settings.get("key_vault_name", None)
8989
if not key_vault_name:
90-
return value
90+
return full_secret_name
9191

9292
if not validate_secret_name_dynamic(full_secret_name):
93-
return value
93+
return full_secret_name
9494

9595
try:
9696
key_vault_url = f"https://{key_vault_name}{KEY_VAULT_DOMAIN}"
@@ -101,7 +101,7 @@ def retrieve_secret_from_keyvault_by_full_name(full_secret_name):
101101
return retrieved_secret.value
102102
except Exception as e:
103103
logging.error(f"Failed to retrieve secret '{full_secret_name}' from Key Vault: {str(e)}")
104-
return value
104+
return full_secret_name
105105

106106

107107
def store_secret_in_key_vault(secret_name, secret_value, scope_value, source="global", scope="global"):
@@ -369,7 +369,7 @@ def keyvault_plugin_get_helper(plugin_dict, scope_value, scope="global", return_
369369
if validate_secret_name_dynamic(value):
370370
try:
371371
if return_actual_key:
372-
actual_key = retrieve_secret_from_key_vault(plugin_name, scope_value, scope, source)
372+
actual_key = retrieve_secret_from_key_vault_by_full_name(value)
373373
new_auth = dict(auth)
374374
new_auth['key'] = actual_key
375375
updated['auth'] = new_auth

application/single_app/json_schema_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def validate_plugin(plugin):
4343
validator = Draft7Validator(schema['definitions']['Plugin'])
4444
errors = sorted(validator.iter_errors(plugin_copy), key=lambda e: e.path)
4545
if errors:
46-
return '; '.join([f"{plugin.name}: {e.message}" for e in errors])
46+
return '; '.join([f"{plugin.get('name', '<Unknown>')}: {e.message}" for e in errors])
4747

4848
# Additional business logic validation
4949
# For non-SQL plugins, endpoint must not be empty

application/single_app/route_backend_settings.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,9 @@ def _test_key_vault_connection(payload):
716716
else:
717717
credential = DefaultAzureCredential()
718718

719-
if AZURE_ENVIRONMENT in ("custom"):
720-
kv_client = SecretClient(vault_url=vault_url, credential=credential, credential_scopes=[key_vault_scope])
719+
if AZURE_ENVIRONMENT == "custom":
720+
#TODO: Needs to be tested with a custom environment
721+
kv_client = SecretClient(vault_url=vault_url, credential=credential)
721722
else:
722723
kv_client = SecretClient(vault_url=vault_url, credential=credential)
723724

application/single_app/semantic_kernel_loader.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from semantic_kernel_plugins.smart_http_plugin import SmartHttpPlugin
3232
from functions_debug import debug_print
3333
from flask import g
34-
from functions_keyvault import validate_secret_name_dynamic, retrieve_secret_from_key_vault, retrieve_secret_from_keyvault_by_full_name
34+
from functions_keyvault import validate_secret_name_dynamic, retrieve_secret_from_key_vault, retrieve_secret_from_key_vault_by_full_name
3535
from functions_global_actions import get_global_actions
3636
from functions_global_agents import get_global_agents
3737
from functions_personal_actions import get_personal_actions, ensure_migration_complete as ensure_actions_migration_complete
@@ -139,7 +139,7 @@ def get_user_apim():
139139
try:
140140
if validate_secret_name_dynamic(key):
141141
# Try to retrieve the secret from Key Vault
142-
resolved_key = retrieve_secret_from_keyvault_by_full_name(key)
142+
resolved_key = retrieve_secret_from_key_vault_by_full_name(key)
143143
if resolved_key:
144144
# Update the agent dict with the resolved key for this session
145145
agent["azure_apim_gpt_subscription_key"] = resolved_key
@@ -160,7 +160,7 @@ def get_global_apim():
160160
try:
161161
if validate_secret_name_dynamic(key):
162162
# Try to retrieve the secret from Key Vault
163-
resolved_key = retrieve_secret_from_keyvault_by_full_name(key)
163+
resolved_key = retrieve_secret_from_key_vault_by_full_name(key)
164164
if resolved_key:
165165
# Update the settings dict with the resolved key for this session
166166
settings["azure_apim_gpt_subscription_key"] = resolved_key
@@ -181,7 +181,7 @@ def get_user_gpt():
181181
try:
182182
if validate_secret_name_dynamic(key):
183183
# Try to retrieve the secret from Key Vault
184-
resolved_key = retrieve_secret_from_keyvault_by_full_name(key)
184+
resolved_key = retrieve_secret_from_key_vault_by_full_name(key)
185185
if resolved_key:
186186
# Update the agent dict with the resolved key for this session
187187
agent["azure_openai_gpt_key"] = resolved_key
@@ -202,7 +202,7 @@ def get_global_gpt():
202202
try:
203203
if validate_secret_name_dynamic(key):
204204
# Try to retrieve the secret from Key Vault
205-
resolved_key = retrieve_secret_from_keyvault_by_full_name(key)
205+
resolved_key = retrieve_secret_from_key_vault_by_full_name(key)
206206
if resolved_key:
207207
# Update the settings dict with the resolved key for this session
208208
settings["azure_openai_gpt_key"] = resolved_key
@@ -483,7 +483,7 @@ def load_agent_specific_plugins(kernel, plugin_names, settings, mode_label="glob
483483
all_plugin_manifests = []
484484
else:
485485
# Global mode - get from global actions container
486-
all_plugin_manifests = global_plugins
486+
all_plugin_manifests = get_global_plugins(return_actual_key=True)
487487
print(f"[SK Loader] Retrieved {len(all_plugin_manifests)} global plugin manifests")
488488

489489
# Filter manifests to only include requested plugins
@@ -828,7 +828,7 @@ def resolve_key_vault_secrets_in_plugins(plugin_manifest, settings):
828828

829829
def resolve_value(value):
830830
if isinstance(value, str) and validate_secret_name_dynamic(value):
831-
resolved = retrieve_secret_from_keyvault_by_full_name(value)
831+
resolved = retrieve_secret_from_key_vault_by_full_name(value)
832832
if resolved:
833833
return resolved
834834
else:

application/single_app/semantic_kernel_plugins/logged_plugin_loader.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,21 @@ def normalize(s):
141141
if matched_class:
142142
try:
143143
plugin = matched_class(manifest) if 'manifest' in matched_class.__init__.__code__.co_varnames else matched_class()
144-
log_event(f"[Logged Plugin Loader] Instanced plugin: {name} (type: {plugin_type}) [{mode_label}]", {"plugin_name": name, "plugin_type": plugin_type}, level=logging.INFO)
144+
log_event(f"[Logged Plugin Loader] Instanced plugin: {name} (type: {plugin_type})", {"plugin_name": name, "plugin_type": plugin_type}, level=logging.INFO)
145145
return plugin
146146
except Exception as e:
147147
log_event(f"[Logged Plugin Loader] Failed to instantiate plugin: {name}: {e}", {"plugin_name": name, "plugin_type": plugin_type, "error": str(e)}, level=logging.ERROR, exceptionTraceback=True)
148148
else:
149-
log_event(f"[Logged Plugin Loader] Unknown plugin type: {plugin_type} for plugin '{name}' [{mode_label}]", {"plugin_name": name, "plugin_type": plugin_type}, level=logging.WARNING)
149+
log_event(f"[Logged Plugin Loader] Unknown plugin type: {plugin_type} for plugin '{name}'", {"plugin_name": name, "plugin_type": plugin_type}, level=logging.WARNING)
150150
except Exception as e:
151-
log_event(f"[Logged Plugin Loader] Error discovering plugin types for {mode_label} mode: {e}", {"error": str(e)}, level=logging.ERROR, exceptionTraceback=True)
151+
log_event(f"[Logged Plugin Loader] Error discovering plugin types: {e}", {"error": str(e)}, level=logging.ERROR, exceptionTraceback=True)
152152

153153
def _create_openapi_plugin(self, manifest: Dict[str, Any]):
154154
"""Create an OpenAPI plugin instance."""
155155
plugin_name = manifest.get('name')
156156
log_event(f"[Logged Plugin Loader] Attempting to create OpenAPI plugin: {plugin_name}", level=logging.DEBUG)
157157

158158
try:
159-
log_event(f"[Logged Plugin Loader] Successfully imported OpenApiPluginFactory", level=logging.DEBUG)
160-
161159
log_event(f"[Logged Plugin Loader] Creating OpenAPI plugin using factory",
162160
extra={"plugin_name": plugin_name, "manifest": manifest},
163161
level=logging.DEBUG)
@@ -357,7 +355,7 @@ def load_multiple_plugins(self, manifests: List[Dict[str, Any]],
357355
total_count = len(results)
358356

359357
log_event(
360-
f"[Plugin Loader] Loaded {successful_count}/{total_count} plugins",
358+
f"[Logged Plugin Loader] Loaded {successful_count}/{total_count} plugins",
361359
extra={
362360
"successful_plugins": [name for name, success in results.items() if success],
363361
"failed_plugins": [name for name, success in results.items() if not success],

application/single_app/semantic_kernel_plugins/ui_test_plugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""
2-
SQL Schema Plugin for Semantic Kernel
3-
- Connects to various SQL databases (SQL Server, PostgreSQL, MySQL, SQLite)
4-
- Extracts schema information (tables, columns, data types, relationships)
5-
- Provides structured schema data for query generation
2+
UI Test Plugin for Semantic Kernel
3+
- Provides demonstration methods for UI testing (greeting, farewell, manifest retrieval)
4+
- Useful for testing plugin integration and UI workflows
5+
- Does not interact with external systems or databases
66
"""
77

88
import json

application/single_app/static/js/plugin_modal_stepper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2112,7 +2112,7 @@ export class PluginModalStepper {
21122112
if (typeof additionalFieldsObj === 'object' && additionalFieldsObj !== null) {
21132113
previewContent = JSON.stringify(additionalFieldsObj, null, 2);
21142114
} else {
2115-
previewContent = additionalFields;
2115+
previewContent = '';
21162116
}
21172117
document.getElementById('summary-additional-fields-content').textContent = previewContent;
21182118
additionalFieldsPreview.style.display = '';

application/single_app/static/json/schemas/ui_test_plugin.plugin.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"title": "UI Test Plugin",
4-
"description": "Schema for UI Test Plugin configuration, restricting auth.type to key, connection_string, and identity.",
4+
"description": "NYI-Schema for UI Test Plugin configuration, restricting auth.type to user, key, connection_string, and identity.",
55
"allOf": [
66
{ "$ref": "plugin.schema.json" },
77
{

0 commit comments

Comments
 (0)