diff --git a/dom/security/metrics.yaml b/dom/security/metrics.yaml index db6d29e9f80e..e05399062276 100644 --- a/dom/security/metrics.yaml +++ b/dom/security/metrics.yaml @@ -304,3 +304,33 @@ security: expires: never extra_keys: *security_evalUsage_extra telemetry_mirror: Security_Evalusage_Parentprocess + + javascript_load_parent_process: + type: event + description: > + The javascript engine requested to load a filename that was not + allowed. Expected values, and fileinfo key, are the same possible + values as above in 'evalUsage' + This event was generated to correspond to the Legacy Telemetry event + security.javascriptLoad#parentProcess. + bugs: + - https://bugzil.la/1582512 + data_reviews: + - https://bugzil.la/1582512 + notification_emails: + - tom@mozilla.com + - gijs@mozilla.com + expires: never + extra_keys: + value: + description: > + The `value` of the event. Mirrors to the Legacy Telemetry + event's `value` parameter. + The filename's type, see + `nsContentSecurityUtils::FilenameToFilenameType(...)`. + type: string + fileinfo: + description: > + Information about the filename that was requested to be loaded + type: string + telemetry_mirror: Security_Javascriptload_Parentprocess diff --git a/dom/security/nsContentSecurityUtils.cpp b/dom/security/nsContentSecurityUtils.cpp index 8cc18b03b3dc..0a88c9584b40 100644 --- a/dom/security/nsContentSecurityUtils.cpp +++ b/dom/security/nsContentSecurityUtils.cpp @@ -46,8 +46,6 @@ #include "mozilla/StaticPrefs_extensions.h" #include "mozilla/StaticPrefs_dom.h" #include "mozilla/Telemetry.h" -#include "mozilla/TelemetryComms.h" -#include "mozilla/TelemetryEventEnums.h" #include "nsIConsoleService.h" #include "nsIStringBundle.h" @@ -1573,27 +1571,18 @@ bool nsContentSecurityUtils::ValidateScriptFilename(JSContext* cx, MOZ_LOG(sCSMLog, LogLevel::Error, ("ValidateScriptFilename Failed: %s\n", aFilename)); - // Send Telemetry FilenameTypeAndDetails fileNameTypeAndDetails = FilenameToFilenameType(filename, true); - Telemetry::EventID eventType = - Telemetry::EventID::Security_Javascriptload_Parentprocess; - - mozilla::Maybe> extra; - if (fileNameTypeAndDetails.second.isSome()) { - extra = Some>({EventExtraEntry{ - "fileinfo"_ns, fileNameTypeAndDetails.second.value()}}); - } else { - extra = Nothing(); - } - if (!sTelemetryEventEnabled.exchange(true)) { sTelemetryEventEnabled = true; Telemetry::SetEventRecordingEnabled("security"_ns, true); } - Telemetry::RecordEvent(eventType, mozilla::Some(fileNameTypeAndDetails.first), - extra); + glean::security::JavascriptLoadParentProcessExtra extra = { + .fileinfo = fileNameTypeAndDetails.second, + .value = Some(fileNameTypeAndDetails.first), + }; + glean::security::javascript_load_parent_process.Record(Some(extra)); #if defined(DEBUG) || defined(FUZZING) auto crashString = nsContentSecurityUtils::SmartFormatCrashString(