Add neverallow rules for java_device_for_host

java_device_for_host and java_host_for_device should rarely be
used and could cause problems if used incorrectly, so restrict them
to only the necessary projects through a neverallow whitelist.

Bug: 117920228
Test: neverallow_test.go
Change-Id: I37dce489c2fb8bca71bd46dbabaaa514bf6f7eee
This commit is contained in:
Colin Cross
2019-03-05 15:06:16 -08:00
parent 7e3b571136
commit fd4f743bf4
2 changed files with 59 additions and 0 deletions

View File

@@ -159,6 +159,17 @@ var neverallowTests = []struct {
},
expectedError: "updatable-media includes private APIs. Use updatable_media_stubs instead.",
},
{
name: "java_device_for_host",
fs: map[string][]byte{
"Blueprints": []byte(`
java_device_for_host {
name: "device_for_host",
libs: ["core-libart"],
}`),
},
expectedError: "java_device_for_host can only be used in whitelisted projects",
},
}
func TestNeverallow(t *testing.T) {
@@ -187,6 +198,7 @@ func testNeverallow(t *testing.T, config Config, fs map[string][]byte) (*TestCon
ctx := NewTestContext()
ctx.RegisterModuleType("cc_library", ModuleFactoryAdaptor(newMockCcLibraryModule))
ctx.RegisterModuleType("java_library", ModuleFactoryAdaptor(newMockJavaLibraryModule))
ctx.RegisterModuleType("java_device_for_host", ModuleFactoryAdaptor(newMockJavaLibraryModule))
ctx.PostDepsMutators(registerNeverallowMutator)
ctx.Register()