Commit graph

63 commits

Author SHA1 Message Date
Jiyong Park
3c306f3d1d Don't allow using framework and SDK at the same time.
Using SDK (current, system_current, module_current, or <api_version>)
while at the same time depending on "framework" doesn't make sense
because framework anyway provides all APIs including hidden ones. This
is not only uncessary but also error prone because the availability of a
private method in a class depends on whether the class is part of the
SDK or not.

Add a neverallow rule for prohibiting that. Note that "core_*" SDKs are
allowed because there's no overlap between "framework" and the core-Java
SDKs.

Bug: 227528906
Test: m nothing on git_master
Change-Id: I0605075aef20c75db084beeedcbf49a642573e69
2022-04-05 15:39:05 +09:00
Anton Hansson
e1b1836939 Revert "Relax apex package restriction for T+ jars"
This reverts commit 1fdd6ca88a.

Reason for revert: b/205289292 tracks the real fix for this

Test: presubmit
Change-Id: I5a2edaf4f930dafa26659f85d9425e9041c72275
Merged-In: I5a2edaf4f930dafa26659f85d9425e9041c72275
2022-04-04 17:27:43 +00:00
Inseob Kim
865d5e6c9d Merge "Revert^3 "Add seapp_contexts to allowlist of makefile goal"" 2022-01-10 11:15:28 +00:00
Inseob Kim
a9078747bb Revert^3 "Add seapp_contexts to allowlist of makefile goal"
This reverts commit feb0756d41.

Reason for revert: redundant now

Change-Id: I6cd43f03a28d03a87d19510a554e3bbe0e69b1de
2021-12-29 08:59:19 +00:00
Liz Kammer
a3d7915c9e 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
2021-12-21 12:00:43 -05:00
Remi NGUYEN VAN
1fdd6ca88a Relax apex package restriction for T+ jars
The ART AOT exemption only applies to Q/R/S, so module jars that have
min_sdk T+ do not need to follow the module package restriction, even if
they are part of a Q/R/S module (but not loaded on Q/R/S).

Relax the restriction to only apply to jars that have min_sdk before T.

Bug: 208773835
Test: m (runs apex tests)
Change-Id: I2c3ad8984ca05ad763bf6162bd478f93ab4ee650
2021-12-09 18:28:47 +09:00
Yuntao Xu
feb0756d41 Revert^2 "Add seapp_contexts to allowlist of makefile goal"
e87a81673e

Change-Id: I461f3ecdd0b0ea0a4b7b12531cf8b561e170df55
2021-11-18 22:33:02 +00:00
Vova Sharaienko
e87a81673e Revert "Add seapp_contexts to allowlist of makefile goal"
Revert submission 1795972-Convert security/Android.mk to Android.bp

Reason for revert: http://b/206976319 Broken build 7928060 on aosp-master on sdk_arm64-sdk
Reverted Changes:
I0e0e7f677:Split property and file contexts modules
I5596d6f00:Add seapp_contexts to allowlist of makefile goal
If685e5ccc:Convert security/Android.mk to Android.bp

Change-Id: I8cf8c0bc2f88172bb3bfa850bbd7ce6daa170c3d
2021-11-18 17:29:01 +00:00
Inseob Kim
a92d10bdf2 Add seapp_contexts to allowlist of makefile goal
This is an interim solution before seapp_contexts and seapp_neverallows
are migrated into Soong. CtsSecurityHostTests needs these two modules.

Bug: 194096505
Test: build
Change-Id: I5596d6f00b957afd86c752501c1e83b3d4089d9e
2021-11-05 05:10:26 +00:00
Steven Moreland
8fc8dbf70c start eating include_dirs from both ends
Further restrictions on a restricting build configuration. Before, we
restricted certain paths from being included. Now, we restrict certain
paths from including.

This adds system/libfmq for now, but I'm planning to add more in the
future, as they are cleaned up.

Bug: 35624006
Test: m nothing
Change-Id: I913f190f93ab63059ee0372d342daa8f5584806b
2021-04-27 02:56:03 +00:00
Paul Duffin
45338f05e3 Convert TestApexPermittedPackagesRules to use test fixtures
Adds PrepareForTestWithNeverallowRules to make it easy to test
neverallow rules. Avoid exporting any unnecessary neverallow related
methods from the android package.

Bug: 181070625
Test: m nothing
Change-Id: Idfc6955cb23f1a4d1790be7879388154b03f3980
2021-03-31 16:16:18 +01:00
Paul Duffin
3cb2c06b44 Cleanup some issues left over from previous reviews
Bug: 183235980
Test: m nothing
Change-Id: I187765c56b889445de3a4729405ee745e5f73729
2021-03-24 22:08:05 +00:00
Paul Duffin
30ac3e7ca7 Remove uses of FixtureFactory from android package
Bug: 183235980
Test: m nothing
Change-Id: I72898ada020ee1a73fd534c61afb5c22fa00c1e5
2021-03-22 18:31:53 +00:00
Paul Duffin
3c6a4ea24a Convert android/neverallow_test.go to test fixtures
Bug: 182885307
Test: m nothing
Change-Id: I5679cb517151ceaf468f2fe2e0ccab718cc7b4a3
2021-03-18 12:18:09 +00:00
Hyundo Moon
8bee1b00ea Allow service-media-s in apex
Bug: 175511943
Test: Builds successfully
Change-Id: I5d76087d3c537205e8b8ca837c13ca1aeb641b4c
2021-01-21 02:21:23 +00:00
Anton Hansson
0af20effc1 Remove sdk_version: "none" restriction
Not entirely sure what the history behind requiring only libcore
projects use this, but it is a bit annoying to have to allow-list every
use.

Bug: 173606718
Test: m nothing
Change-Id: I66f71e67d3f17e7f983c8537dff537fe8419da95
2020-12-17 15:43:29 +00:00
Colin Cross
ae8600b507 Pass Config to NewTestContext instead of ctx.Register
Prepare for using Config when adding singletons by passing
Config to NewTestContext and NewContext instead of to ctx.Register.
This will enable a followup change to store SingletonMakeVarsProviders
registered on the Context in the Config, which is necessary to run
multiple tests in parallel without data races.

Test: all soong tests
Change-Id: Id229629a4e42ff4487d317241673837726c075fc
2020-11-12 10:07:49 -08:00
Colin Cross
405af07859 Revert "Make lots of tests run in parallel"
This reverts commit 323dc60712.

Reason for revert: Possible cause of test instability
Bug: 170513220
Test: soong tests

Change-Id: Iee168e9fbb4210569e6cffcc23e60d111403abb8
2020-10-09 18:34:24 -07:00
Colin Cross
323dc60712 Make lots of tests run in parallel
Putting t.Parallel() in each test makes them run in parallel.
Additional t.Parallel() could be added to each subtest, although
that requires making a local copy of the loop variable for
table driven tests.

Test: m checkbuild
Change-Id: I5d9869ead441093f4d7c5757f2447385333a95a4
2020-10-06 15:12:22 -07:00
Yifan Hong
696ed4d54c Add makefile_goal.
Only for boot images.

Test: add one makefile_goal
Bug: 158537840
Change-Id: I88a006a1c7bfbf79f10f5360aae27a9bc267e42d
2020-07-28 09:51:15 -07:00
Colin Cross
440e0d0542 Use inclusive language in build/soong
Test: m checkbuild
Change-Id: Id07890b7cbc2397291a658ca00e86b43c743aafc
2020-06-11 15:33:16 -07:00
David Srbecky
e033cbae40 Allow the user to explicitly set the java Uncompress_dex property.
ART tests need to explicitly control the compression.

Bug: 157239179
Test: "atest ArtGtestsTarget" with http://go/aog/1302773
Change-Id: I4490aa0a61fa71f830feb6a46dffd8d20fccfc66
Merged-In: I4490aa0a61fa71f830feb6a46dffd8d20fccfc66
2020-05-21 19:59:25 +01:00
Artur Satayev
c5570ac9b1 Allow defining neverallow in packages other than android.
This exposes test func on ValueMatcher and helpers relevant for testing neverallows.

Bug: 153333044
Test: m
Change-Id: Ied07cd33afa537f9d7aa3c33e59f4ac985901a0f
2020-04-15 12:06:13 +01:00
Anton Hansson
453764070d Expand neverallow for sdk_version: none
Allow the platform stubs to specify sdk_version: none,
and add generic support for a regexp matcher.

Bug: 144149403
Test: m
Change-Id: Icaece0d9797bace8ae9741f7a029b9ea57fcbbb9
2020-04-09 14:59:16 +01:00
Colin Cross
c511bc50dc Revert^2 "Add sdk mutator for native modules"
f8e80229fe

Change-Id: Ic30ab6b844684bfc3e8ece5a1913980d5fbf8de2
2020-04-07 16:50:32 +00:00
Colin Cross
f8e80229fe Revert "Add sdk mutator for native modules"
Revert submission 1242911-sdk_version_variant

Reason for revert: b/153394225
Reverted Changes:
Ife99745fb:Use libnativewindow for platform variant of libagq...
I1bae84c43:Use libnativewindow for platform variant of androi...
I6e6021ed3:Use stl to depend on libc++
Ife99745fb:Use libnativewindow for platform variant of libRSS...
I2c9f439b9:Fix static dependency on libprotobuf-cpp-lite-ndk
Iff2aff9cf:Set sdk_version for cc_genrules used by modules wi...
I7d72934aa:Add sdk mutator for native modules
Ief378a007:Use sdk variant of Soong modules when LOCAL_SDK_VE...

Bug: 149591340
Change-Id: I798fa902c779469c6382b6699351e5d12bf14785
Fixes: 153394225
2020-04-07 04:21:21 +00:00
Colin Cross
82e192c3ae Add sdk mutator for native modules
Compiling native modules against the NDK disables platform features
like ASAN.  For anything shipped on the system image there is no
reason to compile against the NDK.  Add a new mutator to Soong that
creates a platform and an SDK variant for modules that set
sdk_version, and ignore sdk_version for the platform variant.  The
SDK variant will be used for embedding in APKs that may be installed
on older platforms.  Apexes use their own variants that enforce
backwards compatibility.

Test: sdk_test.go
Test: TestJNIPackaging
Bug: 149591340
Change-Id: I7d72934aaee2e1326cc0ba5f29f51f14feec4521
2020-04-01 16:09:05 -07:00
Colin Cross
98be1bb00f Move filesystem into Config
The filesystem object was available through ModuleContext.Fs(), but
gives too much access to the filesystem without enforicing correct
dependencies.  In order to support sandboxing the soong_build
process move the filesystem into the Config.  The next change will
make it private.

Bug: 146437378
Test: all Soong tests
Change-Id: I5d3ae9108f120fd335b21efd612aefa078378813
2019-12-18 08:19:10 -08:00
Colin Cross
4b49b768a2 Make TestContext.RegisterModuleType take an android.ModuleFactory
Avoid having to pass ModuleFactoryAdaptor to every call to
RegisterModuleType in a test by wrapping RegisterModuleType.

Test: all soong tests
Change-Id: If8847d16487de0479cc3020b728256922b3cadba
2019-11-25 10:59:44 -08:00
Paul Duffin
7322b5271a Allow per test rules in neverallow_test.go
am: 115445b5d6

Change-Id: I6e7ce7fc42e2fbd186ed4e37fa362faf8cc30fac
2019-09-03 05:44:15 -07:00
Paul Duffin
115445b5d6 Allow per test rules in neverallow_test.go
Makes testing individual rules easier by allowing them to be specified
per test rather than having to add them to the global defaults.

Bug: 138428610
Test: m nothing
Change-Id: Ic65a55dee2a02b6d33254753c047295dd5804408
2019-09-03 10:33:29 +01:00
Paul Duffin
91e3819335 Support multiple expected errors in neverallow_test.go
Extracted some common code used by visibility_test.go and
neverallow_test.go into a new function CheckErrorsAgainstExpectations
in testing.go.

Bug: 138428610
Test: m nothing
Change-Id: I6996fa52968c387e38b4a67ffa59cd07c2d524e8
Merged-In: Iafbadf12c6ffdc4d9128fcfe7f15792df5cfd020
2019-09-03 10:33:29 +01:00
Paul Duffin
b5af6204d3 Support multiple expected errors in neverallow_test.go
Extracted some common code used by visibility_test.go and
neverallow_test.go into a new function CheckErrorsAgainstExpectations
in testing.go.

(cherry picked from commit 8e47e8bc41)
Bug: 138428610
Test: m nothing
Change-Id: Iafbadf12c6ffdc4d9128fcfe7f15792df5cfd020
2019-08-09 09:31:41 +00:00
Paul Duffin
c9c0f52ea5 Merge changes from topic "restrict-libandroidicu-usages"
am: d5a57d8fc5

Change-Id: I5c6fa0a1806bbbb502564d96a8f28a110162c6e8
2019-08-07 04:10:21 -07:00
Paul Duffin
3578188fac Support restrictions based on a module's dependencies
Adds a neverallow InDirectDeps(deps) verb that will allow a neverallow
rule to restrict access to a specific dependency, irrespective of how
it is specified.

Bug: 137543088
Test: m nothing
Change-Id: I0c6bb702d55175e9b78b79e86e96924c5dd83efa
2019-08-06 11:09:02 +01:00
Paul Duffin
c811170ab6 Revert "Revert "Prevent runtime module paths being used in include_dirs""
This reverts commit ff3d72f0bf.

Repplies original change now that issue causing build breakage has been
resolved.

Adds a new StartsWith(string) ValueMatcher along with
With[Out]Matcher(...) methods to support new restrictions that prevent
any paths into runtime module repositories from being added to the
include_dirs.

Test: m nothing
Bug: 35624006
Change-Id: I4c802ef25ef56f0f9b0b5e9d75531ea6f7475714
2019-07-22 12:24:49 +01:00
Ming-Shin Lu
ff3d72f0bf Revert "Prevent runtime module paths being used in include_dirs"
This reverts commit 31d0688df9.

Reason for revert: cause build breakage on stage-aosp-master

Change-Id: I7626f8ec36caaaa5eb4c7e9891565fc164a7f6c7
2019-07-22 06:44:34 +00:00
Paul Duffin
31d0688df9 Prevent runtime module paths being used in include_dirs
am: 2ac2befc9a

Change-Id: Ia7683cb3400013a78bd62b4f7c002c7f0e352903
2019-07-21 04:14:26 -07:00
Paul Duffin
2ac2befc9a Prevent runtime module paths being used in include_dirs
Adds a new StartsWith(string) ValueMatcher along with
With[Out]Matcher(...) methods to support new restrictions that prevent
any paths into runtime module repositories from being added to the
include_dirs.

Test: m nothing
Bug: 35624006
Change-Id: Ib954998e5fc190d8a11a8c6ac5f810cad927aac3
2019-07-19 19:36:25 +01:00
Paul Duffin
b3438891a0 Merge changes I42cb181f,I6413c9b1 am: 33ee25466f
am: 00c2bbb0e7

Change-Id: Icca90608b256e726a9a1bd79e9cedca1a6b53f84
2019-06-17 15:25:30 -07:00
Paul Duffin
a3d0986cfc Remove the no_standard_libs property
Corrects an error message that refers to no_standard_libs.

Removes any tests that use no_standard_libs:true where possible as
there are duplicate tests for sdk_version:"none". Otherwise, switches
them over to use sdk_version:"none".

The androidmk mapping from LOCAL_NO_STANDARD_LIBRARIES to
no_standard_libs has also been removed. There was little point in
updating the tool to map it through to sdk_version:"none" as there are
only a couple of places where it is used, in art's test running mk
targets and in some unbundled packages to work around some limitation
in .mk based build.

Bug: 134566750
Test: m droid
Change-Id: I6413c9b1fe3e63b93753a6a017d2981e32b7e013
2019-06-17 11:21:39 +01:00
Steven Moreland
03cdfe1b31 Merge "neverallow: vintf to libhidltransport impl lib" into qt-dev
am: 6df90831b7

Change-Id: Ibd0f318e8cbc3ee3e24f7f768b85dfafed7565d1
2019-06-14 16:17:12 -07:00
Steven Moreland
a1165d6958 neverallow: vintf to libhidltransport impl lib
Also delete useless testcase.

Bug: 134961554
Test: build

Change-Id: Ie76492f806757b86d94d29a736773f72ce2ab104
2019-06-14 22:04:53 +00:00
Paul Duffin
f45775edbe Merge "Add sdk_version:"none" to replace no_standard_libs:true" am: b11c72b0b8
am: e34bbae1ca

Change-Id: I9465a810dad7f3ea95b6c883844358d817f8cc8e
2019-06-14 01:32:45 -07:00
Paul Duffin
52d398a841 Add sdk_version:"none" to replace no_standard_libs:true
Where possible this duplicates any tests that use no_standard_libs:true
with ones that use sdk_version:"none". If not possible (e.g. in the
default targets included in java/testing.go) it switches some to use
sdk_version:"none" to ensure that there is no regression in the
behavior of no_standard_libs:true.

Follow up changes will switch all usages of no_standard_libs:true over
to use sdk_version:"none" at which point no_standard_libs will be
removed.

Bug: 134566750
Test: m droid
Change-Id: I5f0fd3daa980f6b223abe454cba7f25a97a39d7a
2019-06-13 19:15:10 +01:00
Paul Duffin
065000e3f5 Merge "Never allow java_library_host with no_standard_libs: true" am: 393590d8a8
am: 3321670746

Change-Id: Iebd7f4cd4979860ea1b2f9433373546c114d2160
2019-06-13 00:17:11 -07:00
Paul Duffin
393590d8a8 Merge "Never allow java_library_host with no_standard_libs: true" 2019-06-13 06:57:19 +00:00
Colin Cross
31de2eaf51 Merge changes Ia17b2bcb,Ic71892c3,Id2b23b9e,I435ee7aa,I85112506, ... am: 72ea641dff
am: 98a6f300fa

Change-Id: I84683c2204afb5792ec11e2c608dca288e9431ec
2019-06-12 13:52:07 -07:00
Colin Cross
72ea641dff Merge changes Ia17b2bcb,Ic71892c3,Id2b23b9e,I435ee7aa,I85112506, ...
* changes:
  Consolidate *MutatorContext and ModuleContext into BaseModuleContext
  Add test for missing defaults modules with AllowMissingDependencies
  Capture missing dependency error rules
  Share buildDir for android/soong/android tests
  Reimplement AddMissingDependencies
  Add GenerateAndroidBuildActions to DefaultsModuleBase
2019-06-12 20:19:55 +00:00
Paul Duffin
b815ada8c0 Never allow java_library_host with no_standard_libs: true
This combination makes no sense.

Bug: 134566750
Test: m droid
Change-Id: Ib37bbac165395c003d23225e0469ba60fa6a56ea
2019-06-12 14:08:13 +01:00