首页 > 其他分享 >【STS测试】failure of android.security.sts.KernelLtsTest#testRequiredKernelLts_WARN

【STS测试】failure of android.security.sts.KernelLtsTest#testRequiredKernelLts_WARN

时间:2024-12-27 15:31:12浏览次数:8  
标签:kernel return testRequiredKernelLts format WARN version STS deviceSpl deviceKern

总结:

获取以下信息:

1. 安全补丁版本spl:2024-12-05

2. kernel版本5.15.148

3. 确认spl+6个月是否在【kernel-lifetimes.xml】中对应版本的生命周期之内,如果不在,则报出异常

逻辑:确保安全补丁版本+6个月之后,仍旧在kernel的生命周期之内。也就是kernel版本该升级就升级吧。

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

test_result.html

分析

STS套件中 StsHostTestCases.jar 反编译

将 android-sts\testcases\StsHostTestCases.jar 拖到jadx中,会自动反编译。

testRequiredKernelLts_WARN方法的反编译结果如下:

    @Test
    public void testRequiredKernelLts_WARN() throws Exception {
        Assume.assumeFalse("The kernel update requirement failure is acknowledged; overriding test failure.", this.acknowledgedFailure);
        try {
            if (getSpl().isBefore(SplUtils.localDateFromSplString("2024-05-01"))) {//
                testRequiredKernelLtsV1(true);
            }
            testRequiredKernelLtsV2(true, this.monthsWarning, getSpl(), getKernelVersion());//private int monthsWarning = 6;//How many months before enforcement to warn for
        } catch (AssertionError e) {
            AssertionError warning = new AssertionError("This device does not meet the current or upcoming LTS update requirements. This test is a warning that is autowaived in APA and no waiver request is necessary. Optionally, to override the warning, add this argument: --test-arg com.android.compatibility.common.tradefed.testtype.JarHostTest:set-option:android.security.sts.KernelLtsTest:acknowledge_kernel_update_requirement_warning_failure:true", e);
            warning.setStackTrace(new StackTraceElement[0]);
            throw warning;
        }
    }
    private static void testRequiredKernelLtsV2(boolean warn, int monthsWarning, LocalDate deviceSpl, KernelVersion deviceKernel) throws Exception {
        try {
            if (warn) {
                Assume.assumeThat("The LTS v2 policy does not begin warning until SPL 2024-05-01", deviceSpl, Matchers.greaterThanOrEqualTo(SplUtils.localDateFromSplString("2024-05-01")));
            } else {
                Assume.assumeThat("The LTS v2 policy does not begin enforcing until SPL 2024-11-05", deviceSpl, Matchers.greaterThanOrEqualTo(SplUtils.localDateFromSplString("2024-11-05")));
            }
            Assume.assumeThat(String.format("This non-GKI kernel (%s) does not require LTS updates.", deviceKernel.toString()), deviceKernel, Matchers.greaterThanOrEqualTo(new KernelVersion(5, 10, 0)));
            List<KernelRelease> kernelLifetimes = getKernelLifetimes(KernelLtsTest.class.getResourceAsStream("/kernel-lifetimes.xml"));
            TreeMap<Integer, LocalDate> sublevelEols = (TreeMap) kernelLifetimes.stream().filter(k -> {
                return k.kernelVersion.toStringShort().equals(deviceKernel.toStringShort());
            }).filter(k2 -> {
                if (deviceKernel.osRelease.isPresent()) {
                    return ((Integer) deviceKernel.osRelease.get()).equals(k2.kernelVersion.osRelease.get());
                }
                return true;
            }).collect(Collectors.toMap(k3 -> {
                return Integer.valueOf(k3.kernelVersion.subLevel);
            }, k4 -> {
                return k4.eol;
            }, (a, b) -> {
                if (a.compareTo((ChronoLocalDate) b) >= 0) {
                    return a;
                }
                return b;
            }, TreeMap::new));
            if (sublevelEols.isEmpty()) {
                Assert.fail(String.format("Invalid combination of kernel version %s and kernel branch Android version %s is not supported by LTS policy.", deviceKernel, ((Integer) deviceKernel.osRelease.get()).toString()));
            }
            Optional<Integer> floorSublevel = Optional.ofNullable(sublevelEols.floorKey(Integer.valueOf(deviceKernel.subLevel)));
            if (!floorSublevel.map(s -> {
                return new KernelVersion(deviceKernel.version, deviceKernel.patchLevel, ((Integer) floorSublevel.get()).intValue(), deviceKernel.osRelease);
            }).isPresent()) {
                Assert.fail(String.format("Device kernel version (%s) is too old to meet policy requirements and must be updated to a newer version", deviceKernel));
            }
            Optional<Map.Entry<Integer, LocalDate>> kernelEolEntry = Optional.ofNullable(sublevelEols.floorEntry(Integer.valueOf(deviceKernel.subLevel)));
            Optional map = kernelEolEntry.map(s2 -> {
                return (LocalDate) sublevelEols.floorEntry(Integer.valueOf(deviceKernel.subLevel)).getValue();
            });
            Assert.assertFalse(String.format("Cannot find EOL for min_android_release %s.", deviceKernel.osRelease.map((v0) -> {
                return v0.toString();
            }).orElse("unknown")), map.isEmpty());
            LocalDate asbKernelEol = ((LocalDate) map.get()).withDayOfMonth(5);
            if (warn) {
                LocalDate futureSpl = deviceSpl.plusMonths(monthsWarning);//spl+6个月
                if (deviceSpl.isBefore(asbKernelEol) && !futureSpl.isBefore(asbKernelEol)) {
                    Assert.assertTrue(String.format("WARNING, this kernel (%s) will reach end of life (%s) within %s months, enforced for device SPL (%s), for current device SPL (%s). https://docs.partner.android.com/security/bulletins/kernel-lts-faq", deviceKernel, SplUtils.format((LocalDate) map.get()), Integer.valueOf(deviceSpl.until((ChronoLocalDate) map.get()).getMonths()), SplUtils.format(asbKernelEol), SplUtils.format(deviceSpl)), false);
                }//异常log就是这里
            }
            Assert.assertThat(String.format("This kernel fails the kernel LTS update requirement. The kernel version (%s) is EOL (%s) for device SPL (%s) and needs to be updated. https://docs.partner.android.com/security/bulletins/kernel-lts-faq", deviceKernel, map.get(), SplUtils.format(deviceSpl)), deviceSpl, Matchers.lessThan(asbKernelEol));
        } catch (AssertionError | AssumptionViolatedException e) {
            e.setStackTrace(new StackTraceElement[0]);
            throw e;
        }
    }

getSpl()

获取安全补丁版本。

    private LocalDate getSpl() throws DeviceNotAvailableException {
        String deviceSplString = getDevice().getProperty("ro.build.version.security_patch");
        return SplUtils.localDateFromSplString(deviceSplString);
    }

log显示版本为:

12-24 17:18:59 D/NativeDevice: Using property ro.build.version.security_patch=2024-12-05 from cache.

getKernelVersion()

    private KernelVersion getKernelVersion() throws DeviceNotAvailableException {
        return KernelVersion.parse(getDevice().executeShellCommand("uname -r"));
    }

host log中显示kernel version为5.15.148,和test result中的log对上了。

12-24 17:19:46 D/RunUtil: Running command [adb, -s, f025a2e2, shell, uname, -a] with timeout: 2m 0s
12-24 17:19:46 I/InvocationExecution: Device f025a2e2 kernel information: 'Linux localhost 5.15.148-qki-consolidate-android13-8-ge0552cd669ef-dirty #1 SMP PREEMPT Sat Dec 21 02:40:09 UTC 2024 aarch64 Toybox'

kernel-lifetimes.xml

套件版本:Suite / Build 14_sts-r33 / 12602753

也就是说5.15.148的kernel版本,生命有效期在2025-05-01,而spl(2024-12-05)+ 6 个月已经超过了该有效期。需要升级啦!

 

标签:kernel,return,testRequiredKernelLts,format,WARN,version,STS,deviceSpl,deviceKern
From: https://www.cnblogs.com/xiululu/p/18635892

相关文章

  • python爬虫实验:用Python爬取链家指定数据--附完整代码(基于requests和BeautifulSoup实
    1、前言 本实验实现了对链家房屋名字,所在小区,装饰,是否核验,楼层,总楼层以及租金进行爬取,仅供学习使用。2、url分析第二页:https://cd.lianjia.com/ershoufang/pg2/第三页:https://cd.lianjia.com/ershoufang/pg3/故第i页的url为:https://cd.lianjia.com/ershoufang/pg{i}/......
  • mysql出现unblock with 'mysqladmin flush-hosts'
    朋友发来消息,说一个系统应用登录的时候提示连接超时,让帮忙处理一下。问他应用和数据库是否都正常,回复说数据库好像没有问题,但是应用日志报无法连接数据库。数据库版本是:5.5.53让他telnet数据库是否是通的,回复说不通,并发来了信息提示:12345#telnet 8.8.9.93306......
  • AtCoder Regular Contests
    \[\begin{matrix}\color{#d9d9d9}\blacksquare\color{#D9C5B2}\blacksquare\color{#B2D9B2}\blacksquare\color{#B2ECEC}\blacksquare\color{#B2B2FF}\blacksquare\color{#ECECB2}\blacksquare\color{#FFD9B2}\blacksquare\color{#FFB2B2}\blacksqu......
  • 【RestSharp】常用的几个请求方式
    前言经常用到,做个记录代码(1)Get-Request.Query取值varurl="http://localhost:5000/api/RestSharp/TestGet";varparam=newDictionary<string,string>{{"User","123......
  • 易优CMS中模板文件 lists_tags.htm 不存在,如何解决?
    在使用易优CMS时,如果遇到模板文件 lists_tags.htm 不存在的问题,可以通过以下几种方法来解决。这个问题通常发生在自定义模板或使用官方模板时,某些文件未正确添加或缺失。以下是详细的解决步骤:方法一:手动创建 lists_tags.htm 文件登录FTP或服务器管理工具:使用FTP客户端或......
  • 网格布局警告DeprecationWarning
    过时未解决E:/pycharmProject/untitled4/QGridLayout.py:3:DeprecationWarning:sipPyTypeDict()isdeprecated,theextensionmoduleshouldusesipPyTypeDictRef()insteadclassDemo(QWidget):fromPyQt5importQtCorefromPyQt5.QtWidgetsimport*classDemo(QWid......
  • 【PyTorch】FutureWarning: You are using `torch.load` with `weights_only=False` (
    【PyTorch】FutureWarning:Youareusingtorch.loadwithweights_only=False(thecurrentdefault问题描述model.load_state_dict(torch.load(model_path))FutureWarning:Youareusing`torch.load`with`weights_only=False`(thecurrentdefaultvalue),......
  • 毕业设计:python二手车数据分析可视化系统 requests爬虫 Echarts可视化 Django框架(源码
    毕业设计:python二手车数据分析可视化系统requests爬虫Echarts可视化Django框架(源码)✅1、项目介绍技术栈:python语言、Django框架、MySQL数据库、requests爬虫技术、汽车之家二手车、Echarts可视化2、项目界面(1)中国地图–全国各地车辆数据(2)会员注册年份与等级(3)二......
  • 轻松上手!小白必看的Python Requests抓取<iframe>内容全攻略
    引言对于初学者来说,爬取网页内容是一项既有趣又具挑战性的任务。当你遇到网页中嵌入的<iframe>标签时,可能会感到困惑:如何用Python获取这些框架内的信息呢?别担心!本文将手把手教你使用requests库结合其他工具来实现这一目标。无论你是编程新手还是有一定经验的开发者,这篇文章都......
  • CS152 Representing Elephants as Lists
    CS152Lab Exercise5: Representing Elephantsas ListsThe purposeofthis project isto practice modular designofcodewitha larger,slightly more complexsimulationthanthepenguinsimulation. Wewill be makinguseof nested lists--lists......