forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds sandbox API for policy diagnostics
This will eventually support a chrome://sandbox WebUI for Windows. Adds PolicyList and PolicyInfo types, the GetPolicyInfo() interface to the sandbox (broker) and a basic implementation which simply returns an empty list. The intention is that GetPolicyInfo() will be called on a low priority thread, and will then wait until the tracking thread can complete the work of cloning policy information before returning. PolicyInfo is merely stubbed out at the moment and will be expanded to describe more of the policy once this gets plugged into the webui later. Change-Id: Ie6ea8180e26ad71fa9e1628a2e9eef8f46a93fbd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1756952 Commit-Queue: Alex Gough <ajgo@chromium.org> Reviewed-by: Will Harris <wfh@chromium.org> Cr-Commit-Position: refs/heads/master@{#695409}
- Loading branch information
Showing
10 changed files
with
332 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// 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 "sandbox/win/src/sandbox_constants.h" | ||
|
||
namespace sandbox { | ||
// Strings used as keys in base::Value snapshots of Policies. | ||
extern const char kProcessIds[] = "process_ids"; | ||
|
||
} // namespace sandbox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// 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 SANDBOX_WIN_SRC_SANDBOX_CONSTANTS_H_ | ||
#define SANDBOX_WIN_SRC_SANDBOX_CONSTANTS_H_ | ||
|
||
namespace sandbox { | ||
// Strings used as keys in base::Value snapshots of Policies. | ||
extern const char kProcessIds[]; | ||
|
||
} // namespace sandbox | ||
|
||
#endif // SANDBOX_WIN_SRC_SANDBOX_CONSTANTS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// 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 "sandbox/win/src/sandbox_policy_info.h" | ||
|
||
#include "base/numerics/safe_conversions.h" | ||
#include "base/values.h" | ||
#include "sandbox/win/src/sandbox_constants.h" | ||
#include "sandbox/win/src/sandbox_policy_base.h" | ||
#include "sandbox/win/src/target_process.h" | ||
|
||
namespace sandbox { | ||
|
||
namespace { | ||
|
||
base::Value ProcessIdList(std::vector<uint32_t>& pids) { | ||
base::ListValue results; | ||
for (auto pid : pids) { | ||
results.GetList().push_back(base::Value(base::strict_cast<double>(pid))); | ||
} | ||
|
||
return std::move(results); | ||
} | ||
} // namespace | ||
|
||
// We are a friend of PolicyBase so that we can steal its private members | ||
// quickly in the BrokerServices tracker thread. | ||
PolicyInfo::PolicyInfo(PolicyBase* policy) { | ||
DCHECK(policy); | ||
// TODO(crbug/997273) Add more fields once webui plumbing is complete. | ||
{ | ||
AutoLock lock(&policy->lock_); | ||
for (auto&& target_process : policy->targets_) { | ||
process_ids_.push_back( | ||
base::strict_cast<uint32_t>(target_process->ProcessId())); | ||
} | ||
} | ||
} | ||
|
||
PolicyInfo::~PolicyInfo() {} | ||
|
||
base::Value PolicyInfo::GetValue() { | ||
// TODO(crbug/997273) Add more fields once webui plumbing is complete. | ||
base::DictionaryValue val; | ||
val.SetKey(kProcessIds, ProcessIdList(process_ids_)); | ||
return std::move(val); | ||
} | ||
|
||
} // namespace sandbox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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 SANDBOX_WIN_SRC_SANDBOX_POLICY_INFO_H_ | ||
#define SANDBOX_WIN_SRC_SANDBOX_POLICY_INFO_H_ | ||
|
||
#include <vector> | ||
|
||
#include "base/values.h" | ||
|
||
namespace sandbox { | ||
|
||
class PolicyBase; | ||
|
||
// Intended to rhyme with TargetPolicy, may eventually share a common base | ||
// with a configuration holding class (i.e. this class will extend with dynamic | ||
// members such as the |process_ids_| list.) | ||
class PolicyInfo { | ||
public: | ||
// This should quickly copy what it needs from PolicyBase. | ||
PolicyInfo(PolicyBase* policy); | ||
~PolicyInfo(); | ||
|
||
base::Value GetValue(); | ||
|
||
private: | ||
std::vector<uint32_t> process_ids_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(PolicyInfo); | ||
}; | ||
|
||
} // namespace sandbox | ||
|
||
#endif // SANDBOX_WIN_SRC_SANDBOX_POLICY_INFO_H_ |
Oops, something went wrong.