Add comments and clarify errors in neverallow
Sample of new error for violation: error: system/bt/gd/rust/topshim/macros/Android.bp:10:1: module "libtopshim_macros" variant "linux_glibc_x86_64": violates neverallow requirements. Not allowed: module types: ["rust_benchmark" "rust_benchmark_host" "rust_binary" "rust_binary_host" "rust_library" "rust_library_dylib" "rust_library_rlib" "rust_ffi" "rust_ffi_shared" "rust_ffi_static" "rust_fuzz" "rust_library_host" "rust_library_host_dylib" "rust_library_host_rlib" "rust_ffi_host" "rust_ffi_host_shared" "rust_ffi_host_static" "rust_proc_macro" "rust_test" "rust_test_host"] EXCEPT in dirs: ["device/google/cuttlefish/" "external/adhd/" "external/crosvm/" "external/libchromeos-rs/" "external/minijail/" "external/rust/" "external/selinux/libselinux/" "external/uwb/" "external/vm_tools/p9/" "frameworks/native/libs/binder/rust/" "frameworks/proto_logging/stats/" "packages/modules/DnsResolver/" "packages/modules/Virtualization/" "prebuilts/rust/" "system/core/libstats/pull_rust/" "system/extras/profcollectd/" "system/extras/simpleperf/" "system/hardware/interfaces/keystore2/" "system/librustutils/" "system/logging/liblog/" "system/logging/rust/" "system/nfc/" "system/security/" "system/tools/aidl/" "tools/security/fuzzing/example_rust_fuzzer/" "tools/security/fuzzing/orphans/" "vendor/"] Old error: error: system/bt/gd/rust/topshim/macros/Android.bp:10:1: module "libtopshim_macros" variant "linux_glibc_x86_64": neverallow -dir:device/google/cuttlefish/* -dir:external/adhd/* -dir:external/crosvm/* -dir:external/libchromeos-rs/* -dir:external/minijail/* -dir:external/rust/* -dir:external/selinux/libselinux/* -dir:external/uwb/* -dir:external/vm_tools/p9/* -dir:frameworks/native/libs/binder/rust/* -dir:frameworks/proto_logging/stats/* -dir:packages/modules/DnsResolver/* -dir:packages/modules/Virtualization/* -dir:prebuilts/rust/* -dir:system/core/libstats/pull_rust/* -dir:system/extras/profcollectd/* -dir:system/extras/simpleperf/* -dir:system/hardware/interfaces/keystore2/* -dir:system/librustutils/* -dir:system/logging/liblog/* -dir:system/logging/rust/* -dir:system/nfc/* -dir:system/security/* -dir:system/tools/aidl/* -dir:tools/security/fuzzing/example_rust_fuzzer/* -dir:tools/security/fuzzing/orphans/* -dir:vendor/* type:"rust_benchmark" type:"rust_benchmark_host type:rust_binary type:rust_binary_host type:rust_library type:rust_library_dylib type:rust_library_rlib type:rust_ffi type:rust_ffi_shared type:rust_ffi_static type:rust_fuzz type:rust_library_host type:rust_library_host_dylib type:rust_library_host_rlib type:rust_ffi_host type:rust_ffi_host_shared type:rust_ffi_host_static type:rust_proc_macro type:rust_test type:rust_test_host Test: go test soong tests Change-Id: I1a7ee6bbc8258dfffa5a76f02c12fb1e54fdba1a
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
package android
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
@@ -55,7 +56,37 @@ var neverallowTests = []struct {
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "libother": violates neverallow deps:not_allowed_in_direct_deps`,
|
||||
regexp.QuoteMeta("module \"libother\": violates neverallow requirements. Not allowed:\n\tdep(s): [\"not_allowed_in_direct_deps\"]"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "multiple constraints",
|
||||
rules: []Rule{
|
||||
NeverAllow().
|
||||
InDirectDeps("not_allowed_in_direct_deps").
|
||||
In("other").
|
||||
ModuleType("cc_library").
|
||||
NotIn("top").
|
||||
NotModuleType("cc_binary"),
|
||||
},
|
||||
fs: map[string][]byte{
|
||||
"top/Android.bp": []byte(`
|
||||
cc_library {
|
||||
name: "not_allowed_in_direct_deps",
|
||||
}`),
|
||||
"other/Android.bp": []byte(`
|
||||
cc_library {
|
||||
name: "libother",
|
||||
static_libs: ["not_allowed_in_direct_deps"],
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
regexp.QuoteMeta(`module "libother": violates neverallow requirements. Not allowed:
|
||||
in dirs: ["other/"]
|
||||
module types: ["cc_library"]
|
||||
dep(s): ["not_allowed_in_direct_deps"]
|
||||
EXCEPT in dirs: ["top/"]
|
||||
EXCEPT module types: ["cc_binary"]`),
|
||||
},
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user