summaryrefslogtreecommitdiffstats
path: root/external/meta-security/meta-security-isafw/lib
diff options
context:
space:
mode:
Diffstat (limited to 'external/meta-security/meta-security-isafw/lib')
-rw-r--r--external/meta-security/meta-security-isafw/lib/isafw/__init__.py40
-rw-r--r--external/meta-security/meta-security-isafw/lib/isafw/isafw.py158
-rw-r--r--external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_cfa_plugin.py392
-rw-r--r--external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_cve_plugin.py217
-rw-r--r--external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_fsa_plugin.py185
-rw-r--r--external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_kca_plugin.py323
-rw-r--r--external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_la_plugin.py273
-rw-r--r--external/meta-security/meta-security-isafw/lib/isafw/isaplugins/__init__.py42
-rw-r--r--external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/__init__.py0
-rw-r--r--external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/kca/__init__.py0
-rw-r--r--external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/kca/arm.py24
-rw-r--r--external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/kca/common.py242
-rw-r--r--external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/kca/x86.py38
-rw-r--r--external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/la/approved-non-osi43
-rw-r--r--external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/la/exceptions0
-rw-r--r--external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/la/licenses105
-rw-r--r--external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/la/violations7
17 files changed, 2089 insertions, 0 deletions
diff --git a/external/meta-security/meta-security-isafw/lib/isafw/__init__.py b/external/meta-security/meta-security-isafw/lib/isafw/__init__.py
new file mode 100644
index 00000000..50527fbe
--- /dev/null
+++ b/external/meta-security/meta-security-isafw/lib/isafw/__init__.py
@@ -0,0 +1,40 @@
+#
+# __init__.py - part of ISA FW
+#
+# Copyright (c) 2015 - 2016, Intel Corporation
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of Intel Corporation nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""isafw
+
+Current Contents:
+
+* isafw.py - main class
+* plugins - ISA plugins
+* plugins/configs - configuration data for the plugins
+"""
+
+__all__ = [
+ 'isafw',
+]
diff --git a/external/meta-security/meta-security-isafw/lib/isafw/isafw.py b/external/meta-security/meta-security-isafw/lib/isafw/isafw.py
new file mode 100644
index 00000000..a1a76b8a
--- /dev/null
+++ b/external/meta-security/meta-security-isafw/lib/isafw/isafw.py
@@ -0,0 +1,158 @@
+#
+# isafw.py - Main classes for ISA FW
+#
+# Copyright (c) 2015 - 2016, Intel Corporation
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of Intel Corporation nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+from __future__ import absolute_import, print_function
+
+import sys
+import traceback
+try:
+ # absolute import
+ import isafw.isaplugins as isaplugins
+except ImportError:
+ # relative import when installing as separate modules
+ import isaplugins
+try:
+ from bb import error
+except ImportError:
+ error = print
+
+__all__ = [
+ 'ISA_package',
+ 'ISA_pkg_list',
+ 'ISA_kernel',
+ 'ISA_filesystem',
+ 'ISA_config',
+ 'ISA',
+]
+
+# classes for representing objects for ISA plugins
+
+# source package
+
+
+class ISA_package:
+ # pkg name (mandatory argument)
+ name = ""
+ # full version (mandatory argument)
+ version = ""
+ licenses = [] # list of licences for all subpackages
+ aliases = [] # list of alias names for packages if exist
+ source_files = [] # list of strings of source files
+ patch_files = [] # list of patch files to be applied
+ path_to_sources = "" # path to the source files
+
+# package list
+
+
+class ISA_pkg_list:
+ # image name (mandatory argument)
+ img_name = ""
+ # path to the pkg list file (mandatory argument)
+ path_to_list = ""
+
+# kernel
+
+
+class ISA_kernel:
+ # image name (mandatory argument)
+ img_name = ""
+ # path to the kernel config file (mandatory argument)
+ path_to_config = ""
+
+# filesystem
+
+
+class ISA_filesystem:
+ # image name (mandatory argument)
+ img_name = ""
+ type = "" # filesystem type
+ # path to the fs location (mandatory argument)
+ path_to_fs = ""
+
+# configuration of ISAFW
+# if both whitelist and blacklist is empty, all avaliable plugins will be used
+# if whitelist has entries, then only whitelisted plugins will be used from a set of avaliable plugins
+# if blacklist has entries, then the specified plugins won't be used even
+# if avaliable and even if specified in whitelist
+
+
+class ISA_config:
+ plugin_whitelist = "" # comma separated list of plugins to whitelist
+ plugin_blacklist = "" # comma separated list of plugins to blacklist
+ cacert = None # If set, a CA certificate file that replaces the system default one
+ reportdir = "" # location of produced reports
+ logdir = "" # location of produced logs
+ timestamp = "" # timestamp of the build provided by build system
+ full_reports = False # produce full reports for plugins, False by default
+ machine = "" # name of machine build is produced for
+ la_plugin_image_whitelist = ""# whitelist of images for violating license checks
+ la_plugin_image_blacklist = ""# blacklist of images for violating license checks
+ arch = "" # target architecture
+
+class ISA:
+ def call_plugins(self, methodname, *parameters, **keywords):
+ for name in isaplugins.__all__:
+ plugin = getattr(isaplugins, name)
+ method = getattr(plugin, methodname, None)
+ if not method:
+ # Not having init() is an error, everything else is optional.
+ if methodname == "init":
+ error("No init() defined for plugin %s.\n"
+ "Skipping this plugin." %
+ (methodname, plugin.getPluginName()))
+ continue
+ if self.ISA_config.plugin_whitelist and plugin.getPluginName() not in self.ISA_config.plugin_whitelist:
+ continue
+ if self.ISA_config.plugin_blacklist and plugin.getPluginName() in self.ISA_config.plugin_blacklist:
+ continue
+ try:
+ method(*parameters, **keywords)
+ except:
+ error("Exception in plugin %s %s():\n%s" %
+ (plugin.getPluginName(),
+ methodname,
+ traceback.format_exc()))
+
+ def __init__(self, ISA_config):
+ self.ISA_config = ISA_config
+ self.call_plugins("init", ISA_config)
+
+ def process_package(self, ISA_package):
+ self.call_plugins("process_package", ISA_package)
+
+ def process_pkg_list(self, ISA_pkg_list):
+ self.call_plugins("process_pkg_list", ISA_pkg_list)
+
+ def process_kernel(self, ISA_kernel):
+ self.call_plugins("process_kernel", ISA_kernel)
+
+ def process_filesystem(self, ISA_filesystem):
+ self.call_plugins("process_filesystem", ISA_filesystem)
+
+ def process_report(self):
+ self.call_plugins("process_report")
diff --git a/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_cfa_plugin.py b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_cfa_plugin.py
new file mode 100644
index 00000000..daecba1c
--- /dev/null
+++ b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_cfa_plugin.py
@@ -0,0 +1,392 @@
+#
+# ISA_cfa_plugin.py - Compile flag analyzer plugin, part of ISA FW
+# Main functionality is based on build_comp script from Clear linux project
+#
+# Copyright (c) 2015 - 2016, Intel Corporation
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of Intel Corporation nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import subprocess
+import os
+import sys
+import re
+import copy
+try:
+ from lxml import etree
+except ImportError:
+ try:
+ import xml.etree.cElementTree as etree
+ except ImportError:
+ import xml.etree.ElementTree as etree
+
+
+CFChecker = None
+
+
+class ISA_CFChecker():
+ initialized = False
+ no_relro = []
+ partial_relro = []
+ no_canary = []
+ no_pie = []
+ execstack = []
+ execstack_not_defined = []
+ nodrop_groups = []
+ no_mpx = []
+
+ def __init__(self, ISA_config):
+ self.logfile = ISA_config.logdir + "/isafw_cfalog"
+ self.full_report_name = ISA_config.reportdir + "/cfa_full_report_" + \
+ ISA_config.machine + "_" + ISA_config.timestamp
+ self.problems_report_name = ISA_config.reportdir + \
+ "/cfa_problems_report_" + ISA_config.machine + "_" + ISA_config.timestamp
+ self.full_reports = ISA_config.full_reports
+ self.ISA_filesystem = ""
+ # check that checksec and other tools are installed
+ tools_errors = _check_tools()
+ if tools_errors:
+ with open(self.logfile, 'w') as flog:
+ flog.write(tools_errors)
+ return
+ self.initialized = True
+ with open(self.logfile, 'w') as flog:
+ flog.write("\nPlugin ISA_CFChecker initialized!\n")
+ return
+
+ def process_filesystem(self, ISA_filesystem):
+ self.ISA_filesystem = ISA_filesystem
+ fs_path = self.ISA_filesystem.path_to_fs
+ img_name = self.ISA_filesystem.img_name
+ if (self.initialized):
+ if (img_name and fs_path):
+ with open(self.logfile, 'a') as flog:
+ flog.write("\n\nFilesystem path is: " + fs_path)
+ if self.full_reports:
+ with open(self.full_report_name + "_" + img_name, 'w') as ffull_report:
+ ffull_report.write(
+ "Security-relevant flags for executables for image: " + img_name + '\n')
+ ffull_report.write("With rootfs location at " + fs_path + "\n\n")
+ files = self.find_files(fs_path)
+ import multiprocessing
+ pool = multiprocessing.Pool()
+ results = pool.imap(process_file_wrapper, files)
+ pool.close()
+ pool.join()
+ self.process_results(results)
+ else:
+ with open(self.logfile, 'a') as flog:
+ flog.write(
+ "Mandatory arguments such as image name and path to the filesystem are not provided!\n")
+ flog.write("Not performing the call.\n")
+ else:
+ with open(self.logfile, 'a') as flog:
+ flog.write("Plugin hasn't initialized! Not performing the call.\n")
+
+ def process_results(self, results):
+ fs_path = self.ISA_filesystem.path_to_fs
+ for result in results:
+ if not result:
+ with open(self.logfile, 'a') as flog:
+ flog.write("\nError in returned result")
+ continue
+ with open(self.logfile, 'a') as flog:
+ flog.write("\n\nFor file: " + str(result[0]) + "\nlog is: " + str(result[5]))
+ if result[1]:
+ with open(self.logfile, 'a') as flog:
+ flog.write("\n\nsec_field: " + str(result[1]))
+ if "No RELRO" in result[1]:
+ self.no_relro.append(result[0].replace(fs_path, ""))
+ elif "Partial RELRO" in result[1]:
+ self.partial_relro.append(result[0].replace(fs_path, ""))
+ if "No canary found" in result[1]:
+ self.no_canary.append(result[0].replace(fs_path, ""))
+ if "No PIE" in result[1]:
+ self.no_pie.append(result[0].replace(fs_path, ""))
+ if result[2]:
+ if result[2] == "execstack":
+ self.execstack.append(result[0].replace(fs_path, ""))
+ elif result[2] == "not_defined":
+ self.execstack_not_defined.append(result[0].replace(fs_path, ""))
+ if result[3] and (result[3] == True):
+ self.nodrop_groups.append(result[0].replace(fs_path, ""))
+ if result[4] and (result[4] == True):
+ self.no_mpx.append(result[0].replace(fs_path, ""))
+ self.write_full_report(result)
+ self.write_report()
+ self.write_report_xml()
+
+ def write_full_report(self, result):
+ if not self.full_reports:
+ return
+ fs_path = self.ISA_filesystem.path_to_fs
+ img_name = self.ISA_filesystem.img_name
+ with open(self.full_report_name + "_" + img_name, 'a') as ffull_report:
+ ffull_report.write('\nFile: ' + result[0].replace(fs_path, ""))
+ ffull_report.write('\nsecurity flags: ' + str(result[1]))
+ ffull_report.write('\nexecstack: ' + str(result[2]))
+ ffull_report.write('\nnodrop_groups: ' + str(result[3]))
+ ffull_report.write('\nno mpx: ' + str(result[4]))
+ ffull_report.write('\n')
+
+ def write_report(self):
+ fs_path = self.ISA_filesystem.path_to_fs
+ img_name = self.ISA_filesystem.img_name
+ with open(self.problems_report_name + "_" + img_name, 'w') as fproblems_report:
+ fproblems_report.write("Report for image: " + img_name + '\n')
+ fproblems_report.write("With rootfs location at " + fs_path + "\n\n")
+ fproblems_report.write("Relocation Read-Only\n")
+ fproblems_report.write("More information about RELRO and how to enable it:")
+ fproblems_report.write(
+ " http://tk-blog.blogspot.de/2009/02/relro-not-so-well-known-memory.html\n")
+ fproblems_report.write("Files with no RELRO:\n")
+ for item in self.no_relro:
+ fproblems_report.write(item + '\n')
+ fproblems_report.write("Files with partial RELRO:\n")
+ for item in self.partial_relro:
+ fproblems_report.write(item + '\n')
+ fproblems_report.write("\n\nStack protection\n")
+ fproblems_report.write(
+ "More information about canary stack protection and how to enable it:")
+ fproblems_report.write("https://lwn.net/Articles/584225/ \n")
+ fproblems_report.write("Files with no canary:\n")
+ for item in self.no_canary:
+ fproblems_report.write(item + '\n')
+ fproblems_report.write("\n\nPosition Independent Executable\n")
+ fproblems_report.write("More information about PIE protection and how to enable it:")
+ fproblems_report.write(
+ "https://securityblog.redhat.com/2012/11/28/position-independent-executables-pie/\n")
+ fproblems_report.write("Files with no PIE:\n")
+ for item in self.no_pie:
+ fproblems_report.write(item + '\n')
+ fproblems_report.write("\n\nNon-executable stack\n")
+ fproblems_report.write("Files with executable stack enabled:\n")
+ for item in self.execstack:
+ fproblems_report.write(item + '\n')
+ fproblems_report.write("\n\nFiles with no ability to fetch executable stack status:\n")
+ for item in self.execstack_not_defined:
+ fproblems_report.write(item + '\n')
+ fproblems_report.write("\n\nGrop initialization:\n")
+ fproblems_report.write(
+ "If using setuid/setgid calls in code, one must call initgroups or setgroups\n")
+ fproblems_report.write(
+ "Files that don't initialize groups while using setuid/setgid:\n")
+ for item in self.nodrop_groups:
+ fproblems_report.write(item + '\n')
+ fproblems_report.write("\n\nMemory Protection Extensions\n")
+ fproblems_report.write("More information about MPX protection and how to enable it:")
+ fproblems_report.write(
+ "https://software.intel.com/sites/default/files/managed/9d/f6/Intel_MPX_EnablingGuide.pdf\n")
+ fproblems_report.write("Files that don't have MPX protection enabled:\n")
+ for item in self.no_mpx:
+ fproblems_report.write(item + '\n')
+
+ def write_report_xml(self):
+ numTests = len(self.no_relro) + len(self.partial_relro) + len(self.no_canary) + len(self.no_pie) + \
+ len(self.execstack) + len(self.execstack_not_defined) + \
+ len(self.nodrop_groups) + len(self.no_mpx)
+ root = etree.Element('testsuite', name='ISA_CFChecker', tests=str(numTests))
+ if self.no_relro:
+ for item in self.no_relro:
+ tcase1 = etree.SubElement(
+ root, 'testcase', classname='files_with_no_RELRO', name=item)
+ etree.SubElement(tcase1, 'failure', message=item, type='violation')
+ if self.partial_relro:
+ for item in self.partial_relro:
+ tcase1 = etree.SubElement(
+ root, 'testcase', classname='files_with_partial_RELRO', name=item)
+ etree.SubElement(tcase1, 'failure', message=item, type='violation')
+ if self.no_canary:
+ for item in self.no_canary:
+ tcase2 = etree.SubElement(
+ root, 'testcase', classname='files_with_no_canary', name=item)
+ etree.SubElement(tcase2, 'failure', message=item, type='violation')
+ if self.no_pie:
+ for item in self.no_pie:
+ tcase3 = etree.SubElement(
+ root, 'testcase', classname='files_with_no_PIE', name=item)
+ etree.SubElement(tcase3, 'failure', message=item, type='violation')
+ if self.execstack:
+ for item in self.execstack:
+ tcase5 = etree.SubElement(
+ root, 'testcase', classname='files_with_execstack', name=item)
+ etree.SubElement(tcase5, 'failure', message=item, type='violation')
+ if self.execstack_not_defined:
+ for item in self.execstack_not_defined:
+ tcase6 = etree.SubElement(
+ root, 'testcase', classname='files_with_execstack_not_defined', name=item)
+ etree.SubElement(tcase6, 'failure', message=item, type='violation')
+ if self.nodrop_groups:
+ for item in self.nodrop_groups:
+ tcase7 = etree.SubElement(
+ root, 'testcase', classname='files_with_nodrop_groups', name=item)
+ etree.SubElement(tcase7, 'failure', message=item, type='violation')
+ if self.no_mpx:
+ for item in self.no_mpx:
+ tcase8 = etree.SubElement(
+ root, 'testcase', classname='files_with_no_mpx', name=item)
+ etree.SubElement(tcase8, 'failure', message=item, type='violation')
+ tree = etree.ElementTree(root)
+ output = self.problems_report_name + "_" + self.ISA_filesystem.img_name + '.xml'
+ try:
+ tree.write(output, encoding='UTF-8', pretty_print=True, xml_declaration=True)
+ except TypeError:
+ tree.write(output, encoding='UTF-8', xml_declaration=True)
+
+ def find_files(self, init_path):
+ list_of_files = []
+ for (dirpath, dirnames, filenames) in os.walk(init_path):
+ for f in filenames:
+ list_of_files.append(str(dirpath + "/" + f)[:])
+ return list_of_files
+
+
+def _check_tools():
+
+ def _is_in_path(executable):
+ "Check for presence of executable in PATH"
+ for path in os.environ["PATH"].split(os.pathsep):
+ path = path.strip('"')
+ if (os.path.isfile(os.path.join(path, executable)) and
+ os.access(os.path.join(path, executable), os.X_OK)):
+ return True
+ return False
+
+ tools = {
+ "checksec.sh": "Please install checksec from http://www.trapkit.de/tools/checksec.html\n",
+ "execstack": "Please install execstack from prelink package\n",
+ "readelf": "Please install binutils\n",
+ "objdump": "Please install binutils\n",
+ }
+ output = ""
+ for tool in tools:
+ if not _is_in_path(tool):
+ output += tools[tool]
+ return output
+
+
+def get_info(tool, args, file_name):
+ env = copy.deepcopy(os.environ)
+ env['PSEUDO_UNLOAD'] = "1"
+ cmd = [tool, args, file_name]
+ with open(os.devnull, 'wb') as DEVNULL:
+ try:
+ result = subprocess.check_output(cmd, stderr=DEVNULL, env=env).decode('utf-8')
+ except:
+ return ""
+ else:
+ return result
+
+def get_security_flags(file_name):
+ env = copy.deepcopy(os.environ)
+ env['PSEUDO_UNLOAD'] = "1"
+ cmd = ['checksec.sh', '--file', file_name]
+ try:
+ result = subprocess.check_output(cmd, env=env).decode('utf-8').splitlines()[1]
+ except:
+ return "Not able to fetch flags"
+ else:
+ # remove ansi escape color sequences
+ result = re.sub(r'\x1b[^m]*m', '', result)
+ return re.split(r' {2,}', result)[:-1]
+
+
+def process_file(file):
+ log = "File from map " + file
+ fun_results = [file, [], "", False, False, log]
+ if not os.path.isfile(file):
+ return fun_results
+ env = copy.deepcopy(os.environ)
+ env['PSEUDO_UNLOAD'] = "1"
+ # getting file type
+ cmd = ['file', '--mime-type', file]
+ try:
+ result = subprocess.check_output(cmd, env=env).decode('utf-8')
+ except:
+ fun_results[-1] += "\nNot able to decode mime type"
+ return fun_results
+ file_type = result.split()[-1]
+ # looking for links
+ if "symlink" in file_type:
+ file = os.path.realpath(file)
+ cmd = ['file', '--mime-type', file]
+ try:
+ result = subprocess.check_output(cmd, env=env).decode('utf-8')
+ except:
+ fun_results[-1] += "\nNot able to decode mime type"
+ return fun_results
+ file_type = result.split()[-1]
+ # checking security flags if applies
+ if "application" not in file_type:
+ return fun_results
+ fun_results[-1] += "\nFile type: " + file_type
+ if (("octet-stream" in file_type) or ("dosexec" in file_type) or
+ ("archive" in file_type) or ("xml" in file_type) or
+ ("gzip" in file_type) or ("postscript" in file_type) or
+ ("pdf" in file_type)):
+ return fun_results
+ fun_results[1] = get_security_flags(file)
+ tmp = get_info("execstack", '-q', file)
+ if tmp.startswith("X "):
+ fun_results[2] = "execstack"
+ elif tmp.startswith("? "):
+ fun_results[2] = "not_defined"
+ tmp = get_info("readelf", '-s', file)
+ if ("setgid@GLIBC" in tmp) or ("setegid@GLIBC" in tmp) or ("setresgid@GLIBC" in tmp):
+ if ("setuid@GLIBC" in tmp) or ("seteuid@GLIBC" in tmp) or ("setresuid@GLIBC" in tmp):
+ if ("setgroups@GLIBC" not in tmp) and ("initgroups@GLIBC" not in tmp):
+ fun_results[3] = True
+ tmp = get_info("objdump", '-d', file)
+ if ("bndcu" not in tmp) and ("bndcl" not in tmp) and ("bndmov" not in tmp):
+ fun_results[4] = True
+ return fun_results
+
+def process_file_wrapper(file):
+ # Ensures that exceptions get logged with the original backtrace.
+ # Without this, they appear with a backtrace rooted in
+ # the code which transfers back the result to process_results().
+ try:
+ return process_file(file)
+ except:
+ from isafw import isafw
+ import traceback
+ isafw.error('Internal error:\n%s' % traceback.format_exc())
+ raise
+
+# ======== supported callbacks from ISA ============ #
+
+
+def init(ISA_config):
+ global CFChecker
+ CFChecker = ISA_CFChecker(ISA_config)
+
+
+def getPluginName():
+ return "ISA_CFChecker"
+
+
+def process_filesystem(ISA_filesystem):
+ global CFChecker
+ return CFChecker.process_filesystem(ISA_filesystem)
+
+# =================================================== #
diff --git a/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_cve_plugin.py b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_cve_plugin.py
new file mode 100644
index 00000000..268aa45c
--- /dev/null
+++ b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_cve_plugin.py
@@ -0,0 +1,217 @@
+#
+# ISA_cve_plugin.py - CVE checker plugin, part of ISA FW
+#
+# Copyright (c) 2015 - 2016, Intel Corporation
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of Intel Corporation nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import subprocess
+import os, sys
+import re
+
+CVEChecker = None
+pkglist = "/cve_check_tool_pkglist"
+
+
+class ISA_CVEChecker:
+ initialized = False
+
+ def __init__(self, ISA_config):
+ self.cacert = ISA_config.cacert
+ self.reportdir = ISA_config.reportdir
+ self.timestamp = ISA_config.timestamp
+ self.logfile = ISA_config.logdir + "/isafw_cvelog"
+ self.report_name = ISA_config.reportdir + "/cve_report_" + \
+ ISA_config.machine + "_" + ISA_config.timestamp
+ self.initialized = True
+ with open(self.logfile, 'a') as flog:
+ flog.write("\nPlugin ISA_CVEChecker initialized!\n")
+ output = ""
+ # check that cve-check-tool is installed
+
+ def process_package(self, ISA_pkg):
+ if (self.initialized):
+ if (ISA_pkg.name and ISA_pkg.version and ISA_pkg.patch_files):
+ alias_pkgs_faux = []
+ # need to compose faux format line for cve-check-tool
+ cve_patch_info = self.process_patch_list(ISA_pkg.patch_files)
+ pkgline_faux = ISA_pkg.name + "," + ISA_pkg.version + "," + cve_patch_info + ",\n"
+ if ISA_pkg.aliases:
+ for a in ISA_pkg.aliases:
+ alias_pkgs_faux.append(
+ a + "," + ISA_pkg.version + "," + cve_patch_info + ",\n")
+ pkglist_faux = pkglist + "_" + self.timestamp + ".faux"
+ with open(self.reportdir + pkglist_faux, 'a') as fauxfile:
+ fauxfile.write(pkgline_faux)
+ for a in alias_pkgs_faux:
+ fauxfile.write(a)
+
+ with open(self.logfile, 'a') as flog:
+ flog.write("\npkg info: " + pkgline_faux)
+ else:
+ self.initialized = False
+ with open(self.logfile, 'a') as flog:
+ flog.write(
+ "Mandatory arguments such as pkg name, version and list of patches are not provided!\n")
+ flog.write("Not performing the call.\n")
+ else:
+ with open(self.logfile, 'a') as flog:
+ flog.write(
+ "Plugin hasn't initialized! Not performing the call.\n")
+
+ def process_report(self):
+ if not os.path.isfile(self.reportdir + pkglist + "_" + self.timestamp + ".faux"):
+ return
+ if (self.initialized):
+ with open(self.logfile, 'a') as flog:
+ flog.write("Creating report in HTML format.\n")
+ result = self.process_report_type("html")
+
+ with open(self.logfile, 'a') as flog:
+ flog.write("Creating report in CSV format.\n")
+ result = self.process_report_type("csv")
+
+ pkglist_faux = pkglist + "_" + self.timestamp + ".faux"
+ os.remove(self.reportdir + pkglist_faux)
+
+ with open(self.logfile, 'a') as flog:
+ flog.write("Creating report in XML format.\n")
+ self.write_report_xml(result)
+
+ def write_report_xml(self, result):
+ try:
+ from lxml import etree
+ except ImportError:
+ try:
+ import xml.etree.cElementTree as etree
+ except ImportError:
+ import xml.etree.ElementTree as etree
+ num_tests = 0
+ root = etree.Element('testsuite', name='CVE_Plugin', tests='1')
+
+ if result :
+ num_tests = 1
+ tcase = etree.SubElement(
+ root, 'testcase', classname='ISA_CVEChecker', name="Error in cve-check-tool")
+ etree.SubElement( tcase, 'failure', message=result, type='violation')
+ else:
+ with open(self.report_name + ".csv", 'r') as f:
+ for line in f:
+ num_tests += 1
+ line = line.strip()
+ line_sp = line.split(',', 2)
+ if (len(line_sp) >= 3) and (line_sp[2].startswith('CVE')):
+ tcase = etree.SubElement(
+ root, 'testcase', classname='ISA_CVEChecker', name=line.split(',', 1)[0])
+ etree.SubElement(
+ tcase, 'failure', message=line, type='violation')
+ else:
+ tcase = etree.SubElement(
+ root, 'testcase', classname='ISA_CVEChecker', name=line.split(',', 1)[0])
+
+ root.set('tests', str(num_tests))
+ tree = etree.ElementTree(root)
+ output = self.report_name + '.xml'
+ try:
+ tree.write(output, encoding='UTF-8',
+ pretty_print=True, xml_declaration=True)
+ except TypeError:
+ tree.write(output, encoding='UTF-8', xml_declaration=True)
+
+ def process_report_type(self, rtype):
+ # now faux file is ready and we can process it
+ args = ""
+ result = ""
+ tool_stderr_value = ""
+ args += "cve-check-tool "
+ if self.cacert:
+ args += "--cacert '%s' " % self.cacert
+ if rtype != "html":
+ args += "-c "
+ rtype = "csv"
+ pkglist_faux = pkglist + "_" + self.timestamp + ".faux"
+ args += "-a -t faux '" + self.reportdir + pkglist_faux + "'"
+ with open(self.logfile, 'a') as flog:
+ flog.write("Args: " + args)
+ try:
+ popen = subprocess.Popen(
+ args, shell=True, env=os.environ, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ result = popen.communicate()
+ except:
+ tool_stderr_value = "Error in executing cve-check-tool" + str(sys.exc_info())
+ with open(self.logfile, 'a') as flog:
+ flog.write("Error in executing cve-check-tool: " +
+ str(sys.exc_info()))
+ else:
+ stdout_value = result[0]
+ tool_stderr_value = result[1].decode('utf-8')
+ if not tool_stderr_value and popen.returncode == 0:
+ report = self.report_name + "." + rtype
+ with open(report, 'wb') as freport:
+ freport.write(stdout_value)
+ else:
+ tool_stderr_value = tool_stderr_value + \
+ "\ncve-check-tool terminated with exit code " + str(popen.returncode)
+ return tool_stderr_value
+
+ def process_patch_list(self, patch_files):
+ patch_info = ""
+ for patch in patch_files:
+ patch1 = patch.partition("cve")
+ if (patch1[0] == patch):
+ # no cve substring, try CVE
+ patch1 = patch.partition("CVE")
+ if (patch1[0] == patch):
+ continue
+ patchstripped = patch1[2].split('-')
+ try:
+ patch_info += " CVE-" + \
+ patchstripped[1] + "-" + re.findall('\d+', patchstripped[2])[0]
+ except IndexError:
+ # string parsing attempt failed, so just skip this patch
+ continue
+ return patch_info
+
+# ======== supported callbacks from ISA ============= #
+
+
+def init(ISA_config):
+ global CVEChecker
+ CVEChecker = ISA_CVEChecker(ISA_config)
+
+
+def getPluginName():
+ return "ISA_CVEChecker"
+
+
+def process_package(ISA_pkg):
+ global CVEChecker
+ return CVEChecker.process_package(ISA_pkg)
+
+
+def process_report():
+ global CVEChecker
+ return CVEChecker.process_report()
+
+# ==================================================== #
diff --git a/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_fsa_plugin.py b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_fsa_plugin.py
new file mode 100644
index 00000000..09097566
--- /dev/null
+++ b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_fsa_plugin.py
@@ -0,0 +1,185 @@
+#
+# ISA_fsa_plugin.py - Filesystem analyser plugin, part of ISA FW
+#
+# Copyright (c) 2015 - 2016, Intel Corporation
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of Intel Corporation nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import os
+from stat import *
+try:
+ from lxml import etree
+except ImportError:
+ try:
+ import xml.etree.cElementTree as etree
+ except ImportError:
+ import xml.etree.ElementTree as etree
+
+
+FSAnalyzer = None
+
+
+class ISA_FSChecker():
+ initialized = False
+
+ def __init__(self, ISA_config):
+ self.logfile = ISA_config.logdir + "/isafw_fsalog"
+ self.full_report_name = ISA_config.reportdir + "/fsa_full_report_" + \
+ ISA_config.machine + "_" + ISA_config.timestamp
+ self.problems_report_name = ISA_config.reportdir + \
+ "/fsa_problems_report_" + ISA_config.machine + "_" + ISA_config.timestamp
+ self.full_reports = ISA_config.full_reports
+ self.initialized = True
+ self.setuid_files = []
+ self.setgid_files = []
+ self.ww_files = []
+ self.no_sticky_bit_ww_dirs = []
+ with open(self.logfile, 'w') as flog:
+ flog.write("\nPlugin ISA_FSChecker initialized!\n")
+
+ def process_filesystem(self, ISA_filesystem):
+ if (self.initialized):
+ if (ISA_filesystem.img_name and ISA_filesystem.path_to_fs):
+ with open(self.logfile, 'a') as flog:
+ flog.write("Analyzing filesystem at: " + ISA_filesystem.path_to_fs +
+ " for the image: " + ISA_filesystem.img_name + "\n")
+ self.files = self.find_fsobjects(ISA_filesystem.path_to_fs)
+ with open(self.logfile, 'a') as flog:
+ flog.write("\nFilelist is: " + str(self.files))
+ if self.full_reports:
+ with open(self.full_report_name + "_" + ISA_filesystem.img_name, 'w') as ffull_report:
+ ffull_report.write(
+ "Report for image: " + ISA_filesystem.img_name + '\n')
+ ffull_report.write(
+ "With rootfs location at " + ISA_filesystem.path_to_fs + "\n\n")
+ for f in self.files:
+ st = os.lstat(f)
+ i = f.replace(ISA_filesystem.path_to_fs, "")
+ if self.full_reports:
+ with open(self.full_report_name + "_" + ISA_filesystem.img_name, 'a') as ffull_report:
+ ffull_report.write("File: " + i + ' mode: ' + str(oct(st.st_mode)) +
+ " uid: " + str(st.st_uid) + " gid: " + str(st.st_gid) + '\n')
+ if ((st.st_mode & S_ISUID) == S_ISUID):
+ self.setuid_files.append(i)
+ if ((st.st_mode & S_ISGID) == S_ISGID):
+ self.setgid_files.append(i)
+ if ((st.st_mode & S_IWOTH) == S_IWOTH):
+ if (((st.st_mode & S_IFDIR) == S_IFDIR) and ((st.st_mode & S_ISVTX) != S_ISVTX)):
+ self.no_sticky_bit_ww_dirs.append(i)
+ if (((st.st_mode & S_IFREG) == S_IFREG) and ((st.st_mode & S_IFLNK) != S_IFLNK)):
+ self.ww_files.append(i)
+ self.write_problems_report(ISA_filesystem)
+ self.write_problems_report_xml(ISA_filesystem)
+ else:
+ with open(self.logfile, 'a') as flog:
+ flog.write(
+ "Mandatory arguments such as image name and path to the filesystem are not provided!\n")
+ flog.write("Not performing the call.\n")
+ else:
+ with open(self.logfile, 'a') as flog:
+ flog.write(
+ "Plugin hasn't initialized! Not performing the call.\n")
+
+ def write_problems_report(self, ISA_filesystem):
+ with open(self.problems_report_name + "_" + ISA_filesystem.img_name, 'w') as fproblems_report:
+ fproblems_report.write(
+ "Report for image: " + ISA_filesystem.img_name + '\n')
+ fproblems_report.write(
+ "With rootfs location at " + ISA_filesystem.path_to_fs + "\n\n")
+ fproblems_report.write("Files with SETUID bit set:\n")
+ for item in self.setuid_files:
+ fproblems_report.write(item + '\n')
+ fproblems_report.write("\n\nFiles with SETGID bit set:\n")
+ for item in self.setgid_files:
+ fproblems_report.write(item + '\n')
+ fproblems_report.write("\n\nWorld-writable files:\n")
+ for item in self.ww_files:
+ fproblems_report.write(item + '\n')
+ fproblems_report.write(
+ "\n\nWorld-writable dirs with no sticky bit:\n")
+ for item in self.no_sticky_bit_ww_dirs:
+ fproblems_report.write(item + '\n')
+
+ def write_problems_report_xml(self, ISA_filesystem):
+ num_tests = len(self.setuid_files) + len(self.setgid_files) + \
+ len(self.ww_files) + len(self.no_sticky_bit_ww_dirs)
+ root = etree.Element(
+ 'testsuite', name='FSA_Plugin', tests=str(num_tests))
+ if self.setuid_files:
+ for item in self.setuid_files:
+ tcase1 = etree.SubElement(
+ root, 'testcase', classname='Files_with_SETUID_bit_set', name=item)
+ etree.SubElement(
+ tcase1, 'failure', message=item, type='violation')
+ if self.setgid_files:
+ for item in self.setgid_files:
+ tcase2 = etree.SubElement(
+ root, 'testacase', classname='Files_with_SETGID_bit_set', name=item)
+ etree.SubElement(
+ tcase2, 'failure', message=item, type='violation')
+ if self.ww_files:
+ for item in self.ww_files:
+ tcase3 = etree.SubElement(
+ root, 'testase', classname='World-writable_files', name=item)
+ etree.SubElement(
+ tcase3, 'failure', message=item, type='violation')
+ if self.no_sticky_bit_ww_dirs:
+ for item in self.no_sticky_bit_ww_dirs:
+ tcase4 = etree.SubElement(
+ root, 'testcase', classname='World-writable_dirs_with_no_sticky_bit', name=item)
+ etree.SubElement(
+ tcase4, 'failure', message=item, type='violation')
+ tree = etree.ElementTree(root)
+ output = self.problems_report_name + "_" + ISA_filesystem.img_name + '.xml'
+ try:
+ tree.write(output, encoding='UTF-8',
+ pretty_print=True, xml_declaration=True)
+ except TypeError:
+ tree.write(output, encoding='UTF-8', xml_declaration=True)
+
+ def find_fsobjects(self, init_path):
+ list_of_files = []
+ for (dirpath, dirnames, filenames) in os.walk(init_path):
+ if (dirpath != init_path):
+ list_of_files.append(str(dirpath)[:])
+ for f in filenames:
+ list_of_files.append(str(dirpath + "/" + f)[:])
+ return list_of_files
+
+# ======== supported callbacks from ISA ============= #
+
+
+def init(ISA_config):
+ global FSAnalyzer
+ FSAnalyzer = ISA_FSChecker(ISA_config)
+
+
+def getPluginName():
+ return "ISA_FSChecker"
+
+
+def process_filesystem(ISA_filesystem):
+ global FSAnalyzer
+ return FSAnalyzer.process_filesystem(ISA_filesystem)
+
+# ==================================================== #
diff --git a/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_kca_plugin.py b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_kca_plugin.py
new file mode 100644
index 00000000..ba09819d
--- /dev/null
+++ b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_kca_plugin.py
@@ -0,0 +1,323 @@
+#
+# ISA_kca_plugin.py - Kernel config options analyzer plugin, part of ISA FW
+#
+# Copyright (c) 2015 - 2016, Intel Corporation
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of Intel Corporation nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+try:
+ from lxml import etree
+except ImportError:
+ try:
+ import xml.etree.cElementTree as etree
+ except ImportError:
+ import xml.etree.ElementTree as etree
+import importlib
+
+KCAnalyzer = None
+
+
+class ISA_KernelChecker():
+ initialized = False
+
+ def __init__(self, ISA_config):
+ self.logfile = ISA_config.logdir + "/isafw_kcalog"
+ self.full_report_name = ISA_config.reportdir + "/kca_full_report_" + \
+ ISA_config.machine + "_" + ISA_config.timestamp
+ self.problems_report_name = ISA_config.reportdir + \
+ "/kca_problems_report_" + ISA_config.machine + "_" + ISA_config.timestamp
+ self.full_reports = ISA_config.full_reports
+ self.initialized = True
+ self.arch = ISA_config.arch
+ with open(self.logfile, 'w') as flog:
+ flog.write("\nPlugin ISA_KernelChecker initialized!\n")
+
+ def append_recommendation(self, report, key, value):
+ report.write("Recommended value:\n")
+ report.write(key + ' : ' + str(value) + '\n')
+ comment = self.comments.get(key, '')
+ if comment != '':
+ report.write("Comment:\n")
+ report.write(comment + '\n')
+
+ def process_kernel(self, ISA_kernel):
+ if (self.initialized):
+ if (ISA_kernel.img_name and ISA_kernel.path_to_config):
+ # Merging common and arch configs
+ common_config_module = importlib.import_module('isafw.isaplugins.configs.kca.{}'.format('common'))
+ arch_config_module = importlib.import_module('isafw.isaplugins.configs.kca.{}'.format(self.arch))
+
+ for c in ["hardening_kco", "keys_kco", "security_kco", "integrity_kco",
+ "hardening_kco_ref", "keys_kco_ref", "security_kco_ref", "integrity_kco_ref",
+ "comments"]:
+ setattr(self, c, merge_config(getattr(arch_config_module, c), getattr(common_config_module, c)))
+ with open(self.logfile, 'a') as flog:
+ flog.write("Analyzing kernel config file at: " + ISA_kernel.path_to_config +
+ " for the image: " + ISA_kernel.img_name + "\n")
+ with open(ISA_kernel.path_to_config, 'r') as fkernel_conf:
+ for line in fkernel_conf:
+ line = line.strip('\n')
+ for key in self.hardening_kco:
+ if key + '=' in line:
+ self.hardening_kco[key] = line.split('=')[1]
+ for key in self.keys_kco:
+ if key + '=' in line:
+ self.keys_kco[key] = line.split('=')[1]
+ for key in self.security_kco:
+ if key + '=' in line:
+ self.security_kco[key] = line.split('=')[1]
+ for key in self.integrity_kco:
+ if key + '=' in line:
+ self.integrity_kco[key] = line.split('=')[1]
+ with open(self.logfile, 'a') as flog:
+ flog.write("\n\nhardening_kco values: " +
+ str(self.hardening_kco))
+ flog.write("\n\nkeys_kco values: " + str(self.keys_kco))
+ flog.write("\n\nsecurity_kco values: " +
+ str(self.security_kco))
+ flog.write("\n\nintegrity_kco values: " +
+ str(self.integrity_kco))
+ self.write_full_report(ISA_kernel)
+ self.write_problems_report(ISA_kernel)
+
+ else:
+ with open(self.logfile, 'a') as flog:
+ flog.write(
+ "Mandatory arguments such as image name and path to config are not provided!\n")
+ flog.write("Not performing the call.\n")
+ else:
+ with open(self.logfile, 'a') as flog:
+ flog.write(
+ "Plugin hasn't initialized! Not performing the call!\n")
+
+ def write_full_report(self, ISA_kernel):
+ if self.full_reports:
+ with open(self.full_report_name + "_" + ISA_kernel.img_name, 'w') as freport:
+ freport.write("Report for image: " +
+ ISA_kernel.img_name + '\n')
+ freport.write("With the kernel conf at: " +
+ ISA_kernel.path_to_config + '\n\n')
+ freport.write("Hardening options:\n")
+ for key in sorted(self.hardening_kco):
+ freport.write(
+ key + ' : ' + str(self.hardening_kco[key]) + '\n')
+ freport.write("\nKey-related options:\n")
+ for key in sorted(self.keys_kco):
+ freport.write(key + ' : ' + str(self.keys_kco[key]) + '\n')
+ freport.write("\nSecurity options:\n")
+ for key in sorted(self.security_kco):
+ freport.write(
+ key + ' : ' + str(self.security_kco[key]) + '\n')
+ freport.write("\nIntegrity options:\n")
+ for key in sorted(self.integrity_kco):
+ freport.write(
+ key + ' : ' + str(self.integrity_kco[key]) + '\n')
+
+ def write_problems_report(self, ISA_kernel):
+ self.write_text_problems_report(ISA_kernel)
+ self.write_xml_problems_report(ISA_kernel)
+
+ def write_text_problems_report(self, ISA_kernel):
+ with open(self.problems_report_name + "_" + ISA_kernel.img_name, 'w') as freport:
+ freport.write("Report for image: " + ISA_kernel.img_name + '\n')
+ freport.write("With the kernel conf at: " +
+ ISA_kernel.path_to_config + '\n\n')
+ freport.write("Hardening options that need improvement:\n")
+ for key in sorted(self.hardening_kco):
+ if (self.hardening_kco[key] != self.hardening_kco_ref[key]):
+ valid = False
+ if (key == "CONFIG_CMDLINE"):
+ if (len(self.hardening_kco['CONFIG_CMDLINE']) > 0):
+ valid = True
+ if (key == "CONFIG_DEBUG_STRICT_USER_COPY_CHECKS"):
+ if (self.hardening_kco['CONFIG_ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS'] == 'y'):
+ valid = True
+ if (key == "CONFIG_RANDOMIZE_BASE_MAX_OFFSET"):
+ options = self.hardening_kco_ref[key].split(',')
+ for option in options:
+ if (option == self.hardening_kco[key]):
+ valid = True
+ break
+ if not valid:
+ freport.write("\nActual value:\n")
+ freport.write(
+ key + ' : ' + str(self.hardening_kco[key]) + '\n')
+ self.append_recommendation(freport, key, self.hardening_kco_ref[key])
+ freport.write("\nKey-related options that need improvement:\n")
+ for key in sorted(self.keys_kco):
+ if (self.keys_kco[key] != self.keys_kco_ref[key]):
+ freport.write("\nActual value:\n")
+ freport.write(key + ' : ' + str(self.keys_kco[key]) + '\n')
+ self.append_recommendation(freport, key, self.keys_kco_ref[key])
+ freport.write("\nSecurity options that need improvement:\n")
+ for key in sorted(self.security_kco):
+ if (self.security_kco[key] != self.security_kco_ref[key]):
+ valid = False
+ if (key == "CONFIG_DEFAULT_SECURITY"):
+ options = self.security_kco_ref[key].split(',')
+ for option in options:
+ if (option == self.security_kco[key]):
+ valid = True
+ break
+ if ((key == "CONFIG_SECURITY_SELINUX") or
+ (key == "CONFIG_SECURITY_SMACK") or
+ (key == "CONFIG_SECURITY_APPARMOR") or
+ (key == "CONFIG_SECURITY_TOMOYO")):
+ if ((self.security_kco['CONFIG_SECURITY_SELINUX'] == 'y') or
+ (self.security_kco['CONFIG_SECURITY_SMACK'] == 'y') or
+ (self.security_kco['CONFIG_SECURITY_APPARMOR'] == 'y') or
+ (self.security_kco['CONFIG_SECURITY_TOMOYO'] == 'y')):
+ valid = True
+ if not valid:
+ freport.write("\nActual value:\n")
+ freport.write(
+ key + ' : ' + str(self.security_kco[key]) + '\n')
+ self.append_recommendation(freport, key, self.security_kco_ref[key])
+ freport.write("\nIntegrity options that need improvement:\n")
+ for key in sorted(self.integrity_kco):
+ if (self.integrity_kco[key] != self.integrity_kco_ref[key]):
+ valid = False
+ if ((key == "CONFIG_IMA_DEFAULT_HASH_SHA1") or
+ (key == "CONFIG_IMA_DEFAULT_HASH_SHA256") or
+ (key == "CONFIG_IMA_DEFAULT_HASH_SHA512") or
+ (key == "CONFIG_IMA_DEFAULT_HASH_WP512")):
+ if ((self.integrity_kco['CONFIG_IMA_DEFAULT_HASH_SHA256'] == 'y') or
+ (self.integrity_kco['CONFIG_IMA_DEFAULT_HASH_SHA512'] == 'y')):
+ valid = True
+ if not valid:
+ freport.write("\nActual value:\n")
+ freport.write(
+ key + ' : ' + str(self.integrity_kco[key]) + '\n')
+ self.append_recommendation(freport, key, self.integrity_kco_ref[key])
+
+ def write_xml_problems_report(self, ISA_kernel):
+ # write_problems_report_xml
+ num_tests = len(self.hardening_kco) + len(self.keys_kco) + \
+ len(self.security_kco) + len(self.integrity_kco)
+ root = etree.Element(
+ 'testsuite', name='KCA_Plugin', tests=str(num_tests))
+ for key in sorted(self.hardening_kco):
+ tcase1 = etree.SubElement(
+ root, 'testcase', classname='Hardening options', name=key)
+ if (self.hardening_kco[key] != self.hardening_kco_ref[key]):
+ valid = False
+ if (key == "CONFIG_CMDLINE"):
+ if (len(self.hardening_kco['CONFIG_CMDLINE']) > 0):
+ valid = True
+ if (key == "CONFIG_DEBUG_STRICT_USER_COPY_CHECKS"):
+ if (self.hardening_kco['CONFIG_ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS'] == 'y'):
+ valid = True
+ if (key == "CONFIG_RANDOMIZE_BASE_MAX_OFFSET"):
+ options = self.hardening_kco_ref[key].split(',')
+ for option in options:
+ if (option == self.hardening_kco[key]):
+ valid = True
+ break
+ if not valid:
+ msg1 = 'current=' + key + ' is ' + \
+ str(self.hardening_kco[
+ key]) + ', recommended=' + key + ' is ' + str(self.hardening_kco_ref[key])
+ etree.SubElement(
+ tcase1, 'failure', message=msg1, type='violation')
+ for key in sorted(self.keys_kco):
+ tcase2 = etree.SubElement(
+ root, 'testcase', classname='Key-related options', name=key)
+ if (self.keys_kco[key] != self.keys_kco_ref[key]):
+ msg2 = 'current=' + key + ' is ' + \
+ str(self.keys_kco[key] + ', recommended=' +
+ key + ' is ' + str(self.keys_kco_ref[key]))
+ etree.SubElement(
+ tcase2, 'failure', message=msg2, type='violation')
+ for key in sorted(self.security_kco):
+ tcase3 = etree.SubElement(
+ root, 'testcase', classname='Security options', name=key)
+ if (self.security_kco[key] != self.security_kco_ref[key]):
+ valid = False
+ if (key == "CONFIG_DEFAULT_SECURITY"):
+ options = self.security_kco_ref[key].split(',')
+ for option in options:
+ if (option == self.security_kco[key]):
+ valid = True
+ break
+ if ((key == "CONFIG_SECURITY_SELINUX") or
+ (key == "CONFIG_SECURITY_SMACK") or
+ (key == "CONFIG_SECURITY_APPARMOR") or
+ (key == "CONFIG_SECURITY_TOMOYO")):
+ if ((self.security_kco['CONFIG_SECURITY_SELINUX'] == 'y') or
+ (self.security_kco['CONFIG_SECURITY_SMACK'] == 'y') or
+ (self.security_kco['CONFIG_SECURITY_APPARMOR'] == 'y') or
+ (self.security_kco['CONFIG_SECURITY_TOMOYO'] == 'y')):
+ valid = True
+ if not valid:
+ msg3 = 'current=' + key + ' is ' + \
+ str(self.security_kco[key]) + ', recommended=' + \
+ key + ' is ' + str(self.security_kco_ref[key])
+ etree.SubElement(
+ tcase3, 'failure', message=msg3, type='violation')
+ for key in sorted(self.integrity_kco):
+ tcase4 = etree.SubElement(
+ root, 'testcase', classname='Integrity options', name=key)
+ if (self.integrity_kco[key] != self.integrity_kco_ref[key]):
+ valid = False
+ if ((key == "CONFIG_IMA_DEFAULT_HASH_SHA1") or
+ (key == "CONFIG_IMA_DEFAULT_HASH_SHA256") or
+ (key == "CONFIG_IMA_DEFAULT_HASH_SHA512") or
+ (key == "CONFIG_IMA_DEFAULT_HASH_WP512")):
+ if ((self.integrity_kco['CONFIG_IMA_DEFAULT_HASH_SHA256'] == 'y') or
+ (self.integrity_kco['CONFIG_IMA_DEFAULT_HASH_SHA512'] == 'y')):
+ valid = True
+ if not valid:
+ msg4 = 'current=' + key + ' is ' + \
+ str(self.integrity_kco[
+ key]) + ', recommended=' + key + ' is ' + str(self.integrity_kco_ref[key])
+ etree.SubElement(
+ tcase4, 'failure', message=msg4, type='violation')
+ tree = etree.ElementTree(root)
+ output = self.problems_report_name + "_" + ISA_kernel.img_name + '.xml'
+ try:
+ tree.write(output, encoding='UTF-8',
+ pretty_print=True, xml_declaration=True)
+ except TypeError:
+ tree.write(output, encoding='UTF-8', xml_declaration=True)
+
+
+def merge_config(arch_kco, common_kco):
+ merged = arch_kco.copy()
+ merged.update(common_kco)
+ return merged
+
+# ======== supported callbacks from ISA ============= #
+def init(ISA_config):
+ global KCAnalyzer
+ KCAnalyzer = ISA_KernelChecker(ISA_config)
+
+
+def getPluginName():
+ return "ISA_KernelChecker"
+
+
+def process_kernel(ISA_kernel):
+ global KCAnalyzer
+ return KCAnalyzer.process_kernel(ISA_kernel)
+# ==================================================== #
diff --git a/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_la_plugin.py b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_la_plugin.py
new file mode 100644
index 00000000..20e7e26b
--- /dev/null
+++ b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/ISA_la_plugin.py
@@ -0,0 +1,273 @@
+#
+# ISA_la_plugin.py - License analyzer plugin, part of ISA FW
+# Functionality is based on similar scripts from Clear linux project
+#
+# Copyright (c) 2015 - 2016, Intel Corporation
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of Intel Corporation nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import subprocess
+import os, sys
+
+LicenseChecker = None
+
+flicenses = "/configs/la/licenses"
+fapproved_non_osi = "/configs/la/approved-non-osi"
+fexceptions = "/configs/la/exceptions"
+funwanted = "/configs/la/violations"
+
+
+class ISA_LicenseChecker():
+ initialized = False
+ rpm_present = False
+
+ def __init__(self, ISA_config):
+ self.logfile = ISA_config.logdir + "/isafw_lalog"
+ self.unwanted = []
+ self.report_name = ISA_config.reportdir + "/la_problems_report_" + \
+ ISA_config.machine + "_" + ISA_config.timestamp
+ self.image_pkg_list = ISA_config.reportdir + "/pkglist"
+ self.image_pkgs = []
+ self.la_plugin_image_whitelist = ISA_config.la_plugin_image_whitelist
+ self.la_plugin_image_blacklist = ISA_config.la_plugin_image_blacklist
+ self.initialized = True
+ with open(self.logfile, 'a') as flog:
+ flog.write("\nPlugin ISA_LA initialized!\n")
+ # check that rpm is installed (supporting only rpm packages for now)
+ DEVNULL = open(os.devnull, 'wb')
+ rc = subprocess.call(["which", "rpm"], stdout=DEVNULL, stderr=DEVNULL)
+ DEVNULL.close()
+ if rc == 0:
+ self.rpm_present = True
+ else:
+ with open(self.logfile, 'a') as flog:
+ flog.write("rpm tool is missing! Licence info is expected from build system\n")
+
+ def process_package(self, ISA_pkg):
+ if (self.initialized):
+ if ISA_pkg.name:
+ if (not ISA_pkg.licenses):
+ # need to determine licenses first
+ # for this we need rpm tool to be present
+ if (not self.rpm_present):
+ with open(self.logfile, 'a') as flog:
+ flog.write("rpm tool is missing and licence info is not provided. Cannot proceed.\n")
+ return;
+ if (not ISA_pkg.source_files):
+ if (not ISA_pkg.path_to_sources):
+ self.initialized = False
+ with open(self.logfile, 'a') as flog:
+ flog.write(
+ "No path to sources or source file list is provided!")
+ flog.write(
+ "\nNot able to determine licenses for package: " + ISA_pkg.name)
+ return
+ # need to build list of source files
+ ISA_pkg.source_files = self.find_files(
+ ISA_pkg.path_to_sources)
+ for i in ISA_pkg.source_files:
+ if (i.endswith(".spec")):# supporting rpm only for now
+ args = ("rpm", "-q", "--queryformat",
+ "%{LICENSE} ", "--specfile", i)
+ try:
+ popen = subprocess.Popen(
+ args, stdout=subprocess.PIPE)
+ popen.wait()
+ ISA_pkg.licenses = popen.stdout.read().split()
+ except:
+ self.initialized = False
+ with open(self.logfile, 'a') as flog:
+ flog.write(
+ "Error in executing rpm query: " + str(sys.exc_info()))
+ flog.write(
+ "\nNot able to process package: " + ISA_pkg.name)
+ return
+ for l in ISA_pkg.licenses:
+ if (not self.check_license(l, flicenses) and
+ not self.check_license(l, fapproved_non_osi) and
+ not self.check_exceptions(ISA_pkg.name, l, fexceptions)):
+ # log the package as not following correct license
+ with open(self.report_name, 'a') as freport:
+ freport.write(l + "\n")
+ if (self.check_license(l, funwanted)):
+ # log the package as having license that should not be
+ # used
+ with open(self.report_name + "_unwanted", 'a') as freport:
+ freport.write(l + "\n")
+ else:
+ self.initialized = False
+ with open(self.logfile, 'a') as flog:
+ flog.write(
+ "Mandatory argument package name is not provided!\n")
+ flog.write("Not performing the call.\n")
+ else:
+ with open(self.logfile, 'a') as flog:
+ flog.write(
+ "Plugin hasn't initialized! Not performing the call.")
+
+ def process_report(self):
+ if (self.initialized):
+ with open(self.logfile, 'a') as flog:
+ flog.write("Creating report with violating licenses.\n")
+ self.process_pkg_list()
+ self.write_report_unwanted()
+ with open(self.logfile, 'a') as flog:
+ flog.write("Creating report in XML format.\n")
+ self.write_report_xml()
+
+ def process_pkg_list(self):
+ if os.path.isfile (self.image_pkg_list):
+ img_name = ""
+ with open(self.image_pkg_list, 'r') as finput:
+ for line in finput:
+ line = line.strip()
+ if not line:
+ continue
+ if line.startswith("Packages "):
+ img_name = line.split()[3]
+ with open(self.logfile, 'a') as flog:
+ flog.write("img_name: " + img_name + "\n")
+ continue
+ package_info = line.split()
+ pkg_name = package_info[0]
+ orig_pkg_name = package_info[2]
+ if (not self.image_pkgs) or ((pkg_name + " from " + img_name) not in self.image_pkgs):
+ self.image_pkgs.append(pkg_name + " from " + img_name + " " + orig_pkg_name)
+
+ def write_report_xml(self):
+ try:
+ from lxml import etree
+ except ImportError:
+ try:
+ import xml.etree.cElementTree as etree
+ except ImportError:
+ import xml.etree.ElementTree as etree
+ num_tests = 0
+ root = etree.Element('testsuite', name='LA_Plugin', tests='2')
+ if os.path.isfile(self.report_name):
+ with open(self.report_name, 'r') as f:
+ class_name = "Non-approved-licenses"
+ for line in f:
+ line = line.strip()
+ if line == "":
+ continue
+ if line.startswith("Packages that "):
+ class_name = "Violating-licenses"
+ continue
+ num_tests += 1
+ tcase1 = etree.SubElement(
+ root, 'testcase', classname=class_name, name=line.split(':', 1)[0])
+ etree.SubElement(
+ tcase1, 'failure', message=line, type='violation')
+ else:
+ tcase1 = etree.SubElement(
+ root, 'testcase', classname='ISA_LAChecker', name='none')
+ num_tests = 1
+ root.set('tests', str(num_tests))
+ tree = etree.ElementTree(root)
+ output = self.report_name + '.xml'
+ try:
+ tree.write(output, encoding='UTF-8',
+ pretty_print=True, xml_declaration=True)
+ except TypeError:
+ tree.write(output, encoding='UTF-8', xml_declaration=True)
+
+ def write_report_unwanted(self):
+ if os.path.isfile(self.report_name + "_unwanted"):
+ with open(self.logfile, 'a') as flog:
+ flog.write("image_pkgs: " + str(self.image_pkgs) + "\n")
+ flog.write("self.la_plugin_image_whitelist: " + str(self.la_plugin_image_whitelist) + "\n")
+ flog.write("self.la_plugin_image_blacklist: " + str(self.la_plugin_image_blacklist) + "\n")
+ with open(self.report_name, 'a') as fout:
+ with open(self.report_name + "_unwanted", 'r') as f:
+ fout.write(
+ "\n\nPackages that violate mandatory license requirements:\n")
+ for line in f:
+ line = line.strip()
+ pkg_name = line.split(':',1)[0]
+ if (not self.image_pkgs):
+ fout.write(line + " from image name not available \n")
+ continue
+ for pkg_info in self.image_pkgs:
+ image_pkg_name = pkg_info.split()[0]
+ image_name = pkg_info.split()[2]
+ image_orig_pkg_name = pkg_info.split()[3]
+ if ((image_pkg_name == pkg_name) or (image_orig_pkg_name == pkg_name)):
+ if self.la_plugin_image_whitelist and (image_name not in self.la_plugin_image_whitelist):
+ continue
+ if self.la_plugin_image_blacklist and (image_name in self.la_plugin_image_blacklist):
+ continue
+ fout.write(line + " from image " + image_name)
+ if (image_pkg_name != image_orig_pkg_name):
+ fout.write(" binary_pkg_name " + image_pkg_name + "\n")
+ continue
+ fout.write("\n")
+ os.remove(self.report_name + "_unwanted")
+
+ def find_files(self, init_path):
+ list_of_files = []
+ for (dirpath, dirnames, filenames) in os.walk(init_path):
+ for f in filenames:
+ list_of_files.append(str(dirpath + "/" + f)[:])
+ return list_of_files
+
+ def check_license(self, license, file_path):
+ with open(os.path.dirname(__file__) + file_path, 'r') as f:
+ for line in f:
+ s = line.rstrip()
+ curr_license = license.split(':',1)[1]
+ if s == curr_license:
+ return True
+ return False
+
+ def check_exceptions(self, pkg_name, license, file_path):
+ with open(os.path.dirname(__file__) + file_path, 'r') as f:
+ for line in f:
+ s = line.rstrip()
+ curr_license = license.split(':',1)[1]
+ if s == pkg_name + " " + curr_license:
+ return True
+ return False
+
+# ======== supported callbacks from ISA ============= #
+
+def init(ISA_config):
+ global LicenseChecker
+ LicenseChecker = ISA_LicenseChecker(ISA_config)
+
+
+def getPluginName():
+ return "ISA_LicenseChecker"
+
+
+def process_package(ISA_pkg):
+ global LicenseChecker
+ return LicenseChecker.process_package(ISA_pkg)
+
+
+def process_report():
+ global LicenseChecker
+ return LicenseChecker.process_report()
+
+# ==================================================== #
diff --git a/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/__init__.py b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/__init__.py
new file mode 100644
index 00000000..ad1997d0
--- /dev/null
+++ b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/__init__.py
@@ -0,0 +1,42 @@
+#
+# __init__.py - part of ISA FW
+#
+# Copyright (c) 2015 - 2016, Intel Corporation
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of Intel Corporation nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import glob
+import keyword
+import os
+import sys
+
+basedir = os.path.dirname(__file__)
+
+__all__ = []
+for name in glob.glob(os.path.join(basedir, '*.py')):
+ module = os.path.splitext(os.path.split(name)[-1])[0]
+ if not module.startswith('_') and not keyword.iskeyword(module):
+ __import__(__name__ + '.' + module)
+ __all__.append(module)
+__all__.sort()
diff --git a/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/__init__.py b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/__init__.py
diff --git a/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/kca/__init__.py b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/kca/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/kca/__init__.py
diff --git a/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/kca/arm.py b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/kca/arm.py
new file mode 100644
index 00000000..d47ba9f1
--- /dev/null
+++ b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/kca/arm.py
@@ -0,0 +1,24 @@
+############################################################################################
+# Kernel Hardening Configurations
+############################################################################################
+hardening_kco = {'CONFIG_DEFAULT_MMAP_MIN_ADDR': 'not set',}
+hardening_kco_ref = {'CONFIG_DEFAULT_MMAP_MIN_ADDR': '32768',}
+############################################################################################
+# Keys Kernel Configuration
+############################################################################################
+keys_kco = {}
+keys_kco_ref = {}
+############################################################################################
+# Security Kernel Configuration
+############################################################################################
+security_kco = {'CONFIG_LSM_MMAP_MIN_ADDR': 'not set',}
+security_kco_ref = {'CONFIG_LSM_MMAP_MIN_ADDR': '32768',}
+############################################################################################
+# Integrity Kernel Configuration
+############################################################################################
+integrity_kco = {}
+integrity_kco_ref = {}
+############################################################################################
+# Comments
+############################################################################################
+comments = {'CONFIG_DEFAULT_MMAP_MIN_ADDR': 'Defines the portion of low virtual memory that should be protected from userspace allocation. Keeping a user from writing to low pages can help reduce the impact of kernel NULL pointer bugs.'}
diff --git a/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/kca/common.py b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/kca/common.py
new file mode 100644
index 00000000..faa388ca
--- /dev/null
+++ b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/kca/common.py
@@ -0,0 +1,242 @@
+############################################################################################
+# Kernel Hardening Configurations
+############################################################################################
+hardening_kco = {'CONFIG_SERIAL_8250_CONSOLE': 'not set',
+ 'CONFIG_SERIAL_CORE': 'not set',
+ 'CONFIG_SERIAL_CORE_CONSOLE': 'not set',
+ 'CONFIG_CMDLINE_BOOL': 'not set',
+ 'CONFIG_CMDLINE': 'not set',
+ 'CONFIG_CMDLINE_OVERRIDE': 'not set',
+ 'CONFIG_DEBUG_INFO': 'not set',
+ 'CONFIG_KGDB': 'not set',
+ 'CONFIG_KPROBES': 'not set',
+ 'CONFIG_FTRACE': 'not set',
+ 'CONFIG_OPROFILE': 'not set',
+ 'CONFIG_PROFILING': 'not set',
+ 'CONFIG_MAGIC_SYSRQ': 'not set',
+ 'CONFIG_DEBUG_BUGVERBOSE': 'not set',
+ 'CONFIG_IP_PNP': 'not set',
+ 'CONFIG_IKCONFIG': 'not set',
+ 'CONFIG_SWAP': 'not set',
+ 'CONFIG_NAMESPACES': 'not set',
+ 'CONFIG_NFSD': 'not set',
+ 'CONFIG_NFS_FS': 'not set',
+ 'CONFIG_BINFMT_MISC': 'not set',
+ 'CONFIG_KALLSYMS': 'not set',
+ 'CONFIG_KALLSYMS_ALL': 'not set',
+ 'CONFIG_BUG': 'not set',
+ 'CONFIG_SYSCTL_SYSCALL': 'not set',
+ 'CONFIG_MODULE_UNLOAD': 'not set',
+ 'CONFIG_MODULE_FORCE_LOAD': 'not set',
+ 'CONFIG_DEVMEM': 'not set',
+ 'CONFIG_COREDUMP': 'not set',
+ 'CONFIG_CROSS_MEMORY_ATTACH': 'not set',
+ 'CONFIG_UNIX_DIAG': 'not set',
+ 'CONFIG_CHECKPOINT_RESTORE': 'not set',
+ 'CONFIG_PANIC_ON_OOPS': 'not set',
+ 'CONFIG_PACKET_DIAG': 'not set',
+ 'CONFIG_FW_LOADER_USER_HELPER': 'not set',
+ 'CONFIG_BPF_JIT': 'not set',
+ 'CONFIG_USELIB': 'not set',
+ 'CONFIG_CC_STACKPROTECTOR': 'not set',
+ 'CONFIG_KEXEC': 'not set',
+ 'CONFIG_PROC_KCORE': 'not set',
+ 'CONFIG_SECURITY_DMESG_RESTRICT': 'not set',
+ 'CONFIG_DEBUG_STACKOVERFLOW': 'not set',
+ 'CONFIG_DEBUG_STRICT_USER_COPY_CHECKS': 'not set',
+ 'CONFIG_ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS': 'not set',
+ 'CONFIG_IKCONFIG_PROC': 'not set',
+ 'CONFIG_RANDOMIZE_BASE': 'not set',
+ 'CONFIG_DEBUG_RODATA': 'not set',
+ 'CONFIG_STRICT_DEVMEM': 'not set',
+ 'CONFIG_DEVKMEM': 'not set',
+ 'CONFIG_ARCH_BINFMT_ELF_RANDOMIZE_PIE': 'not set',
+ 'CONFIG_DEBUG_KERNEL': 'not set',
+ 'CONFIG_DEBUG_FS': 'not set',
+ 'CONFIG_MODULE_SIG_FORCE': 'not set',
+ }
+hardening_kco_ref = {'CONFIG_SERIAL_8250_CONSOLE': 'not set',
+ 'CONFIG_SERIAL_CORE': 'not set',
+ 'CONFIG_SERIAL_CORE_CONSOLE': 'not set',
+ 'CONFIG_CMDLINE_BOOL': 'y',
+ 'CONFIG_CMDLINE': '"cmd_line"',
+ 'CONFIG_CMDLINE_OVERRIDE': 'y',
+ 'CONFIG_DEBUG_INFO': 'not set',
+ 'CONFIG_KGDB': 'not set',
+ 'CONFIG_KPROBES': 'not set',
+ 'CONFIG_FTRACE': 'not set',
+ 'CONFIG_OPROFILE': 'not set',
+ 'CONFIG_PROFILING': 'not set',
+ 'CONFIG_MAGIC_SYSRQ': 'not set',
+ 'CONFIG_DEBUG_BUGVERBOSE': 'not set',
+ 'CONFIG_IP_PNP': 'not set',
+ 'CONFIG_IKCONFIG': 'not set',
+ 'CONFIG_SWAP': 'not set',
+ 'CONFIG_NAMESPACES': 'not set',
+ 'CONFIG_NFSD': 'not set',
+ 'CONFIG_NFS_FS': 'not set',
+ 'CONFIG_BINFMT_MISC': 'not set',
+ 'CONFIG_KALLSYMS': 'not set',
+ 'CONFIG_KALLSYMS_ALL': 'not set',
+ 'CONFIG_BUG': 'not set',
+ 'CONFIG_SYSCTL_SYSCALL': 'not set',
+ 'CONFIG_MODULE_UNLOAD': 'not set',
+ 'CONFIG_MODULE_FORCE_LOAD': 'not set',
+ 'CONFIG_DEVMEM': 'not set',
+ 'CONFIG_COREDUMP': 'not set',
+ 'CONFIG_CROSS_MEMORY_ATTACH': 'not set',
+ 'CONFIG_UNIX_DIAG': 'not set',
+ 'CONFIG_CHECKPOINT_RESTORE': 'not set',
+ 'CONFIG_PANIC_ON_OOPS': 'y',
+ 'CONFIG_PACKET_DIAG': 'not set',
+ 'CONFIG_FW_LOADER_USER_HELPER': 'not set',
+ 'CONFIG_BPF_JIT': 'not set',
+ 'CONFIG_USELIB': 'not set',
+ 'CONFIG_CC_STACKPROTECTOR': 'y',
+ 'CONFIG_KEXEC': 'not set',
+ 'CONFIG_PROC_KCORE': 'not set',
+ 'CONFIG_SECURITY_DMESG_RESTRICT': 'y',
+ 'CONFIG_DEBUG_STACKOVERFLOW': 'y',
+ 'CONFIG_DEBUG_STRICT_USER_COPY_CHECKS': 'y',
+ 'CONFIG_ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS': 'y',
+ 'CONFIG_IKCONFIG_PROC': 'not set',
+ 'CONFIG_RANDOMIZE_BASE': 'y',
+ 'CONFIG_DEBUG_RODATA': 'y',
+ 'CONFIG_STRICT_DEVMEM': 'y',
+ 'CONFIG_DEVKMEM': 'not set',
+ 'CONFIG_ARCH_BINFMT_ELF_RANDOMIZE_PIE': 'y',
+ 'CONFIG_DEBUG_KERNEL': 'not set',
+ 'CONFIG_DEBUG_FS': 'not set',
+ 'CONFIG_MODULE_SIG_FORCE': 'y',
+ }
+############################################################################################
+# Keys Kernel Configuration
+############################################################################################
+keys_kco = {'CONFIG_KEYS': 'not set',
+ 'CONFIG_TRUSTED_KEYS': 'not set',
+ 'CONFIG_ENCRYPTED_KEYS': 'not set',
+ 'CONFIG_KEYS_DEBUG_PROC_KEYS': 'not set'
+ }
+keys_kco_ref = {'CONFIG_KEYS': 'y',
+ 'CONFIG_TRUSTED_KEYS': 'y',
+ 'CONFIG_ENCRYPTED_KEYS': 'y',
+ 'CONFIG_KEYS_DEBUG_PROC_KEYS': 'not set'
+ }
+############################################################################################
+# Security Kernel Configuration
+############################################################################################
+security_kco = {'CONFIG_SECURITY': 'not set',
+ 'CONFIG_SECURITYFS': 'not set',
+ 'CONFIG_SECURITY_NETWORKING': 'not set',
+ 'CONFIG_DEFAULT_SECURITY': 'not set',
+ 'CONFIG_SECURITY_SELINUX': 'not set',
+ 'CONFIG_SECURITY_SMACK': 'not set',
+ 'CONFIG_SECURITY_TOMOYO': 'not set',
+ 'CONFIG_SECURITY_APPARMOR': 'not set',
+ 'CONFIG_SECURITY_YAMA': 'not set',
+ 'CONFIG_SECURITY_YAMA_STACKED': 'not set'
+ }
+security_kco_ref = {'CONFIG_SECURITY': 'y',
+ 'CONFIG_SECURITYFS': 'y',
+ 'CONFIG_SECURITY_NETWORKING': 'y',
+ 'CONFIG_DEFAULT_SECURITY': '"selinux","smack","apparmor","tomoyo"',
+ 'CONFIG_SECURITY_SELINUX': 'y',
+ 'CONFIG_SECURITY_SMACK': 'y',
+ 'CONFIG_SECURITY_TOMOYO': 'y',
+ 'CONFIG_SECURITY_APPARMOR': 'y',
+ 'CONFIG_SECURITY_YAMA': 'y',
+ 'CONFIG_SECURITY_YAMA_STACKED': 'y'
+ }
+############################################################################################
+# Integrity Kernel Configuration
+############################################################################################
+integrity_kco = {'CONFIG_INTEGRITY': 'not set',
+ 'CONFIG_INTEGRITY_SIGNATURE': 'not set',
+ 'CONFIG_INTEGRITY_AUDIT': 'not set',
+ 'CONFIG_IMA': 'not set',
+ 'CONFIG_IMA_LSM_RULES': 'not set',
+ 'CONFIG_IMA_APPRAISE': 'not set',
+ 'CONFIG_IMA_TRUSTED_KEYRING': 'not set',
+ 'CONFIG_IMA_APPRAISE_SIGNED_INIT': 'not set',
+ 'CONFIG_EVM': 'not set',
+ 'CONFIG_EVM_ATTR_FSUUID': 'not set',
+ 'CONFIG_EVM_EXTRA_SMACK_XATTRS': 'not set',
+ 'CONFIG_IMA_DEFAULT_HASH_SHA1': 'not set',
+ 'CONFIG_IMA_DEFAULT_HASH_SHA256': 'not set',
+ 'CONFIG_IMA_DEFAULT_HASH_SHA512': 'not set',
+ 'CONFIG_IMA_DEFAULT_HASH_WP512': 'not set'
+ }
+integrity_kco_ref = {'CONFIG_INTEGRITY': 'y',
+ 'CONFIG_INTEGRITY_SIGNATURE': 'y',
+ 'CONFIG_INTEGRITY_AUDIT': 'y',
+ 'CONFIG_IMA': 'y',
+ 'CONFIG_IMA_LSM_RULES': 'y',
+ 'CONFIG_IMA_APPRAISE': 'y',
+ 'CONFIG_IMA_TRUSTED_KEYRING': 'y',
+ 'CONFIG_IMA_APPRAISE_SIGNED_INIT': 'y',
+ 'CONFIG_EVM': 'y',
+ 'CONFIG_EVM_ATTR_FSUUID': 'y',
+ 'CONFIG_EVM_EXTRA_SMACK_XATTRS': 'y',
+ 'CONFIG_IMA_DEFAULT_HASH_SHA1': 'not set',
+ 'CONFIG_IMA_DEFAULT_HASH_SHA256': 'y',
+ 'CONFIG_IMA_DEFAULT_HASH_SHA512': 'y',
+ 'CONFIG_IMA_DEFAULT_HASH_WP512': 'not set'
+ }
+############################################################################################
+# Comments
+############################################################################################
+comments = { # Kernel Hardening Configurations
+ 'CONFIG_SERIAL_8250_CONSOLE': 'Enables the serial console. Providing access to the serial console would assist an attacker in discovering attack vectors.',
+ 'CONFIG_SERIAL_CORE': 'Enables the serial console. Providing access to the serial console would assist an attacker in discovering attack vectors.',
+ 'CONFIG_SERIAL_CORE_CONSOLE': 'Enables the serial console. Providing access to the serial console would assist an attacker in discovering attack vectors.',
+ 'CONFIG_CMDLINE_BOOL': 'Enables the kernel command line to be hardcoded directly into the kernel. Hardcoding the command line allows tighter control over kernel command line options.',
+ 'CONFIG_CMDLINE': 'Defines the kernel command line to be hardcoded into the kernel. Hardcoding the command line allows tighter control over kernel command line options.',
+ 'CONFIG_CMDLINE_OVERRIDE': 'Enables the kernel to ignore the boot loader command line and to use only the hardcoded command line. Hardcoding the command line allows tighter control over kernel command line options.',
+ 'CONFIG_DEBUG_INFO': 'Enables debug symbols in the kernel. Providing debug symbols would assist an attacker in discovering attack vectors.',
+ 'CONFIG_KGDB': 'Enables KGDB over USB and console ports. Providing KGDB would assist an attacker in discovering attack vectors.',
+ 'CONFIG_KPROBES': 'Enables Kernel Dynamic Probes. Providing kprobes allows the attacker to collect debug and performance information.',
+ 'CONFIG_FTRACE': 'Enables the kernel to trace every function. Providing kernel trace functionality would assist an attacker in discovering attack vectors.',
+ 'CONFIG_OPROFILE': 'Enables a profiling system capable of profiling kernel and kernel modules. Providing profiling functionality would assist an attacker in discovering attack vectors.',
+ 'CONFIG_PROFILING': 'Enables a profiling system capable of profiling kernel and kernel modules. Providing profiling functionality would assist an attacker in discovering attack vectors.',
+ 'CONFIG_MAGIC_SYSRQ': 'Enables a console device to interpret special characters as SysRQ system commands. SysRQ commands are an immediate attack vector as they provide the ability to dump information or reboot the device.',
+ 'CONFIG_DEBUG_BUGVERBOSE': 'Enables verbose logging for BUG() panics. Verbose logging would assist an attacker in discovering attack vectors.',
+ 'CONFIG_IP_PNP': 'Enables automatic configuration of IP addresses of devices and of the routing table during kernel boot. Providing networking functionality before the system has come up would assist an attacker in discovering attack vectors.',
+ 'CONFIG_IKCONFIG': 'Enables access to the kernel config through /proc/config.gz. Leaking the kernel configuration would assist an attacker in discovering attack vectors.',
+ 'CONFIG_SWAP': 'Enables swap files for kernel. The ability to read kernel memory pages in swap files would assist an attacker in discovering attack vectors.',
+ 'CONFIG_NAMESPACES': 'Enabling this can result in duplicates of dev nodes, pids and mount points, which can be useful to attackers trying to spoof running environments on devices.',
+ 'CONFIG_NFSD': 'Enables remote access to files residing on this system using Sun\'s Network File System protocol. Providing remote access to the file system would assist an attacker in discovering attack vectors.',
+ 'CONFIG_NFS_FS': 'Enables remote access to files residing on this system using Sun\'s Network File System protocol. Providing remote access to the file system would assist an attacker in discovering attack vectors.',
+ 'CONFIG_BINFMT_MISC': 'Enables support for binary formats other than ELF. Providing the ability to use alternate interpreters would assist an attacker in discovering attack vectors.',
+ 'CONFIG_KALLSYMS': 'Enables printing of symbolic crash information and symbolic stack backtraces. Verbose logging would assist an attacker in discovering attack vectors.',
+ 'CONFIG_KALLSYMS_ALL': 'Enables printing of symbolic crash information and symbolic stack backtraces. Verbose logging would assist an attacker in discovering attack vectors.',
+ 'CONFIG_BUG': 'Enables display of backtrace and register information for BUGs and WARNs in kernel space. Verbose logging would assist an attacker in discovering attack vectors.',
+ 'CONFIG_SYSCTL_SYSCALL': 'Enables sysctl to read and write kernel parameters. Use of deprecated and unmaintained features is not recommended.',
+ 'CONFIG_MODULE_UNLOAD': 'Enables the ability to unload a kernel module. Allowing module unloading enables the attacker to disable security modules.',
+ 'CONFIG_MODULE_FORCE_LOAD': 'Enables forced loading of modules without version information. Providing an attacker with the ability to force load a module assists in discovering attack vectors.',
+ 'CONFIG_DEVMEM': 'Enables mem device, which provides access to physical memory. Providing a view into physical memory would assist an attacker in discovering attack vectors.',
+ 'CONFIG_COREDUMP': 'Enables support for performing core dumps. Providing core dumps would assist an attacker in discovering attack vectors.',
+ 'CONFIG_CROSS_MEMORY_ATTACH': 'Enables cross-process virtual memory access. Providing virtual memory access to and from a hostile process would assist an attacker in discovering attack vectors.',
+ 'CONFIG_UNIX_DIAG': 'Enables support for socket monitoring interface. Allows the attacker to inspect shared file descriptors on Unix Domain sockets or traffic on \'localhost\'.',
+ 'CONFIG_CHECKPOINT_RESTORE': 'Enables the checkpoint/restore service which can freeze and migrate processes. Providing a method for manipulating process state would assist an attacker in discovering attack vectors.',
+ 'CONFIG_PANIC_ON_OOPS': 'Enables conversion of kernel OOPs to PANIC. When fuzzing the kernel or attempting kernel exploits, attackers are likely to trigger kernel OOPSes. Setting the behavior on OOPS to PANIC can impede their progress.',
+ 'CONFIG_PACKET_DIAG': 'Enables support for socket monitoring interface. Allows the attacker to inspect shared file descriptors on Unix Domain sockets or traffic on \'localhost\'.',
+ 'CONFIG_FW_LOADER_USER_HELPER': 'Enables the invocation of user-helper (e.g. udev) for loading firmware files as a fallback after the direct file loading in kernel fails. Providing firmware auto loader functionality would assist an attacker in discovering attack vectors.',
+ 'CONFIG_BPF_JIT': 'Enables Berkeley Packet Filter filtering capabilities. The BPF JIT can be used to create kernel-payloads from firewall table rules which assist an attacker in discovering attack vectors.',
+ 'CONFIG_USELIB': 'Enables the uselib syscall. The uselib system call has no valid use in any libc6 or uclibc system. Legacy features would assist an attacker in discovering attack vectors.',
+ 'CONFIG_CC_STACKPROTECTOR': 'Enables the stack protector GCC feature which defends against stack-based buffer overflows',
+ 'CONFIG_KEXEC': 'Enables the ability to shutdown your current kernel, and start another one. If enabled, this can be used as a way to bypass signed kernels.',
+ 'CONFIG_PROC_KCORE': 'Enables access to a kernel core dump from userspace. Providing access to core dumps of the kernel would assist an attacker in discovering attack vectors.',
+ 'CONFIG_SECURITY_DMESG_RESTRICT': 'Enables restrictions on unprivileged users reading the kernel syslog via dmesg(8). Unrestricted access to kernel syslogs would assist an attacker in discovering attack vectors.',
+ 'CONFIG_DEBUG_STACKOVERFLOW': 'Enables messages to be printed if free stack space drops below a certain limit. Leaking information about resources used by the kernel would assist an attacker in discovering attack vectors.',
+ 'CONFIG_DEBUG_STRICT_USER_COPY_CHECKS': 'Converts a certain set of sanity checks for user copy operations into compile time failures. The copy_from_user() etc checks help test if there are sufficient security checks on the length argument of the copy operation by having gcc prove that the argument is within bounds.',
+ 'CONFIG_ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS': 'Required to enable DEBUG_STRICT_USER_COPY_CHECKS, but alone does not provide security.',
+ 'CONFIG_IKCONFIG_PROC': 'Enables access to the kernel config through /proc/config.gz. Leaking the kernel configuration would assist an attacker in discovering attack vectors.',
+ 'CONFIG_RANDOMIZE_BASE': 'Enables Kernel Address Space Layout randomization (kASLR). This hinders some types of security attacks by making it more difficult for an attacker to predict target addresses.',
+ 'CONFIG_DEBUG_RODATA': 'Sets kernel text and rodata sections as read-only and write-protected. This guards against malicious attempts to change the kernel\'s executable code.',
+ 'CONFIG_STRICT_DEVMEM': 'Enables restriction of userspace access to kernel memory. Failure to enable this option provides an immediate attack vector.',
+ 'CONFIG_DEVKMEM': 'Enables kmem device, which direct maps kernel memory. Providing a view into kernel memory would assist an attacker in discovering attack vectors.',
+ 'CONFIG_ARCH_BINFMT_ELF_RANDOMIZE_PIE': 'Enables randomization of PIE load address for ELF binaries. This hinders some types of security attacks by making it more difficult for an attacker to predict target addresses.',
+ 'CONFIG_DEBUG_KERNEL': 'Enables sysfs output intended to assist with debugging a kernel. The information output to sysfs would assist an attacker in discovering attack vectors.',
+ 'CONFIG_DEBUG_FS': 'Enables the kernel debug filesystem. The kernel debug filesystem presents a lot of useful information and means of manipulation of the kernel to an attacker.',
+ 'CONFIG_MODULE_SIG_FORCE': 'Enables validation of module signature. Disabling this option enables an attacker to load unsigned modules.',
+}
diff --git a/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/kca/x86.py b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/kca/x86.py
new file mode 100644
index 00000000..cbaddf87
--- /dev/null
+++ b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/kca/x86.py
@@ -0,0 +1,38 @@
+############################################################################################
+# Kernel Hardening Configurations
+############################################################################################
+hardening_kco = {'CONFIG_DEFAULT_MMAP_MIN_ADDR': 'not set',
+ 'CONFIG_RANDOMIZE_BASE_MAX_OFFSET': 'not set',
+ 'CONFIG_X86_INTEL_MPX': 'not set',
+ 'CONFIG_X86_MSR': 'not set'
+ }
+hardening_kco_ref = {'CONFIG_DEFAULT_MMAP_MIN_ADDR': '65536', # x86 specific
+ 'CONFIG_RANDOMIZE_BASE_MAX_OFFSET': '0x20000000,0x40000000', # x86 specific
+ 'CONFIG_X86_INTEL_MPX': 'y', # x86 and certain HW variants specific
+ 'CONFIG_X86_MSR': 'not set'
+ }
+############################################################################################
+# Keys Kernel Configuration
+############################################################################################
+keys_kco = {}
+keys_kco_ref = {}
+############################################################################################
+# Security Kernel Configuration
+############################################################################################
+security_kco = {'CONFIG_LSM_MMAP_MIN_ADDR': 'not set',
+ 'CONFIG_INTEL_TXT': 'not set'}
+security_kco_ref = {'CONFIG_LSM_MMAP_MIN_ADDR': '65536', # x86 specific
+ 'CONFIG_INTEL_TXT': 'y'}
+############################################################################################
+# Integrity Kernel Configuration
+############################################################################################
+integrity_kco = {}
+integrity_kco_ref = {}
+############################################################################################
+# Comments
+############################################################################################
+comments = {'CONFIG_DEFAULT_MMAP_MIN_ADDR': 'Defines the portion of low virtual memory that should be protected from userspace allocation. Keeping a user from writing to low pages can help reduce the impact of kernel NULL pointer bugs.',
+ 'CONFIG_RANDOMIZE_BASE_MAX_OFFSET': 'Defines the maximal offset in bytes that will be applied to the kernel when kernel Address Space Layout Randomization (kASLR) is active.',
+ 'CONFIG_X86_INTEL_MPX': 'Enables MPX hardware features that can be used with compiler-instrumented code to check memory references. It is designed to detect buffer overflow or underflow bugs.',
+ 'CONFIG_X86_MSR': 'Enables privileged processes access to the x86 Model-Specific Registers (MSRs). MSR accesses are directed to a specific CPU on multi-processor systems. This alone does not provide security.'
+ }
diff --git a/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/la/approved-non-osi b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/la/approved-non-osi
new file mode 100644
index 00000000..5e7a69f5
--- /dev/null
+++ b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/la/approved-non-osi
@@ -0,0 +1,43 @@
+Artistic-1.0-perl
+BSD-2-Clause-FreeBSD
+BSD-3-Clause-Clear
+BSD-4-Clause
+BSD-4-Clause-UC
+bzip2-1.0.5
+bzip2-1.0.6
+CC0-1.0
+CC-BY-SA-3.0
+ErlPL-1.1
+FTL
+GFDL-1.1
+GFDL-1.1+
+GFDL-1.2
+GFDL-1.2+
+GFDL-1.3
+GFDL-1.3+
+GPL-1.0
+GPL-1.0+
+ICU
+IJG
+Libpng
+libtiff
+MIT-feh
+MIT-Opengroup
+mpich2
+Muddy-MIT
+OFL-1.0
+OLDAP-2.0.1
+OLDAP-2.8
+OpenSSL
+PHP-3.01
+Qhull
+Ruby
+SGI-B-2.0
+TCL
+Vim
+X11
+Zend-2.0
+zlib-acknowledgement
+ZPL-1.1
+ZPL-2.0
+ZPL-2.1
diff --git a/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/la/exceptions b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/la/exceptions
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/la/exceptions
diff --git a/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/la/licenses b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/la/licenses
new file mode 100644
index 00000000..8fff0b1c
--- /dev/null
+++ b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/la/licenses
@@ -0,0 +1,105 @@
+AFL-1.1
+AFL-1.2
+AFL-2.0
+AFL-2.1
+AFL-3.0
+APL-1.0
+Apache-1.1
+Apache-2.0
+APSL-1.0
+APSL-1.1
+APSL-1.2
+APSL-2.0
+Artistic-1.0
+Artistic-1.0-Perl
+Artistic-1.0-cl8
+Artistic-2.0
+AAL
+BSL-1.0
+BSD-2-Clause
+BSD-3-Clause
+CNRI-Python
+CDDL-1.0
+CPAL-1.0
+CPL-1.0
+CATOSL-1.1
+CUA-OPL-1.0
+EPL-1.0
+ECL-1.0
+ECL-2.0
+EFL-1.0
+EFL-2.0
+Entessa
+EUDatagrid
+EUPL-1.1
+Fair
+Frameworx-1.0
+AGPL-3.0
+GPL-2.0
+GPL-2.0+
+GPL-2.0-with-autoconf-exception
+GPL-2.0-with-bison-exception
+GPL-2.0-with-classpath-exception
+GPL-2.0-with-font-exception
+GPL-2.0-with-GCC-exception
+GPL-3.0
+GPL-3.0+
+GPL-3.0-with-autoconf-exception
+GPL-3.0-with-GCC-exception
+LGPL-2.1
+LGPL-2.1+
+LGPL-3.0
+LGPL-3.0+
+LGPL-2.0
+LGPL-2.0+
+HPND
+IPL-1.0
+Intel
+IPA
+ISC
+LPPL-1.3c
+LPL-1.02
+LPL-1.0
+MS-PL
+MS-RL
+MirOS
+MIT
+Motosoto
+MPL-1.0
+MPL-1.1
+MPL-2.0
+MPL-2.0-no-copyleft-exception
+Multics
+NASA-1.3
+Naumen
+NGPL
+Nokia
+NPOSL-3.0
+NTP
+OCLC-2.0
+OGTSL
+OSL-1.0
+OSL-2.0
+OSL-2.1
+OSL-3.0
+PHP-3.0
+PostgreSQL
+Python-2.0
+QPL-1.0
+RPSL-1.0
+RPL-1.1
+RPL-1.5
+RSCPL
+OFL-1.1
+SimPL-2.0
+Sleepycat
+SISSL
+SPL-1.0
+Watcom-1.0
+NCSA
+VSL-1.0
+W3C
+WXwindows
+Xnet
+Zlib
+ZPL-2.0
diff --git a/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/la/violations b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/la/violations
new file mode 100644
index 00000000..5da203b0
--- /dev/null
+++ b/external/meta-security/meta-security-isafw/lib/isafw/isaplugins/configs/la/violations
@@ -0,0 +1,7 @@
+GPL-3.0
+GPL-3.0+
+GPL-3.0-with-autoconf-exception
+GPL-3.0-with-GCC-exception
+LGPL-3.0
+LGPL-3.0+
+