forked from mirrors/gecko-dev
Bug 1867233 - Rename IsAnnotationAllowlistedForPing() r=afranchuk
Differential Revision: https://phabricator.services.mozilla.com/D194976
This commit is contained in:
parent
2aa8541d0c
commit
e825df6c3f
9 changed files with 31 additions and 31 deletions
|
|
@ -674,7 +674,7 @@ CrashManager.prototype = Object.freeze({
|
||||||
|
|
||||||
for (let line in annotations) {
|
for (let line in annotations) {
|
||||||
try {
|
try {
|
||||||
if (Services.appinfo.isAnnotationAllowlistedForPing(line)) {
|
if (Services.appinfo.isAnnotationAllowedForPing(line)) {
|
||||||
filteredAnnotations[line] = annotations[line];
|
filteredAnnotations[line] = annotations[line];
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
|
|
@ -330,7 +330,7 @@ add_task(async function test_main_crash_event_file() {
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
found.payload.metadata.ThisShouldNot,
|
found.payload.metadata.ThisShouldNot,
|
||||||
undefined,
|
undefined,
|
||||||
"Non-allowlisted fields should be filtered out"
|
"Non-allowed fields should be filtered out"
|
||||||
);
|
);
|
||||||
|
|
||||||
count = await m.aggregateEventsFiles();
|
count = await m.aggregateEventsFiles();
|
||||||
|
|
@ -757,17 +757,17 @@ add_task(async function test_child_process_crash_ping() {
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
found.payload.metadata.ThisShouldNot,
|
found.payload.metadata.ThisShouldNot,
|
||||||
undefined,
|
undefined,
|
||||||
"Non-allowlisted fields should be filtered out"
|
"Non-allowed fields should be filtered out"
|
||||||
);
|
);
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
found.payload.metadata.RemoteType,
|
found.payload.metadata.RemoteType,
|
||||||
remoteType,
|
remoteType,
|
||||||
"RemoteType should be allowlisted for content crashes"
|
"RemoteType should be allowed for content crashes"
|
||||||
);
|
);
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
found.payload.metadata.ipc_channel_error,
|
found.payload.metadata.ipc_channel_error,
|
||||||
"ShutDownKill",
|
"ShutDownKill",
|
||||||
"ipc_channel_error should be allowlisted for content crashes"
|
"ipc_channel_error should be allowed for content crashes"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ using std::find_if;
|
||||||
namespace CrashReporter {
|
namespace CrashReporter {
|
||||||
|
|
||||||
bool AnnotationFromString(Annotation& aResult, const char* aValue) {
|
bool AnnotationFromString(Annotation& aResult, const char* aValue) {
|
||||||
auto elem = find_if(
|
const auto* elem = find_if(
|
||||||
begin(kAnnotationStrings), end(kAnnotationStrings),
|
begin(kAnnotationStrings), end(kAnnotationStrings),
|
||||||
[&aValue](const char* aString) { return strcmp(aString, aValue) == 0; });
|
[&aValue](const char* aString) { return strcmp(aString, aValue) == 0; });
|
||||||
|
|
||||||
|
|
@ -27,12 +27,12 @@ bool AnnotationFromString(Annotation& aResult, const char* aValue) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsAnnotationAllowlistedForPing(Annotation aAnnotation) {
|
bool IsAnnotationAllowedForPing(Annotation aAnnotation) {
|
||||||
auto elem = find_if(
|
const auto* elem = find_if(
|
||||||
begin(kCrashPingAllowlist), end(kCrashPingAllowlist),
|
begin(kCrashPingAllowedList), end(kCrashPingAllowedList),
|
||||||
[&aAnnotation](Annotation aElement) { return aElement == aAnnotation; });
|
[&aAnnotation](Annotation aElement) { return aElement == aAnnotation; });
|
||||||
|
|
||||||
return elem != end(kCrashPingAllowlist);
|
return elem != end(kCrashPingAllowedList);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace CrashReporter
|
} // namespace CrashReporter
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ ${strings}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Allowlist of crash annotations that can be included in a crash ping
|
// Allowlist of crash annotations that can be included in a crash ping
|
||||||
const Annotation kCrashPingAllowlist[] = {
|
const Annotation kCrashPingAllowedList[] = {
|
||||||
${allowlist}
|
${allowedlist}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -46,14 +46,14 @@ static inline const char* AnnotationToString(Annotation aAnnotation) {
|
||||||
bool AnnotationFromString(Annotation& aResult, const char* aValue);
|
bool AnnotationFromString(Annotation& aResult, const char* aValue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given crash annotation is allowlisted for inclusion in the
|
* Checks if the given crash annotation is allowed for inclusion in the crash
|
||||||
* crash ping.
|
* ping.
|
||||||
*
|
*
|
||||||
* @param aAnnotation the crash annotation to be checked
|
* @param aAnnotation the crash annotation to be checked
|
||||||
* @return true if the annotation can be included in the crash ping, false
|
* @return true if the annotation can be included in the crash ping, false
|
||||||
* otherwise
|
* otherwise
|
||||||
*/
|
*/
|
||||||
bool IsAnnotationAllowlistedForPing(Annotation aAnnotation);
|
bool IsAnnotationAllowedForPing(Annotation aAnnotation);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract annotation writer, this is needed only for code that writes out
|
* Abstract annotation writer, this is needed only for code that writes out
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
# Additionally a field can have the following optional fields:
|
# Additionally a field can have the following optional fields:
|
||||||
# - altname: A string that will be used when writing out the annotation to the
|
# - altname: A string that will be used when writing out the annotation to the
|
||||||
# .extra file instead of the annotation name
|
# .extra file instead of the annotation name
|
||||||
# - ping: A boolean that indicates whether the annotation is allowlisted for
|
# - ping: A boolean that indicates whether the annotation is allowed for
|
||||||
# going into the crash ping, if not specified this defaults to false
|
# inclusion in the crash ping, if not specified this defaults to false
|
||||||
|
|
||||||
AbortMessage:
|
AbortMessage:
|
||||||
description: >
|
description: >
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ static Json::Value CreateMetadataNode(const Json::Value& aExtra) {
|
||||||
Annotation annotation;
|
Annotation annotation;
|
||||||
|
|
||||||
if (AnnotationFromString(annotation, iter.memberName())) {
|
if (AnnotationFromString(annotation, iter.memberName())) {
|
||||||
if (IsAnnotationAllowlistedForPing(annotation)) {
|
if (IsAnnotationAllowedForPing(annotation)) {
|
||||||
node[iter.memberName()] = *iter;
|
node[iter.memberName()] = *iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,8 @@ def read_template(template_filename):
|
||||||
return template
|
return template
|
||||||
|
|
||||||
|
|
||||||
def extract_crash_ping_allowlist(annotations):
|
def extract_crash_ping_allowedlist(annotations):
|
||||||
"""Extract an array holding the names of the annotations allowlisted for
|
"""Extract an array holding the names of the annotations allowed for
|
||||||
inclusion in the crash ping."""
|
inclusion in the crash ping."""
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
@ -123,13 +123,13 @@ def generate_header(template, annotations):
|
||||||
"""Generate a header by filling the template with the the list of
|
"""Generate a header by filling the template with the the list of
|
||||||
annotations and return it as a string."""
|
annotations and return it as a string."""
|
||||||
|
|
||||||
allowlist = extract_crash_ping_allowlist(annotations)
|
allowedlist = extract_crash_ping_allowedlist(annotations)
|
||||||
|
|
||||||
return template_header + string.Template(template).substitute(
|
return template_header + string.Template(template).substitute(
|
||||||
{
|
{
|
||||||
"enum": generate_enum(annotations),
|
"enum": generate_enum(annotations),
|
||||||
"strings": generate_strings(annotations),
|
"strings": generate_strings(annotations),
|
||||||
"allowlist": generate_array_initializer(allowlist),
|
"allowedlist": generate_array_initializer(allowedlist),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -168,11 +168,11 @@ def generate_java_array_initializer(contents):
|
||||||
def generate_class(template, annotations):
|
def generate_class(template, annotations):
|
||||||
"""Fill the class template from the list of annotations."""
|
"""Fill the class template from the list of annotations."""
|
||||||
|
|
||||||
allowlist = extract_crash_ping_allowlist(annotations)
|
allowedlist = extract_crash_ping_allowedlist(annotations)
|
||||||
|
|
||||||
return template_header + string.Template(template).substitute(
|
return template_header + string.Template(template).substitute(
|
||||||
{
|
{
|
||||||
"allowlist": generate_java_array_initializer(allowlist),
|
"allowedlist": generate_java_array_initializer(allowedlist),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -189,8 +189,8 @@ def emit_class(output, annotations_filename):
|
||||||
* are kept in sync with the other C++ and JS users.
|
* are kept in sync with the other C++ and JS users.
|
||||||
*/
|
*/
|
||||||
public class CrashReporterConstants {
|
public class CrashReporterConstants {
|
||||||
public static final String[] ANNOTATION_ALLOWLIST = {
|
public static final String[] ANNOTATION_ALLOWEDLIST = {
|
||||||
${allowlist}
|
${allowedlist}
|
||||||
};
|
};
|
||||||
}"""
|
}"""
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1837,15 +1837,15 @@ nsXULAppInfo::RemoveCrashReportAnnotation(const nsACString& key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXULAppInfo::IsAnnotationAllowlistedForPing(const nsACString& aValue,
|
nsXULAppInfo::IsAnnotationAllowedForPing(const nsACString& aValue,
|
||||||
bool* aIsAllowlisted) {
|
bool* aIsAllowed) {
|
||||||
CrashReporter::Annotation annotation;
|
CrashReporter::Annotation annotation;
|
||||||
|
|
||||||
if (!AnnotationFromString(annotation, PromiseFlatCString(aValue).get())) {
|
if (!AnnotationFromString(annotation, PromiseFlatCString(aValue).get())) {
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
*aIsAllowlisted = CrashReporter::IsAnnotationAllowlistedForPing(annotation);
|
*aIsAllowed = CrashReporter::IsAnnotationAllowedForPing(annotation);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ interface nsICrashReporter : nsISupports
|
||||||
void removeCrashReportAnnotation(in AUTF8String key);
|
void removeCrashReportAnnotation(in AUTF8String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if an annotation is allowlisted for inclusion in the crash ping.
|
* Checks if an annotation is allowed for inclusion in the crash ping.
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* Name of a known crash annotation constant.
|
* Name of a known crash annotation constant.
|
||||||
|
|
@ -108,7 +108,7 @@ interface nsICrashReporter : nsISupports
|
||||||
included in the crash ping, false otherwise.
|
included in the crash ping, false otherwise.
|
||||||
* @throw NS_ERROR_INVALID_ARG if key contains an invalid value.
|
* @throw NS_ERROR_INVALID_ARG if key contains an invalid value.
|
||||||
*/
|
*/
|
||||||
boolean isAnnotationAllowlistedForPing(in ACString value);
|
boolean isAnnotationAllowedForPing(in ACString value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append some data to the "Notes" field, to be submitted with a crash report.
|
* Append some data to the "Notes" field, to be submitted with a crash report.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue