Merge "Support whitelist entries from class2greylist"

This commit is contained in:
David Brazdil
2018-08-27 21:41:04 +00:00
committed by Gerrit Code Review

View File

@@ -325,6 +325,7 @@ $(OUT_DOCS)/offline-sdk-timestamp: $(OUT_DOCS)/offline-sdk-docs-docs.zip
include $(CLEAR_VARS) include $(CLEAR_VARS)
# File names of final API lists # File names of final API lists
LOCAL_WHITELIST := $(INTERNAL_PLATFORM_HIDDENAPI_WHITELIST)
LOCAL_LIGHT_GREYLIST := $(INTERNAL_PLATFORM_HIDDENAPI_LIGHT_GREYLIST) LOCAL_LIGHT_GREYLIST := $(INTERNAL_PLATFORM_HIDDENAPI_LIGHT_GREYLIST)
LOCAL_DARK_GREYLIST := $(INTERNAL_PLATFORM_HIDDENAPI_DARK_GREYLIST) LOCAL_DARK_GREYLIST := $(INTERNAL_PLATFORM_HIDDENAPI_DARK_GREYLIST)
LOCAL_BLACKLIST := $(INTERNAL_PLATFORM_HIDDENAPI_BLACKLIST) LOCAL_BLACKLIST := $(INTERNAL_PLATFORM_HIDDENAPI_BLACKLIST)
@@ -374,6 +375,13 @@ endef
# or have alternative rules for building them. Other rules in the build system # or have alternative rules for building them. Other rules in the build system
# should depend on the files in the build folder. # should depend on the files in the build folder.
# Merge whitelist from:
# (1) public API stubs
# (2) whitelist entries generated by class2greylist (PRIVATE_WHITELIST_INPUTS)
$(LOCAL_WHITELIST): $(LOCAL_SRC_PUBLIC_API)
sort $(LOCAL_SRC_PUBLIC_API) $(PRIVATE_WHITELIST_INPUTS) > $@
$(call assert-has-no-duplicates,$@)
# Merge light greylist from multiple files: # Merge light greylist from multiple files:
# (1) manual greylist LOCAL_SRC_GREYLIST # (1) manual greylist LOCAL_SRC_GREYLIST
# (2) list of usages from vendor apps LOCAL_SRC_VENDOR_LIST # (2) list of usages from vendor apps LOCAL_SRC_VENDOR_LIST
@@ -384,6 +392,7 @@ endef
# Automatically adds all methods which match the signatures in # Automatically adds all methods which match the signatures in
# REGEX_SERIALIZATION. These are greylisted in order to allow applications # REGEX_SERIALIZATION. These are greylisted in order to allow applications
# to write their own serializers. # to write their own serializers.
# (5) greylist entries generated by class2greylist (PRIVATE_GREYLIST_INPUTS)
$(LOCAL_LIGHT_GREYLIST): REGEX_SERIALIZATION := \ $(LOCAL_LIGHT_GREYLIST): REGEX_SERIALIZATION := \
"readObject\(Ljava/io/ObjectInputStream;\)V" \ "readObject\(Ljava/io/ObjectInputStream;\)V" \
"readObjectNoData\(\)V" \ "readObjectNoData\(\)V" \
@@ -392,7 +401,7 @@ $(LOCAL_LIGHT_GREYLIST): REGEX_SERIALIZATION := \
"serialPersistentFields:\[Ljava/io/ObjectStreamField;" \ "serialPersistentFields:\[Ljava/io/ObjectStreamField;" \
"writeObject\(Ljava/io/ObjectOutputStream;\)V" \ "writeObject\(Ljava/io/ObjectOutputStream;\)V" \
"writeReplace\(\)Ljava/lang/Object;" "writeReplace\(\)Ljava/lang/Object;"
$(LOCAL_LIGHT_GREYLIST): $(LOCAL_SRC_ALL) $(LOCAL_LIGHT_GREYLIST): $(LOCAL_SRC_ALL) $(LOCAL_WHITELIST)
sort $(LOCAL_SRC_GREYLIST) $(LOCAL_SRC_VENDOR_LIST) $(PRIVATE_GREYLIST_INPUTS) \ sort $(LOCAL_SRC_GREYLIST) $(LOCAL_SRC_VENDOR_LIST) $(PRIVATE_GREYLIST_INPUTS) \
<(grep -E "\->("$(subst $(space),"|",$(REGEX_SERIALIZATION))")$$" \ <(grep -E "\->("$(subst $(space),"|",$(REGEX_SERIALIZATION))")$$" \
$(LOCAL_SRC_PRIVATE_API)) \ $(LOCAL_SRC_PRIVATE_API)) \
@@ -400,6 +409,7 @@ $(LOCAL_LIGHT_GREYLIST): $(LOCAL_SRC_ALL)
> $@ > $@
$(call assert-has-no-duplicates,$@) $(call assert-has-no-duplicates,$@)
$(call assert-is-subset,$@,$(LOCAL_SRC_PRIVATE_API)) $(call assert-is-subset,$@,$(LOCAL_SRC_PRIVATE_API))
$(call assert-has-no-overlap,$@,$(LOCAL_WHITELIST))
$(call assert-has-no-overlap,$@,$(LOCAL_SRC_FORCE_BLACKLIST)) $(call assert-has-no-overlap,$@,$(LOCAL_SRC_FORCE_BLACKLIST))
# Generate dark greylist as remaining classes and class members in the same # Generate dark greylist as remaining classes and class members in the same
@@ -412,9 +422,9 @@ $(LOCAL_LIGHT_GREYLIST): $(LOCAL_SRC_ALL)
# name but do not contain another forward-slash in the class name, e.g. # name but do not contain another forward-slash in the class name, e.g.
# matching '^Lpackage/subpackage/[^/;]*;' # matching '^Lpackage/subpackage/[^/;]*;'
# (4) subtract entries shared with LOCAL_LIGHT_GREYLIST # (4) subtract entries shared with LOCAL_LIGHT_GREYLIST
$(LOCAL_DARK_GREYLIST): $(LOCAL_SRC_ALL) $(LOCAL_LIGHT_GREYLIST) $(LOCAL_DARK_GREYLIST): $(LOCAL_SRC_ALL) $(LOCAL_WHITELIST) $(LOCAL_LIGHT_GREYLIST)
comm -13 <(sort $(LOCAL_LIGHT_GREYLIST) $(LOCAL_SRC_FORCE_BLACKLIST)) \ comm -13 <(sort $(LOCAL_WHITELIST) $(LOCAL_LIGHT_GREYLIST) $(LOCAL_SRC_FORCE_BLACKLIST)) \
<(cat $(LOCAL_SRC_PUBLIC_API) $(LOCAL_LIGHT_GREYLIST) | \ <(cat $(LOCAL_WHITELIST) $(LOCAL_LIGHT_GREYLIST) | \
sed 's/\->.*//' | sed 's/\(.*\/\).*/\1/' | sort | uniq | \ sed 's/\->.*//' | sed 's/\(.*\/\).*/\1/' | sort | uniq | \
while read PKG_NAME; do \ while read PKG_NAME; do \
grep -E "^$${PKG_NAME}[^/;]*;" $(LOCAL_SRC_PRIVATE_API); \ grep -E "^$${PKG_NAME}[^/;]*;" $(LOCAL_SRC_PRIVATE_API); \
@@ -422,16 +432,18 @@ $(LOCAL_DARK_GREYLIST): $(LOCAL_SRC_ALL) $(LOCAL_LIGHT_GREYLIST)
> $@ > $@
$(call assert-is-subset,$@,$(LOCAL_SRC_PRIVATE_API)) $(call assert-is-subset,$@,$(LOCAL_SRC_PRIVATE_API))
$(call assert-has-no-duplicates,$@) $(call assert-has-no-duplicates,$@)
$(call assert-has-no-overlap,$@,$(LOCAL_WHITELIST))
$(call assert-has-no-overlap,$@,$(LOCAL_LIGHT_GREYLIST)) $(call assert-has-no-overlap,$@,$(LOCAL_LIGHT_GREYLIST))
$(call assert-has-no-overlap,$@,$(LOCAL_SRC_FORCE_BLACKLIST)) $(call assert-has-no-overlap,$@,$(LOCAL_SRC_FORCE_BLACKLIST))
# Generate blacklist as private API minus (light greylist plus dark greylist). # Generate blacklist as private API minus (light greylist plus dark greylist).
$(LOCAL_BLACKLIST): $(LOCAL_SRC_ALL) $(LOCAL_LIGHT_GREYLIST) $(LOCAL_DARK_GREYLIST) $(LOCAL_BLACKLIST): $(LOCAL_SRC_ALL) $(LOCAL_WHITELIST) $(LOCAL_LIGHT_GREYLIST) $(LOCAL_DARK_GREYLIST)
comm -13 <(sort $(LOCAL_LIGHT_GREYLIST) $(LOCAL_DARK_GREYLIST)) \ comm -13 <(sort $(LOCAL_WHITELIST) $(LOCAL_LIGHT_GREYLIST) $(LOCAL_DARK_GREYLIST)) \
<(sort $(LOCAL_SRC_PRIVATE_API)) \ <(sort $(LOCAL_SRC_PRIVATE_API)) \
> $@ > $@
$(call assert-is-subset,$@,$(LOCAL_SRC_PRIVATE_API)) $(call assert-is-subset,$@,$(LOCAL_SRC_PRIVATE_API))
$(call assert-has-no-duplicates,$@) $(call assert-has-no-duplicates,$@)
$(call assert-has-no-overlap,$@,$(LOCAL_WHITELIST))
$(call assert-has-no-overlap,$@,$(LOCAL_LIGHT_GREYLIST)) $(call assert-has-no-overlap,$@,$(LOCAL_LIGHT_GREYLIST))
$(call assert-has-no-overlap,$@,$(LOCAL_DARK_GREYLIST)) $(call assert-has-no-overlap,$@,$(LOCAL_DARK_GREYLIST))
$(call assert-is-subset,$(LOCAL_SRC_FORCE_BLACKLIST),$@) $(call assert-is-subset,$(LOCAL_SRC_FORCE_BLACKLIST),$@)