Commit 4ced1fac authored by Joe Mason's avatar Joe Mason Committed by Commit Bot

Update chrome_cleaner dirs from internal repo: chrome_utils, crash, logging

Get changes from the internal repo since last branch point:
- chrome_utils now uses the sandboxed JsonParser to parse extension install methods
- add JsonParser sandbox to crash client and process information logging
- get internal API keys for official build, dummy API keys for public build
- Add FOUND_IN_PROGRAMFILES trace location

R=csharp

Bug: 830892
Change-Id: I33944eaaf31be836ac4c91041fd7e4e0d25278d2
Reviewed-on: https://chromium-review.googlesource.com/1195798Reviewed-by: default avatarChris Sharp <csharp@chromium.org>
Commit-Queue: Joe Mason <joenotcharles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587700}
parent 21e06c68
# Copyright 2018 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.
declare_args() {
# If this is true, builds an official release of the Chrome Cleanup Tool
# (requires extra Google-internal resources).
is_official_chrome_cleaner_build = false
}
...@@ -22,7 +22,9 @@ source_set("extensions_util_lib") { ...@@ -22,7 +22,9 @@ source_set("extensions_util_lib") {
] ]
deps = [ deps = [
":chrome_util_lib",
"//base:base", "//base:base",
"//chrome/chrome_cleaner/json_parser",
"//chrome/chrome_cleaner/os:common_os", "//chrome/chrome_cleaner/os:common_os",
] ]
} }
...@@ -35,12 +37,10 @@ source_set("unittest_sources") { ...@@ -35,12 +37,10 @@ source_set("unittest_sources") {
] ]
deps = [ deps = [
":chrome_util_lib",
":extensions_util_lib", ":extensions_util_lib",
"//base:base", "//base:base",
"//base/test:test_support", "//base/test:test_support",
"//chrome/chrome_cleaner/constants:common_strings", "//chrome/chrome_cleaner/json_parser",
"//chrome/chrome_cleaner/os:common_os",
"//chrome/chrome_cleaner/test:test_util", "//chrome/chrome_cleaner/test:test_util",
"//testing/gtest", "//testing/gtest",
] ]
......
...@@ -79,4 +79,42 @@ bool RetrieveChromeExePathFromCommandLine(base::FilePath* chrome_exe_path) { ...@@ -79,4 +79,42 @@ bool RetrieveChromeExePathFromCommandLine(base::FilePath* chrome_exe_path) {
return true; return true;
} }
void ListChromeExePaths(std::set<base::FilePath>* paths) {
DCHECK(paths);
static const unsigned int install_paths[] = {
base::DIR_PROGRAM_FILESX86, base::DIR_PROGRAM_FILES,
base::DIR_LOCAL_APP_DATA,
};
for (unsigned int path : install_paths) {
base::FilePath install_path;
bool success = base::PathService::Get(path, &install_path);
if (!success) {
LOG(ERROR) << "Can't get path from PathService '" << path << "'.";
continue;
}
base::FilePath chrome_path =
install_path.Append(L"google\\chrome\\application");
if (!base::PathExists(chrome_path))
continue;
paths->insert(chrome_path);
}
}
void ListChromeInstallationPaths(std::set<base::FilePath>* paths) {
DCHECK(paths);
std::set<base::FilePath> exe_paths;
ListChromeExePaths(&exe_paths);
for (const base::FilePath& exe_path : exe_paths) {
base::FilePath pattern = exe_path.Append(L"??.*.*.*");
std::vector<base::FilePath> matches;
CollectMatchingPaths(pattern, &matches);
paths->insert(matches.begin(), matches.end());
}
}
} // namespace chrome_cleaner } // namespace chrome_cleaner
...@@ -32,6 +32,14 @@ bool RetrieveChromeVersionAndInstalledDomain(base::string16* chrome_version, ...@@ -32,6 +32,14 @@ bool RetrieveChromeVersionAndInstalledDomain(base::string16* chrome_version,
// path exists. // path exists.
bool RetrieveChromeExePathFromCommandLine(base::FilePath* chrome_exe_path); bool RetrieveChromeExePathFromCommandLine(base::FilePath* chrome_exe_path);
// Search for all Chrome executable paths, for example
// "C:\Program Files\Google\Chrome\Application".
void ListChromeExePaths(std::set<base::FilePath>* paths);
// Search for all Chrome versioned installation paths, for example
// "C:\Program Files\Google\Chrome\Application\68.0.3440.84".
void ListChromeInstallationPaths(std::set<base::FilePath>* paths);
} // namespace chrome_cleaner } // namespace chrome_cleaner
#endif // CHROME_CHROME_CLEANER_CHROME_UTILS_CHROME_UTIL_H_ #endif // CHROME_CHROME_CLEANER_CHROME_UTILS_CHROME_UTIL_H_
...@@ -7,31 +7,73 @@ ...@@ -7,31 +7,73 @@
#include <vector> #include <vector>
#include "base/files/file_path.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/string16.h"
#include "base/synchronization/waitable_event.h"
#include "chrome/chrome_cleaner/json_parser/json_parser_api.h"
#include "chrome/chrome_cleaner/os/registry_util.h" #include "chrome/chrome_cleaner/os/registry_util.h"
namespace chrome_cleaner { namespace chrome_cleaner {
// A registry key that holds some form of policy for |extension_id|. // A registry key that holds some form of policy for |extension_id|.
struct ExtensionRegistryPolicy { struct ExtensionPolicyRegistryEntry {
base::string16 extension_id; base::string16 extension_id;
HKEY hkey; HKEY hkey;
base::string16 path; base::string16 path;
base::string16 name; base::string16 name;
ExtensionRegistryPolicy(const base::string16& extension_id, ExtensionPolicyRegistryEntry(const base::string16& extension_id,
HKEY hkey, HKEY hkey,
const base::string16& path, const base::string16& path,
const base::string16& name); const base::string16& name);
ExtensionRegistryPolicy(ExtensionRegistryPolicy&&); ExtensionPolicyRegistryEntry(ExtensionPolicyRegistryEntry&&);
ExtensionRegistryPolicy& operator=(ExtensionRegistryPolicy&&); ExtensionPolicyRegistryEntry& operator=(ExtensionPolicyRegistryEntry&&);
DISALLOW_COPY_AND_ASSIGN(ExtensionRegistryPolicy); DISALLOW_COPY_AND_ASSIGN(ExtensionPolicyRegistryEntry);
};
// A file that holds some form of policy for |extension_id|.
struct ExtensionPolicyFile {
base::string16 extension_id;
base::FilePath path;
ExtensionPolicyFile(const base::string16& extension_id,
const base::FilePath& path);
ExtensionPolicyFile(ExtensionPolicyFile&&);
ExtensionPolicyFile& operator=(ExtensionPolicyFile&&);
DISALLOW_COPY_AND_ASSIGN(ExtensionPolicyFile);
}; };
// Find all extension forcelist registry policies and append to |policies|. // Find all extension forcelist registry policies and append to |policies|.
void GetExtensionForcelistRegistryPolicies( void GetExtensionForcelistRegistryPolicies(
std::vector<ExtensionRegistryPolicy>* policies); std::vector<ExtensionPolicyRegistryEntry>* policies);
// Find non-whitelisted extension IDs in external_extensions.json files, which
// are extensions that will be installed by default on new user profiles. Using
// the input |json_parser| to parse JSON, append found extensions to |policies|.
// Signals |done| when all parse tasks have finished.
void GetNonWhitelistedDefaultExtensions(
JsonParserAPI* json_parser,
std::vector<ExtensionPolicyFile>* policies,
base::WaitableEvent* done);
// Find all extensions whose enterprise policy settings contain
// "installation_mode":"force_installed" and append them to |policies|. Uses the
// input |json_parser| to parse JSON, and signals |done| when all parse tasks
// have finished.
void GetExtensionSettingsForceInstalledExtensions(
JsonParserAPI* json_parser,
std::vector<ExtensionPolicyRegistryEntry>* policies,
base::WaitableEvent* done);
// Find master preferences extensions, which are installed to new user profiles,
// and append them to |policies|. Uses the input |json_parser| to parse JSON,
// and signals |done| when all parse tasks have finished.
void GetMasterPreferencesExtensions(JsonParserAPI* json_parser,
std::vector<ExtensionPolicyFile>* policies,
base::WaitableEvent* done);
} // namespace chrome_cleaner } // namespace chrome_cleaner
......
...@@ -195,6 +195,9 @@ bool CrashpadCrashClient::InitializeCrashReporting(Mode mode, ...@@ -195,6 +195,9 @@ bool CrashpadCrashClient::InitializeCrashReporting(Mode mode,
case SandboxType::kEset: case SandboxType::kEset:
SetCrashKey(kProcessType, "eset"); SetCrashKey(kProcessType, "eset");
break; break;
case SandboxType::kJsonParser:
SetCrashKey(kProcessType, "json_parser");
break;
default: default:
NOTREACHED(); NOTREACHED();
} }
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import("//chrome/chrome_cleaner/chrome_cleaner_args.gni")
source_set("scoped_timed_task_logger") { source_set("scoped_timed_task_logger") {
sources = [ sources = [
"scoped_timed_task_logger.cc", "scoped_timed_task_logger.cc",
...@@ -66,11 +68,20 @@ source_set("logging_definitions") { ...@@ -66,11 +68,20 @@ source_set("logging_definitions") {
] ]
} }
source_set("dummy_api_keys") { source_set("api_keys_header") {
sources = [ sources = [
"api_keys.h", "api_keys.h",
]
}
source_set("dummy_api_keys") {
sources = [
"dummy_api_keys.cc", "dummy_api_keys.cc",
] ]
deps = [
":api_keys_header",
]
} }
static_library("cleaner_logging") { static_library("cleaner_logging") {
...@@ -84,7 +95,7 @@ static_library("cleaner_logging") { ...@@ -84,7 +95,7 @@ static_library("cleaner_logging") {
] ]
deps = [ deps = [
":dummy_api_keys", ":api_keys_header",
"//base", "//base",
"//chrome/chrome_cleaner/chrome_utils:chrome_util_lib", "//chrome/chrome_cleaner/chrome_utils:chrome_util_lib",
"//chrome/chrome_cleaner/constants:chrome_cleanup_tool_branding_header", "//chrome/chrome_cleaner/constants:chrome_cleanup_tool_branding_header",
...@@ -101,6 +112,12 @@ static_library("cleaner_logging") { ...@@ -101,6 +112,12 @@ static_library("cleaner_logging") {
"//components/chrome_cleaner/public/constants:constants", "//components/chrome_cleaner/public/constants:constants",
] ]
if (is_official_chrome_cleaner_build) {
deps += [ "//chrome_cleaner_internal/logging:api_keys" ]
} else {
deps += [ ":dummy_api_keys" ]
}
public_deps = [ public_deps = [
":common", ":common",
] ]
...@@ -113,7 +130,7 @@ static_library("reporter_logging") { ...@@ -113,7 +130,7 @@ static_library("reporter_logging") {
] ]
deps = [ deps = [
":dummy_api_keys", ":api_keys_header",
"//base", "//base",
"//chrome/chrome_cleaner/chrome_utils:chrome_util_lib", "//chrome/chrome_cleaner/chrome_utils:chrome_util_lib",
"//chrome/chrome_cleaner/constants:common_strings", "//chrome/chrome_cleaner/constants:common_strings",
...@@ -127,6 +144,12 @@ static_library("reporter_logging") { ...@@ -127,6 +144,12 @@ static_library("reporter_logging") {
"//components/chrome_cleaner/public/constants:constants", "//components/chrome_cleaner/public/constants:constants",
] ]
if (is_official_chrome_cleaner_build) {
deps += [ "//chrome_cleaner_internal/logging:api_keys" ]
} else {
deps += [ ":dummy_api_keys" ]
}
public_deps = [ public_deps = [
":common", ":common",
] ]
......
...@@ -203,6 +203,7 @@ message UwS { ...@@ -203,6 +203,7 @@ message UwS {
FOUND_IN_SCHEDULED_TASK = 8; // Task scheduler FOUND_IN_SCHEDULED_TASK = 8; // Task scheduler
FOUND_IN_CLSID = 9; // CLSID FOUND_IN_CLSID = 9; // CLSID
FOUND_IN_MODULES = 10; // Loaded modules of a process FOUND_IN_MODULES = 10; // Loaded modules of a process
FOUND_IN_PROGRAMFILES = 11; // "Program Files" directory
} }
repeated TraceLocation trace_locations = 9; repeated TraceLocation trace_locations = 9;
...@@ -244,6 +245,7 @@ message ProcessInformation { ...@@ -244,6 +245,7 @@ message ProcessInformation {
MAIN = 1; MAIN = 1;
DEPRECATED_SIGNATURE_MATCHER_SANDBOX = 2; DEPRECATED_SIGNATURE_MATCHER_SANDBOX = 2;
ESET_SANDBOX = 3; ESET_SANDBOX = 3;
JSON_PARSER_SANDBOX = 4;
} }
optional Process process = 1; optional Process process = 1;
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/win/i18n.h" #include "base/win/i18n.h"
#include "base/win/windows_version.h" #include "base/win/windows_version.h"
...@@ -27,7 +26,7 @@ ...@@ -27,7 +26,7 @@
namespace chrome_cleaner { namespace chrome_cleaner {
namespace { namespace {
// TODO(joenotcharles): refer to the report definition in the "data" section. // TODO(joenotcharles): Refer to the report definition in the "data" section.
constexpr net::NetworkTrafficAnnotationTag kReporterTrafficAnnotation = constexpr net::NetworkTrafficAnnotationTag kReporterTrafficAnnotation =
net::DefineNetworkTrafficAnnotation("unwanted_software_report", R"( net::DefineNetworkTrafficAnnotation("unwanted_software_report", R"(
semantics { semantics {
......
...@@ -250,6 +250,9 @@ ProcessInformation GetProcessInformationProtoObject( ...@@ -250,6 +250,9 @@ ProcessInformation GetProcessInformationProtoObject(
case SandboxType::kEset: case SandboxType::kEset:
process_info.set_process(ProcessInformation::ESET_SANDBOX); process_info.set_process(ProcessInformation::ESET_SANDBOX);
break; break;
case SandboxType::kJsonParser:
process_info.set_process(ProcessInformation::JSON_PARSER_SANDBOX);
break;
default: default:
NOTREACHED() << "Unknown sandbox type " << static_cast<int>(process_type); NOTREACHED() << "Unknown sandbox type " << static_cast<int>(process_type);
} }
......
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