-
Notifications
You must be signed in to change notification settings - Fork 284
Description
Problem
When logging hook names in telemetry (hooks.name attribute), we currently validate against a static list of 16 known built-in azd hook names (prebuild, postbuild, predeploy, etc.). Unknown hook names are SHA-256 hashed to prevent logging arbitrary user input as customer content.
However, extensions can define custom hook names via:
azure.yamlproject/service hook configurations- Runtime event handlers registered through
azdext.ExtensionHost.WithProjectEventHandler()/WithServiceEventHandler()
These extension-defined hooks are legitimate hook names that would be useful to see in telemetry in plain text, but they currently get hashed because they're not in the built-in known-names list.
Current Behavior
- Built-in hook names (
prebuild,postdeploy, etc.) → logged raw ✅ - Extension-defined hook names from
azure.yaml→ hashed (not ideal) - Arbitrary user input (
azd hooks run asdf) → hashed ✅
Desired Behavior
Extension-defined hook names should also be logged in plain text when they can be validated as legitimate (i.e., defined in project config or registered by an extension).
Options to Investigate
-
Validate against project config at telemetry time — Check
projectConfig.Hooksand allservice.Hooksmaps. If the hook name exists there, log raw; otherwise hash. This covers extension hooks defined inazure.yamlbut not runtime-only handlers. -
Extension hook name registry — Provide an API for extensions to register their custom hook names, making them available for telemetry validation.
-
Accept hashing for extension hooks — If extension hook telemetry isn't critical, the current approach (hash unknown names) may be acceptable.
Context
- PR: feat: comprehensive telemetry audit - add command-specific usage attributes #7299
- Review comment: https://github.com/Azure/azure-dev/pull/7299/files#r2996272790
- Current implementation:
cli/azd/cmd/hooks.go—knownHookNamesmap +StringHashedfallback