diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-01-08 02:08:28 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-01-08 02:08:28 +0000 |
commit | a5780d0d1c6f9db75a476ec33d63bd51482a0d6d (patch) | |
tree | 08a20a2aa3cd6fd9e00011f471624b86d720991c | |
parent | cc0f5914addae033b720eea600e7640d93c1c064 (diff) | |
parent | 64f40f5e3a6ab5cc6962326ac79dba58399991ab (diff) | |
download | platform_testing-a5780d0d1c6f9db75a476ec33d63bd51482a0d6d.tar.gz |
Snap for 8055317 from 64f40f5e3a6ab5cc6962326ac79dba58399991ab to sc-v2-release
Change-Id: Ib1665cc7b8f70d6011a9096db53d7cfd70edfdd6
4 files changed, 0 insertions, 208 deletions
diff --git a/libraries/compatibility-common-util/Android.bp b/libraries/compatibility-common-util/Android.bp index 850a8bba1..5b58337e9 100644 --- a/libraries/compatibility-common-util/Android.bp +++ b/libraries/compatibility-common-util/Android.bp @@ -26,7 +26,6 @@ java_library_static { static_libs: [ "guava", "junit", - "platform-test-annotations", ], } diff --git a/libraries/compatibility-common-util/src/com/android/sts/OWNERS b/libraries/compatibility-common-util/src/com/android/sts/OWNERS deleted file mode 100644 index d029d2098..000000000 --- a/libraries/compatibility-common-util/src/com/android/sts/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# STS Owners -cdombroski@google.com diff --git a/libraries/compatibility-common-util/src/com/android/sts/common/util/SplUtils.java b/libraries/compatibility-common-util/src/com/android/sts/common/util/SplUtils.java deleted file mode 100644 index 4144fff76..000000000 --- a/libraries/compatibility-common-util/src/com/android/sts/common/util/SplUtils.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2021 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.sts.common.util; - -import java.time.Instant; -import java.time.LocalDate; -import java.time.ZoneId; -import java.time.format.DateTimeFormatter; - -/** Tools for Security Patch Levels and LocalDates representing them. */ -public final class SplUtils { - private static final ZoneId UTC_ZONE_ID = ZoneId.of("UTC"); - private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - - public static LocalDate localDateFromMillis(long millis) { - return Instant.ofEpochMilli(millis).atZone(UTC_ZONE_ID).toLocalDate(); - } - - public static LocalDate localDateFromSplString(String spl) { - return LocalDate.parse(spl, formatter); - } - - public static String format(LocalDate date) { - return date.format(formatter); - } -} diff --git a/libraries/compatibility-common-util/src/com/android/sts/common/util/StsLogic.java b/libraries/compatibility-common-util/src/com/android/sts/common/util/StsLogic.java deleted file mode 100644 index 1dec855c2..000000000 --- a/libraries/compatibility-common-util/src/com/android/sts/common/util/StsLogic.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (C) 2021 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.sts.common.util; - -import static org.junit.Assume.*; - -import android.platform.test.annotations.AsbSecurityTest; - -import com.android.compatibility.common.util.BusinessLogicMapStore; -import com.android.compatibility.common.util.MultiLog; - -import org.junit.runner.Description; - -import java.time.LocalDate; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -/** Common STS extra business logic for host-side and device-side to implement. */ -public interface StsLogic extends MultiLog { - - static final String LOG_TAG = StsLogic.class.getSimpleName(); - - // keep in sync with google3: - // //wireless/android/partner/apbs/*/config/xtsbgusinesslogic/sts_business_logic.gcl - List<String> STS_EXTRA_BUSINESS_LOGIC_FULL = Arrays.asList(new String[]{ - "uploadSpl", - "uploadModificationTime", - }); - List<String> STS_EXTRA_BUSINESS_LOGIC_INCREMENTAL = Arrays.asList(new String[]{ - "uploadSpl", - "uploadModificationTime", - "incremental", - }); - - Description getTestDescription(); - - LocalDate getDeviceSpl(); - - default long[] getCveBugIds() { - AsbSecurityTest annotation = getTestDescription().getAnnotation(AsbSecurityTest.class); - if (annotation == null) { - return null; - } - return annotation.cveBugId(); - } - - default LocalDate getMinTestSpl() { - Map<String, String> map = BusinessLogicMapStore.getMap("security_bulletins"); - if (map == null) { - throw new IllegalArgumentException("Could not find the security bulletin map"); - } - LocalDate minSpl = null; - for (long cveBugId : getCveBugIds()) { - String splString = map.get(Long.toString(cveBugId)); - if (splString == null) { - // This bug id wasn't found in the map. - // This is a new test or the bug was removed from the bulletin and this is an old - // binary. Neither is a critical issue and the test will run in these cases. - // New test: developer should be able to write the test without getting blocked. - // Removed bug + old binary: test will run. - logInfo(LOG_TAG, "could not find the CVE bug %d in the spl map", cveBugId); - continue; - } - LocalDate spl = SplUtils.localDateFromSplString(splString); - if (minSpl == null) { - minSpl = spl; - } else if (spl.isBefore(minSpl)) { - minSpl = spl; - } - } - return minSpl; - } - - default LocalDate getMinModificationDate() { - Map<String, String> map = BusinessLogicMapStore.getMap("sts_modification_times"); - if (map == null) { - throw new IllegalArgumentException("Could not find the modification date map"); - } - LocalDate minModificationDate = null; - for (long cveBugId : getCveBugIds()) { - String modificationMillisString = map.get(Long.toString(cveBugId)); - if (modificationMillisString == null) { - logInfo(LOG_TAG, - "Could not find the CVE bug %d in the modification date map", cveBugId); - continue; - } - LocalDate modificationDate = - SplUtils.localDateFromMillis(Long.parseLong(modificationMillisString)); - if (minModificationDate == null) { - minModificationDate = modificationDate; - } else if (modificationDate.isBefore(minModificationDate)) { - minModificationDate = modificationDate; - } - } - return minModificationDate; - } - - default boolean shouldSkipIncremental() { - logDebug(LOG_TAG, "filtering by incremental"); - - long[] bugIds = getCveBugIds(); - if (bugIds == null) { - // There were no @AsbSecurityTest annotations - logInfo(LOG_TAG, "not an ASB test"); - return false; - } - - // check if test spl is older than the past 6 months from the device spl - LocalDate deviceSpl = getDeviceSpl(); - LocalDate incrementalCutoffSpl = deviceSpl.plusMonths(-6); - - LocalDate minTestModifiedDate = getMinModificationDate(); - if (minTestModifiedDate == null) { - // could not get the modification date - run the test - if (Arrays.stream(bugIds).min().getAsLong() < 157905780) { - // skip if the bug id is older than ~ June 2020 - // otherwise the test will run due to missing data - logDebug(LOG_TAG, "no data for this old test"); - return true; - } - return false; - } - if (minTestModifiedDate.isAfter(incrementalCutoffSpl)) { - logDebug(LOG_TAG, "the test was recently modified"); - return false; - } - - LocalDate minTestSpl = getMinTestSpl(); - if (minTestSpl == null) { - // could not get the test spl - run the test - logWarn(LOG_TAG, "could not get the test SPL"); - return false; - } - if (minTestSpl.isAfter(incrementalCutoffSpl)) { - logDebug(LOG_TAG, "the test has a recent SPL"); - return false; - } - - logDebug(LOG_TAG, "test should skip"); - return true; - } - - default boolean shouldSkipSpl() { - return true; - } - - default void skip(String message) { - assumeTrue(message, false); - } -} |