diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/components/enterprise | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/enterprise')
-rw-r--r-- | chromium/components/enterprise/BUILD.gn | 19 | ||||
-rw-r--r-- | chromium/components/enterprise/DEPS | 5 | ||||
-rw-r--r-- | chromium/components/enterprise/OWNERS | 11 | ||||
-rw-r--r-- | chromium/components/enterprise/browser/reporting/policy_info.cc | 142 | ||||
-rw-r--r-- | chromium/components/enterprise/browser/reporting/policy_info.h | 36 | ||||
-rw-r--r-- | chromium/components/enterprise/browser/reporting/report_request_definition.h | 29 | ||||
-rw-r--r-- | chromium/components/enterprise/common/BUILD.gn | 10 | ||||
-rw-r--r-- | chromium/components/enterprise/common/proto/BUILD.gn | 12 | ||||
-rw-r--r-- | chromium/components/enterprise/common/proto/connectors.proto | 106 | ||||
-rw-r--r-- | chromium/components/enterprise/common/strings.cc | 13 | ||||
-rw-r--r-- | chromium/components/enterprise/common/strings.h | 18 |
11 files changed, 401 insertions, 0 deletions
diff --git a/chromium/components/enterprise/BUILD.gn b/chromium/components/enterprise/BUILD.gn new file mode 100644 index 00000000000..f87dab1fa26 --- /dev/null +++ b/chromium/components/enterprise/BUILD.gn @@ -0,0 +1,19 @@ +# Copyright 2020 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +static_library("enterprise") { + sources = [ + "browser/reporting/policy_info.cc", + "browser/reporting/policy_info.h", + "browser/reporting/report_request_definition.h", + ] + + deps = [ + "//base", + "//components/policy/core/browser", + "//components/policy/core/common", + "//components/policy/proto", + "//components/strings", + ] +} diff --git a/chromium/components/enterprise/DEPS b/chromium/components/enterprise/DEPS new file mode 100644 index 00000000000..0544504cf9a --- /dev/null +++ b/chromium/components/enterprise/DEPS @@ -0,0 +1,5 @@ +include_rules = [ + "+components/policy", + "+components/safe_browsing/core/proto", + "+components/strings/grit", +] diff --git a/chromium/components/enterprise/OWNERS b/chromium/components/enterprise/OWNERS new file mode 100644 index 00000000000..c6d1e611f7a --- /dev/null +++ b/chromium/components/enterprise/OWNERS @@ -0,0 +1,11 @@ +domfc@chromium.org +emaxx@chromium.org +nicolaso@chromium.org +pastarmovj@chromium.org +pmarko@chromium.org +rogerta@chromium.org +ydago@chromium.org +zmin@chromium.org + +# COMPONENT: Enterprise + diff --git a/chromium/components/enterprise/browser/reporting/policy_info.cc b/chromium/components/enterprise/browser/reporting/policy_info.cc new file mode 100644 index 00000000000..dd690664510 --- /dev/null +++ b/chromium/components/enterprise/browser/reporting/policy_info.cc @@ -0,0 +1,142 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/enterprise/browser/reporting/policy_info.h" + +#include <string> + +#include "base/json/json_writer.h" +#include "build/build_config.h" +#include "components/policy/core/browser/policy_conversions.h" +#include "components/policy/core/common/cloud/cloud_policy_client.h" +#include "components/policy/core/common/cloud/cloud_policy_constants.h" +#include "components/policy/core/common/cloud/machine_level_user_cloud_policy_manager.h" +#include "components/policy/core/common/policy_types.h" +#include "components/strings/grit/components_strings.h" + +namespace em = enterprise_management; + +namespace enterprise_reporting { + +namespace { + +em::Policy_PolicyLevel GetLevel(const base::Value& policy) { + switch (static_cast<policy::PolicyLevel>(*policy.FindIntKey("level"))) { + case policy::POLICY_LEVEL_RECOMMENDED: + return em::Policy_PolicyLevel_LEVEL_RECOMMENDED; + case policy::POLICY_LEVEL_MANDATORY: + return em::Policy_PolicyLevel_LEVEL_MANDATORY; + } + NOTREACHED() << "Invalid policy level: " << *policy.FindIntKey("level"); + return em::Policy_PolicyLevel_LEVEL_UNKNOWN; +} + +em::Policy_PolicyScope GetScope(const base::Value& policy) { + switch (static_cast<policy::PolicyScope>(*policy.FindIntKey("scope"))) { + case policy::POLICY_SCOPE_USER: + return em::Policy_PolicyScope_SCOPE_USER; + case policy::POLICY_SCOPE_MACHINE: + return em::Policy_PolicyScope_SCOPE_MACHINE; + } + NOTREACHED() << "Invalid policy scope: " << *policy.FindIntKey("scope"); + return em::Policy_PolicyScope_SCOPE_UNKNOWN; +} + +em::Policy_PolicySource GetSource(const base::Value& policy) { + switch (static_cast<policy::PolicySource>(*policy.FindIntKey("source"))) { + case policy::POLICY_SOURCE_ENTERPRISE_DEFAULT: + return em::Policy_PolicySource_SOURCE_ENTERPRISE_DEFAULT; + case policy::POLICY_SOURCE_CLOUD: + return em::Policy_PolicySource_SOURCE_CLOUD; + case policy::POLICY_SOURCE_ACTIVE_DIRECTORY: + return em::Policy_PolicySource_SOURCE_ACTIVE_DIRECTORY; + case policy::POLICY_SOURCE_DEVICE_LOCAL_ACCOUNT_OVERRIDE: + return em::Policy_PolicySource_SOURCE_DEVICE_LOCAL_ACCOUNT_OVERRIDE; + case policy::POLICY_SOURCE_PLATFORM: + return em::Policy_PolicySource_SOURCE_PLATFORM; + case policy::POLICY_SOURCE_PRIORITY_CLOUD: + return em::Policy_PolicySource_SOURCE_PRIORITY_CLOUD; + case policy::POLICY_SOURCE_MERGED: + return em::Policy_PolicySource_SOURCE_MERGED; + case policy::POLICY_SOURCE_COUNT: + NOTREACHED(); + return em::Policy_PolicySource_SOURCE_UNKNOWN; + } + NOTREACHED() << "Invalid policy source: " << *policy.FindIntKey("source"); + return em::Policy_PolicySource_SOURCE_UNKNOWN; +} + +void UpdatePolicyInfo(em::Policy* policy_info, + const std::string& policy_name, + const base::Value& policy) { + policy_info->set_name(policy_name); + policy_info->set_level(GetLevel(policy)); + policy_info->set_scope(GetScope(policy)); + policy_info->set_source(GetSource(policy)); + base::JSONWriter::Write(*policy.FindKey("value"), + policy_info->mutable_value()); + const std::string* error = policy.FindStringKey("error"); + std::string deprecated_error; + std::string future_error; + // Because server side use keyword "deprecated" to determine policy + // deprecation error. Using l10n string actually causing issue. + if (policy.FindBoolKey("deprecated")) + deprecated_error = "This policy has been deprecated"; + + if (policy.FindBoolKey("future")) + future_error = "This policy hasn't been released"; + + if (error && !deprecated_error.empty()) + policy_info->set_error( + base::JoinString({*error, deprecated_error, future_error}, "\n")); + else if (error) + policy_info->set_error(*error); + else if (!deprecated_error.empty()) + policy_info->set_error(deprecated_error); +} + +} // namespace + +void AppendChromePolicyInfoIntoProfileReport( + const base::Value& policies, + em::ChromeUserProfileInfo* profile_info) { + for (const auto& policy_iter : + policies.FindKey("chromePolicies")->DictItems()) { + UpdatePolicyInfo(profile_info->add_chrome_policies(), policy_iter.first, + policy_iter.second); + } +} + +void AppendExtensionPolicyInfoIntoProfileReport( + const base::Value& policies, + em::ChromeUserProfileInfo* profile_info) { + for (const auto& extension_iter : + policies.FindKey("extensionPolicies")->DictItems()) { + const base::Value& policies = extension_iter.second; + if (policies.DictSize() == 0) + continue; + auto* extension = profile_info->add_extension_policies(); + extension->set_extension_id(extension_iter.first); + for (const auto& policy_iter : policies.DictItems()) { + UpdatePolicyInfo(extension->add_policies(), policy_iter.first, + policy_iter.second); + } + } +} + +void AppendMachineLevelUserCloudPolicyFetchTimestamp( + em::ChromeUserProfileInfo* profile_info, + policy::MachineLevelUserCloudPolicyManager* manager) { +#if !defined(OS_CHROMEOS) + if (!manager || !manager->IsClientRegistered()) + return; + auto* timestamp = profile_info->add_policy_fetched_timestamps(); + timestamp->set_type( + policy::dm_protocol::kChromeMachineLevelExtensionCloudPolicyType); + timestamp->set_timestamp( + manager->core()->client()->last_policy_timestamp().ToJavaTime()); +#endif // !defined(OS_CHROMEOS) +} + +} // namespace enterprise_reporting diff --git a/chromium/components/enterprise/browser/reporting/policy_info.h b/chromium/components/enterprise/browser/reporting/policy_info.h new file mode 100644 index 00000000000..82a5fa9ea7a --- /dev/null +++ b/chromium/components/enterprise/browser/reporting/policy_info.h @@ -0,0 +1,36 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_ENTERPRISE_BROWSER_REPORTING_POLICY_INFO_H_ +#define COMPONENTS_ENTERPRISE_BROWSER_REPORTING_POLICY_INFO_H_ + +#include "components/policy/proto/device_management_backend.pb.h" + +namespace base { +class Value; +} + +namespace policy { +class MachineLevelUserCloudPolicyManager; +} + +// Unit tests are in chrome\browser\enterprise\reporting\policy_info_unittest.cc +// TODO(crbug.com/1096499): Move the tests to this directory. +namespace enterprise_reporting { + +void AppendChromePolicyInfoIntoProfileReport( + const base::Value& policies, + enterprise_management::ChromeUserProfileInfo* profile_info); + +void AppendExtensionPolicyInfoIntoProfileReport( + const base::Value& policies, + enterprise_management::ChromeUserProfileInfo* profile_info); + +void AppendMachineLevelUserCloudPolicyFetchTimestamp( + enterprise_management::ChromeUserProfileInfo* profile_info, + policy::MachineLevelUserCloudPolicyManager* manager); + +} // namespace enterprise_reporting + +#endif // COMPONENTS_ENTERPRISE_BROWSER_REPORTING_POLICY_INFO_H_ diff --git a/chromium/components/enterprise/browser/reporting/report_request_definition.h b/chromium/components/enterprise/browser/reporting/report_request_definition.h new file mode 100644 index 00000000000..5fdcc22ca81 --- /dev/null +++ b/chromium/components/enterprise/browser/reporting/report_request_definition.h @@ -0,0 +1,29 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_ENTERPRISE_BROWSER_REPORTING_REPORT_REQUEST_DEFINITION_H_ +#define COMPONENTS_ENTERPRISE_BROWSER_REPORTING_REPORT_REQUEST_DEFINITION_H_ + +#include "build/build_config.h" +#include "components/policy/proto/device_management_backend.pb.h" + +namespace enterprise_reporting { + +namespace definition { + +// Both ChromeOsUserReportRequest and ChromeDesktopReportRequest are used to +// upload usage data to DM Server. By the reference to this macro, most classes +// in enterprise_reporting namespace can share the same logic for various +// operation systems. +#if defined(OS_CHROMEOS) +using ReportRequest = enterprise_management::ChromeOsUserReportRequest; +#else +using ReportRequest = enterprise_management::ChromeDesktopReportRequest; +#endif + +} // namespace definition + +} // namespace enterprise_reporting + +#endif // COMPONENTS_ENTERPRISE_BROWSER_REPORTING_REPORT_REQUEST_DEFINITION_H_ diff --git a/chromium/components/enterprise/common/BUILD.gn b/chromium/components/enterprise/common/BUILD.gn new file mode 100644 index 00000000000..cea78da082b --- /dev/null +++ b/chromium/components/enterprise/common/BUILD.gn @@ -0,0 +1,10 @@ +# Copyright 2020 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +static_library("strings") { + sources = [ + "strings.cc", + "strings.h", + ] +} diff --git a/chromium/components/enterprise/common/proto/BUILD.gn b/chromium/components/enterprise/common/proto/BUILD.gn new file mode 100644 index 00000000000..38563e2ea2d --- /dev/null +++ b/chromium/components/enterprise/common/proto/BUILD.gn @@ -0,0 +1,12 @@ +# Copyright 2020 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//third_party/protobuf/proto_library.gni") + +proto_library("connectors_proto") { + proto_in_dir = "//" + sources = [ "connectors.proto" ] + + deps = [ "//components/safe_browsing/core:csd_proto" ] +} diff --git a/chromium/components/enterprise/common/proto/connectors.proto b/chromium/components/enterprise/common/proto/connectors.proto new file mode 100644 index 00000000000..1fafb7ef9e8 --- /dev/null +++ b/chromium/components/enterprise/common/proto/connectors.proto @@ -0,0 +1,106 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +syntax = "proto2"; + +option optimize_for = LITE_RUNTIME; + +package enterprise_connectors; + +// For ClientDownloadRequest. +import "components/safe_browsing/core/proto/csd.proto"; + +// Which connector is calling BinaryUploadService so that the proper rules can +// be triggered. BinaryUploadService also uses this value to find the URL that +// the payload should be uploaded to. +// +// The values in this enum can be extended in future versions of Chrome to +// support new analysis connectors. +enum AnalysisConnector { + ANALYSIS_CONNECTOR_UNSPECIFIED = 0; + FILE_DOWNLOADED = 1; + FILE_ATTACHED = 2; + BULK_DATA_ENTRY = 3; +} + +message ContentMetaData { + // The URL containing the file download/upload or to which web content is + // being uploaded. + optional string url = 1; + + // Name of file on user system (if applicable). + optional string filename = 2; + + // Sha256 digest of file. + optional string digest = 3; + + // Specifically for the download case. + optional safe_browsing.ClientDownloadRequest csd = 4; +} + +// Analysis request sent from chrome to backend. +message ContentAnalysisRequest { + // The TokenID for Enterprise-enrolled devices. This identifies a specific + // chrome instance. + optional string device_token = 1; + + // Firebase Cloud Messaging token used to notify this client of the verdict. + // This identifies a specific chrome instance. + optional string fcm_notification_token = 2; + + // Which enterprise connector fired this request. + optional AnalysisConnector analysis_connector = 9; + + // Information about the data that triggered the content analysis request. + optional ContentMetaData request_data = 10; + + // Token used to correlate requests and responses. This is different than the + // FCM token in that it is unique for each request. + optional string request_token = 5; + + // The tags configured for the URL that triggered the content analysis. + repeated string tags = 11; + + // Reserved to make sure there is no overlap with DeepScanningClientRequest. + reserved 3, 4, 6 to 8; +} + +// Scanning response sent from backend to Chrome. +message ContentAnalysisResponse { + // Token used to correlate requests and responses. Corresponds to field in + // ContentAnalysisRequest with the same name. + optional string request_token = 1; + + // Represents the analysis result from a given tag. + message Result { + optional string tag = 1; + + // The status of this result. + enum Status { + STATUS_UNKNOWN = 0; + SUCCESS = 1; + FAILURE = 2; + } + optional Status status = 2; + + // Identifies the detection rules that were triggered by the analysis. + // Only relevant when status is SUCCESS. + message TriggeredRule { + enum Action { + ACTION_UNSPECIFIED = 0; + REPORT_ONLY = 1; + WARN = 2; + BLOCK = 3; + } + optional Action action = 1; + optional string rule_name = 2; + optional string rule_id = 3; + } + repeated TriggeredRule triggered_rules = 3; + } + repeated Result results = 4; + + // Reserved to make sure there is no overlap with DeepScanningClientResponse. + reserved 2 to 3; +} diff --git a/chromium/components/enterprise/common/strings.cc b/chromium/components/enterprise/common/strings.cc new file mode 100644 index 00000000000..529ed8b1d2c --- /dev/null +++ b/chromium/components/enterprise/common/strings.cc @@ -0,0 +1,13 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/enterprise/common/strings.h" + +namespace enterprise { + +const char kUrlParamConnector[] = "connector"; +const char kUrlParamDeviceToken[] = "device_token"; +const char kUrlParamTag[] = "tag"; + +} // namespace enterprise diff --git a/chromium/components/enterprise/common/strings.h b/chromium/components/enterprise/common/strings.h new file mode 100644 index 00000000000..df3d348a633 --- /dev/null +++ b/chromium/components/enterprise/common/strings.h @@ -0,0 +1,18 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_ENTERPRISE_COMMON_STRINGS_H_ +#define COMPONENTS_ENTERPRISE_COMMON_STRINGS_H_ + +namespace enterprise { + +// URL parameters used when enterprise connectors call on service provider +// endpoints. +extern const char kUrlParamConnector[]; +extern const char kUrlParamDeviceToken[]; +extern const char kUrlParamTag[]; + +} // namespace enterprise + +#endif // COMPONENTS_ENTERPRISE_COMMON_STRINGS_H_ |