Skip to content

Commit

Permalink
Bug 1633525 - reject frecency-update pings as UnwantedData (#1295)
Browse files Browse the repository at this point in the history
* Bug 1633525 - reject frecency-update pings as UnwantedData

* Refactor handling of unwanted telemetry document types in MessageScrubber

Co-authored-by: Jeff Klukas <[email protected]>
  • Loading branch information
akkomar and jklukas authored May 26, 2020
1 parent 3d618c7 commit 3a2adc5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public class MessageScrubber {
.put("org-mozilla-fenix-debug", "1614409") //
.build();

private static final Map<String, String> IGNORED_TELEMETRY_DOCTYPES = ImmutableMap
.<String, String>builder().put("pioneer-study", "1631849") //
.put("frecency-update", "1633525") //
.build();

private static final ImmutableSet<String> FIREFOX_ONLY_DOCTYPES = ImmutableSet.of("event", "main",
"modules");

Expand Down Expand Up @@ -85,6 +90,10 @@ public static void scrub(Map<String, String> attributes, ObjectNode json)
throw new UnwantedDataException(IGNORED_NAMESPACES.get(namespace));
}

if (ParseUri.TELEMETRY.equals(namespace) && IGNORED_TELEMETRY_DOCTYPES.containsKey(docType)) {
throw new UnwantedDataException(IGNORED_TELEMETRY_DOCTYPES.get(docType));
}

if ("FirefoxOS".equals(appName)) {
throw new UnwantedDataException("1618684");
}
Expand All @@ -108,13 +117,6 @@ public static void scrub(Map<String, String> attributes, ObjectNode json)
throw new AffectedByBugException("1626020");
}

// Decommission pioneer-study ping. These pings should be rerouted to a
// Pioneer specific decoder, in which the payload should be decrypted at
// this point.
if ("telemetry".equals(namespace) && "pioneer-study".equals(docType)) {
throw new UnwantedDataException("1631849");
}

// Redactions (message is altered, but allowed through).
if (bug1602844Affected(attributes)) {
json.path("events").elements().forEachRemaining(event -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,14 @@ public void testUnwantedDataBug1631849PioneerStudy() {
assertThrows(UnwantedDataException.class,
() -> MessageScrubber.scrub(attributes, Json.createObjectNode()));
}

@Test
public void testUnwantedDataBug1633525FrecencyUpdate() {
Map<String, String> attributes = ImmutableMap.<String, String>builder()
.put(Attribute.DOCUMENT_NAMESPACE, "telemetry")
.put(Attribute.DOCUMENT_TYPE, "frecency-update").build();

assertThrows(UnwantedDataException.class,
() -> MessageScrubber.scrub(attributes, Json.createObjectNode()));
}
}

0 comments on commit 3a2adc5

Please sign in to comment.