This test compares values of variables CVE_CHECK_IGNORE with
CVE_IGNORED that is exported from cve-export.bbclass

Signed-off-by: Akash Hadke <akash.ha...@kpit.com>
Signed-off-by: Akash Hadke <hadkeaka...@gmail.com>
---
 meta/lib/oeqa/selftest/cases/cve_export.py | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/cve_export.py

diff --git a/meta/lib/oeqa/selftest/cases/cve_export.py 
b/meta/lib/oeqa/selftest/cases/cve_export.py
new file mode 100644
index 0000000000..7c7fd07957
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/cve_export.py
@@ -0,0 +1,24 @@
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake, get_bb_var
+from oe.cve_check import get_ignored_cves
+
+class CveExportTest (OESelftestTestCase):
+
+    def test_ignored_cves(self):
+        """
+        This test compares the values of variables CVE_CHECK_IGNORE with
+        CVE_IGNORED that is exported from cve-export.bbclass
+        """
+        target = 'unzip'
+        feature = 'INHERIT += "cve-export"\n'
+        feature += 'require conf/distro/include/cve-extra-exclusions.inc'
+        self.write_config(feature)
+
+        res = bitbake("%s -c fetch" % target, ignore_status=True)
+        self.assertEqual(res.status, 0, "\nCouldn't build.\nbitbake output %s" 
% res.output)
+
+        paths = get_bb_var('PATH', target).split(':')
+        cves = get_bb_var('CVE_CHECK_IGNORE', target).split()
+        final_cve = get_ignored_cves(paths, cves)
+        ignore_cves_from_exported_variable = get_bb_var('CVE_IGNORED', target)
+        self.assertEqual(final_cve, 
ignore_cves_from_exported_variable.strip(), "Ignored CVEs are not matching")
-- 
2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#165501): 
https://lists.openembedded.org/g/openembedded-core/message/165501
Mute This Topic: https://lists.openembedded.org/mt/91037024/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to