Commit 9cdd041d authored by Oleg Davydov's avatar Oleg Davydov Committed by Commit Bot

Add ContentVerifierDelegate::ShouldBeChecked

All policy-based extensions' files should be checked in some way. It
already works for Chrome Web Store extension, but not yet for
self-hosted ones. This commit adds a way of telling to ContentVerifier
that extension should be checked.

The commit only adds a new delegate method, which is not yet used.

Bug: 958794
Change-Id: I67898ce61c47d9ecc53c0398bfa5e9bdb65373b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1710327Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Reviewed-by: default avatarNikita Podguzov <nikitapodguzov@google.com>
Commit-Queue: Oleg Davydov <burunduk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683213}
parent deb100c5
...@@ -135,6 +135,15 @@ ChromeContentVerifierDelegate::ChromeContentVerifierDelegate( ...@@ -135,6 +135,15 @@ ChromeContentVerifierDelegate::ChromeContentVerifierDelegate(
ChromeContentVerifierDelegate::~ChromeContentVerifierDelegate() { ChromeContentVerifierDelegate::~ChromeContentVerifierDelegate() {
} }
bool ChromeContentVerifierDelegate::ShouldBeChecked(
const Extension& extension) {
// All policy-based extensions should have some checks.
return ShouldBeVerified(extension);
// TODO(crbug.com/958794): After all preparations enable content checking for
// all policy-based extension (even for self-hosted ones):
// || Manifest::IsPolicyLocation(extension.location());
}
bool ChromeContentVerifierDelegate::ShouldBeVerified( bool ChromeContentVerifierDelegate::ShouldBeVerified(
const Extension& extension) { const Extension& extension) {
return GetVerifyMode(extension) != NONE; return GetVerifyMode(extension) != NONE;
......
...@@ -55,6 +55,7 @@ class ChromeContentVerifierDelegate : public ContentVerifierDelegate { ...@@ -55,6 +55,7 @@ class ChromeContentVerifierDelegate : public ContentVerifierDelegate {
~ChromeContentVerifierDelegate() override; ~ChromeContentVerifierDelegate() override;
// ContentVerifierDelegate: // ContentVerifierDelegate:
bool ShouldBeChecked(const Extension& extension) override;
bool ShouldBeVerified(const Extension& extension) override; bool ShouldBeVerified(const Extension& extension) override;
ContentVerifierKey GetPublicKey() override; ContentVerifierKey GetPublicKey() override;
GURL GetSignatureFetchUrl(const std::string& extension_id, GURL GetSignatureFetchUrl(const std::string& extension_id,
......
...@@ -133,6 +133,10 @@ void TestContentVerifyJobObserver::JobFinished( ...@@ -133,6 +133,10 @@ void TestContentVerifyJobObserver::JobFinished(
MockContentVerifierDelegate::MockContentVerifierDelegate() = default; MockContentVerifierDelegate::MockContentVerifierDelegate() = default;
MockContentVerifierDelegate::~MockContentVerifierDelegate() = default; MockContentVerifierDelegate::~MockContentVerifierDelegate() = default;
bool MockContentVerifierDelegate::ShouldBeChecked(const Extension& extension) {
return true;
}
bool MockContentVerifierDelegate::ShouldBeVerified(const Extension& extension) { bool MockContentVerifierDelegate::ShouldBeVerified(const Extension& extension) {
return true; return true;
} }
......
...@@ -111,6 +111,7 @@ class MockContentVerifierDelegate : public ContentVerifierDelegate { ...@@ -111,6 +111,7 @@ class MockContentVerifierDelegate : public ContentVerifierDelegate {
~MockContentVerifierDelegate() override; ~MockContentVerifierDelegate() override;
// ContentVerifierDelegate: // ContentVerifierDelegate:
bool ShouldBeChecked(const Extension& extension) override;
bool ShouldBeVerified(const Extension& extension) override; bool ShouldBeVerified(const Extension& extension) override;
ContentVerifierKey GetPublicKey() override; ContentVerifierKey GetPublicKey() override;
GURL GetSignatureFetchUrl(const ExtensionId& extension_id, GURL GetSignatureFetchUrl(const ExtensionId& extension_id,
......
...@@ -25,11 +25,18 @@ class ContentVerifierDelegate { ...@@ -25,11 +25,18 @@ class ContentVerifierDelegate {
public: public:
virtual ~ContentVerifierDelegate() {} virtual ~ContentVerifierDelegate() {}
// Returns whether or not resources from |extension| should be verified. // Returns true if resources from |extension| should be checked for some
// content mismatch at all. Note that differs from ShouldBeVerified, and does
// not consider whether |extension| has signed hashes (verified_contents.json)
// or not.
virtual bool ShouldBeChecked(const Extension& extension) = 0;
// Returns whether or not resources from |extension| should be verified using
// signed hashes data (verified_contents.json). If yes, methods GetPublicKey
// and GetSignatureFetchUrl might be used.
virtual bool ShouldBeVerified(const Extension& extension) = 0; virtual bool ShouldBeVerified(const Extension& extension) = 0;
// Returns the public key to use for validating signatures via the two out // Returns the public key to use for validating signatures.
// parameters.
virtual ContentVerifierKey GetPublicKey() = 0; virtual ContentVerifierKey GetPublicKey() = 0;
// Returns a URL that can be used to fetch the verified_contents.json // Returns a URL that can be used to fetch the verified_contents.json
......
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