Commit 92e88cd6 authored by Joe DeBlasio's avatar Joe DeBlasio Committed by Commit Bot

Switch safety_tips component protobuf to use patterns.

This CL switches the protobuf used for component updater to pass
patterns rather than raw URLs. This allows safety_tips to remain
consistent with the SB-style pattern matching. It also moves the
playbook for component updates to g3.

Change-Id: I9da231882cdb68fddd1d0b582006ed60e97fbe8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1743247Reviewed-by: default avatarMustafa Emre Acer <meacer@chromium.org>
Commit-Queue: Joe DeBlasio <jdeblasio@chromium.org>
Auto-Submit: Joe DeBlasio <jdeblasio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685384}
parent acacb2a3
......@@ -14,9 +14,9 @@ message FlaggedPage {
BAD_REP = 1;
YOUNG_DOMAIN = 2;
}
// |url| is a full URL such as
// http://example.test/test-path-for-safety-tips/test.html.
optional string url = 1;
// |pattern| is a full URL, without scheme/username/password/port, such as
// example.test/test-path-for-safety-tips/test.html.
optional string pattern = 1;
optional FlagType type = 2;
}
......
......@@ -30,6 +30,12 @@ def CheckVersionUpdatedInProto(input_api, output_api):
'Do not check in the full safety_tips.asciipb proto. '
'Only increment |version_id|.')]
# This proto should not contain any actually-flagged pages. ContainsLine
# checks if any line *starts with* the given string.
if ContainsLine(contents, 'flagged_page:'):
return [output_api.PresubmitError(
'Remove entries from Chromium safety_tips.asciipb before submitting.')]
# It's enticing to do something fancy like checking whether the ID was in fact
# incremented or whether this is a whitespace-only or comment-only change.
# However, currently deleted lines don't show up in ChangedContents() and
......
### Update Instructions for Safety Tips Component
Safety Tips component pushes binary protos to clients via Chrome's component
updater. The proto files are stored in a Google Cloud Storage bucket
(`gs://chrome-components-safety-tips`) under versioned directories
(e.g. `gs://chrome-components-safety-tips/5/all` for version `5`, `all` for all
platforms).
Follow these instructions to write binary protos under versioned directories:
1. Overwrite `safety_tips.asciipb` with the data. Don't forget to increment
`version_id`.
2. Build the binary proto: `ninja -C out/Release`. This will write the binary
proto at `out/Release/gen/chrome/browser/resources/safety_tips/safety_tips.pb`.
3. Push the binary proto to cloud storage:
`chrome/browser/resources/safety_tips/push_proto.py -d out/Release`
4. Revert `safety_tips.asciipb`, update `version_id` only for future reference
and check it in.
5. In a day or two, navigate to chrome://components on Canary and check that
the version of the "Safety Tips" component is updated (you might need to press
the "Check for update" button).
**Do not check in the full proto**.
#### In case of emergency
If the Safety Tips component needs to be disabled immediately, increment the
version number and push an empty proto.
See go/safety-tips-component-update for Safety Tips component update playbook.
......@@ -43,13 +43,13 @@ class SafetyTipsProtoGenerator(BinaryProtoGenerator):
def ValidatePb(self, opts, pb):
assert pb.version_id > 0
assert len(pb.flagged_page) > 0
for flagged_page in pb.flagged_page:
assert flagged_page.url
assert flagged_page.pattern
assert flagged_page.type != safety_tips_pb2.FlaggedPage.UNKNOWN
flagged_urls = [flagged_page.url for flagged_page in pb.flagged_page]
assert sorted(flagged_urls) == flagged_urls, "Please sort flagged_page entries by URL."
flagged_patterns = [page.pattern for page in pb.flagged_page]
assert sorted(flagged_patterns) == flagged_patterns, (
"Please sort flagged_page entries by pattern.")
def ProcessPb(self, opts, pb):
binary_pb_str = pb.SerializeToString()
......
......@@ -2,17 +2,19 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Placeholder for list of known bad URLs.
# This file must be kept as-is and the full list must not be checked in to
# Chromium source. When you want to update it, overwrite it locally, generate
# and push the protobuffer to the storage bucket but do not check in the
# changes.
# Placeholder for list of known bad patterns.
# This file must be kept as-is except for version_id. The full list must not be
# checked in to Chromium source. When you want to update it, overwrite it
# locally, generate and push the protobuffer to the storage bucket but do not
# check in the changes.
version_id: 2
# See chrome/browser/lookalikes/safety_tips.proto for the full format.
# These entries must be sorted by url.
flagged_page {
url: "http://example.test/test-path-for-safety-tips/test.html"
type: BAD_REP
}
# These entries must be sorted alphabetically by pattern.
# Example entry:
# flagged_page {
# pattern: "example.test/test-path-for-safety-tips/test.html"
# type: BAD_REP
#}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment