tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit b71bcebac0dfa1a23a2b0c6a032ee4170bf79360
parent 8e2e7fe54e53c21e6df36c5bf145a648ec282f5c
Author: Alex Franchuk <afranchuk@mozilla.com>
Date:   Tue,  4 Nov 2025 16:43:46 +0000

Bug 1989417 - Add support for ping-only crash annotations r=gsvelto

This is needed to exclude the `StackTraces` annotation from reports
(though in the future we may include it). We previously classified it as
a `client` scope, but it _is_ sent in the crash ping, albeit not
verbatim.

Differential Revision: https://phabricator.services.mozilla.com/D265512

Diffstat:
Mtoolkit/crashreporter/annotations/CrashAnnotations.cpp | 3++-
Mtoolkit/crashreporter/annotations/CrashAnnotations.h.in | 5+++++
Mtoolkit/crashreporter/annotations/CrashAnnotations.java.in | 4++--
Mtoolkit/crashreporter/annotations/CrashAnnotations.kt.in | 4++--
Mtoolkit/crashreporter/annotations/generate.py | 25++++++++++---------------
Mtoolkit/crashreporter/client/app/build.rs | 14+++++++++-----
Mtoolkit/crashreporter/client/app/src/logic/annotations.rs | 4++--
7 files changed, 32 insertions(+), 27 deletions(-)

diff --git a/toolkit/crashreporter/annotations/CrashAnnotations.cpp b/toolkit/crashreporter/annotations/CrashAnnotations.cpp @@ -42,7 +42,8 @@ static bool AnnotationInList(Annotation aAnnotation, } bool IsAnnotationAllowedForPing(Annotation aAnnotation) { - return AnnotationInList(aAnnotation, kCrashPingAllowedList); + return AnnotationInList(aAnnotation, kCrashPingAllowedList) || + AnnotationInList(aAnnotation, kCrashPingOnlyAllowedList); } bool IsAnnotationAllowedForReport(Annotation aAnnotation) { diff --git a/toolkit/crashreporter/annotations/CrashAnnotations.h.in b/toolkit/crashreporter/annotations/CrashAnnotations.h.in @@ -45,6 +45,11 @@ const Annotation kCrashPingAllowedList[] = { ${pingallowedlist} }; +// Allowlist of crash annotations that can be only included in a crash ping +const Annotation kCrashPingOnlyAllowedList[] = { +${pingonlyallowedlist} +}; + // Allowlist of crash annotations that can be included in a crash report // (excludes those in kCrashPingAllowedList). const Annotation kCrashReportAllowedList[] = { diff --git a/toolkit/crashreporter/annotations/CrashAnnotations.java.in b/toolkit/crashreporter/annotations/CrashAnnotations.java.in @@ -26,12 +26,12 @@ final class ${class} { /** @return Whether the annotation should be included in crash pings. */ public boolean allowedInPing() { - return this.scope.equals("ping"); + return this.scope.equals("ping") || this.scope.equals("ping-only"); } /** @return Whether the annotation should be included in crash reports. */ public boolean allowedInReport() { - return allowedInPing() || this.scope.equals("report"); + return this.scope.equals("ping") || this.scope.equals("report"); } } } diff --git a/toolkit/crashreporter/annotations/CrashAnnotations.kt.in b/toolkit/crashreporter/annotations/CrashAnnotations.kt.in @@ -15,9 +15,9 @@ internal class ${class} { public override fun toString() = s /** @return Whether the annotation should be included in crash pings. */ - public fun allowedInPing() = scope.equals("ping") + public fun allowedInPing() = scope.equals("ping") || scope.equals("ping-only") /** @return Whether the annotation should be included in crash reports. */ - public fun allowedInReport() = allowedInPing() || scope.equals("report") + public fun allowedInReport() = scope.equals("ping") || scope.equals("report") } } diff --git a/toolkit/crashreporter/annotations/generate.py b/toolkit/crashreporter/annotations/generate.py @@ -43,7 +43,7 @@ def validate_annotations(annotations): ) annotation_scope = data.get("scope", "client") - valid_scopes = ["client", "report", "ping"] + valid_scopes = ["client", "report", "ping", "ping-only"] if annotation_scope not in valid_scopes: sys.exit( "Annotation " @@ -82,21 +82,12 @@ def read_template(template_filename): return template -def extract_crash_ping_allowedlist(annotations): +def extract_crash_scope_list(annotations, scope): """Extract an array holding the names of the annotations allowed for - inclusion in a crash ping.""" + inclusion in a crash scope.""" return [ - name for (name, data) in annotations if data.get("scope", "client") == "ping" - ] - - -def extract_crash_report_allowedlist(annotations): - """Extract an array holding the names of the annotations allowed for - inclusion in a crash report (excluding those allowed for pings).""" - - return [ - name for (name, data) in annotations if data.get("scope", "client") == "report" + name for (name, data) in annotations if data.get("scope", "client") == scope ] @@ -202,8 +193,9 @@ def generate_types_initializer(contents): @content_generator("h") def emit_header(annotations, _output_name): - pingallowedlist = extract_crash_ping_allowedlist(annotations) - reportallowedlist = extract_crash_report_allowedlist(annotations) + pingallowedlist = extract_crash_scope_list(annotations, "ping") + pingonlyallowedlist = extract_crash_scope_list(annotations, "ping-only") + reportallowedlist = extract_crash_scope_list(annotations, "report") skiplist = extract_skiplist(annotations) typelist = extract_types(annotations) @@ -211,6 +203,9 @@ def emit_header(annotations, _output_name): "enum": generate_enum(annotations), "strings": generate_strings(annotations), "pingallowedlist": generate_annotations_array_initializer(pingallowedlist), + "pingonlyallowedlist": generate_annotations_array_initializer( + pingonlyallowedlist + ), "reportallowedlist": generate_annotations_array_initializer(reportallowedlist), "skiplist": generate_skiplist_initializer(skiplist), "types": generate_types_initializer(typelist), diff --git a/toolkit/crashreporter/client/app/build.rs b/toolkit/crashreporter/client/app/build.rs @@ -59,16 +59,20 @@ fn crash_annotations() { }; let mut ping_annotations = phf_codegen::Set::new(); - let mut report_annotations = phf_codegen::Set::new(); + let mut annotations = phf_codegen::Set::new(); for (k, v) in entries { let scope = v["scope"].as_str().unwrap_or("client"); match scope { - "ping" => { + "ping-only" => { ping_annotations.entry(k.into_string().unwrap()); } + "ping" => { + ping_annotations.entry(k.clone().into_string().unwrap()); + annotations.entry(k.into_string().unwrap()); + } "report" => { - report_annotations.entry(k.into_string().unwrap()); + annotations.entry(k.into_string().unwrap()); } _ => (), } @@ -83,8 +87,8 @@ fn crash_annotations() { .unwrap(); writeln!( &mut file, - "static REPORT_ANNOTATIONS: phf::Set<&'static str> = {};", - report_annotations.build(), + "static ALL_REPORT_ANNOTATIONS: phf::Set<&'static str> = {};", + annotations.build(), ) .unwrap(); } diff --git a/toolkit/crashreporter/client/app/src/logic/annotations.rs b/toolkit/crashreporter/client/app/src/logic/annotations.rs @@ -6,7 +6,7 @@ // Generated by `build.rs`. // static PING_ANNOTATIONS: phf::Set<&'static str>; -// static REPORT_ANNOTATIONS: phf::Set<&'static str>; +// static ALL_REPORT_ANNOTATIONS: phf::Set<&'static str>; include!(concat!(env!("OUT_DIR"), "/crash_annotations.rs")); /// Return whether the given annotation can be sent in a crash ping. @@ -16,5 +16,5 @@ pub fn send_in_ping(annotation: &str) -> bool { /// Return whether the given annotation can be sent in a crash report. pub fn send_in_report(annotation: &str) -> bool { - REPORT_ANNOTATIONS.contains(annotation) || PING_ANNOTATIONS.contains(annotation) + ALL_REPORT_ANNOTATIONS.contains(annotation) }