Bug 1918226 - Use Glean APIs for security.javascriptLoad#parentProcess r=tjr

Differential Revision: https://phabricator.services.mozilla.com/D221492
This commit is contained in:
Chris H-C 2024-09-20 18:43:01 +00:00
parent 93d4576ea9
commit e3a2cdfa9e
2 changed files with 35 additions and 16 deletions

View File

@ -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

View File

@ -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<nsTArray<EventExtraEntry>> extra;
if (fileNameTypeAndDetails.second.isSome()) {
extra = Some<nsTArray<EventExtraEntry>>({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(