Merge "Add namespace-level flag-write allowlist." into udc-dev
This commit is contained in:
@@ -76,7 +76,8 @@
|
||||
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.WRITE_DEVICE_CONFIG" />
|
||||
<uses-permission android:name="android.permission.READ_WRITE_SYNC_DISABLED_MODE_CONFIG" />
|
||||
<uses-permission android:name="android.permission.WRITE_ALLOWLISTED_DEVICE_CONFIG" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
per-file WritableNamespacePrefixes.java = cbrubaker@google.com,tedbauer@google.com
|
||||
@@ -2323,7 +2323,15 @@ public class SettingsProvider extends ContentProvider {
|
||||
return;
|
||||
} else if (hasAllowlistPermission) {
|
||||
for (String flag : flags) {
|
||||
if (!DeviceConfig.getAdbWritableFlags().contains(flag)) {
|
||||
boolean namespaceAllowed = false;
|
||||
for (String allowlistedPrefix : WritableNamespacePrefixes.ALLOWLIST) {
|
||||
if (flag.startsWith(allowlistedPrefix)) {
|
||||
namespaceAllowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!namespaceAllowed && !DeviceConfig.getAdbWritableFlags().contains(flag)) {
|
||||
throw new SecurityException("Permission denial for flag '"
|
||||
+ flag
|
||||
+ "'; allowlist permission granted, but must add flag to the allowlist.");
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.providers.settings;
|
||||
|
||||
import android.util.ArraySet;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Contains the list of prefixes for namespaces in which any flag can be written with adb.
|
||||
* <p>
|
||||
* A security review is required for any prefix that's added to this list. To add to
|
||||
* the list, create a change and tag the OWNER. In the change description, include a
|
||||
* description of the flag's functionality, and a justification for why it needs to be
|
||||
* allowlisted.
|
||||
*/
|
||||
final class WritableNamespacePrefixes {
|
||||
public static final Set<String> ALLOWLIST =
|
||||
new ArraySet<String>(Arrays.asList(
|
||||
"app_compat_overrides",
|
||||
"game_overlay",
|
||||
"namespace1"
|
||||
));
|
||||
}
|
||||
Reference in New Issue
Block a user