Best Python code snippet using dbt-osmosis_python
policy_base.py
Source:policy_base.py
...4class PolicyBase(object):5 """6 This class acts as the base class of any policy.7 :ivar str name: Name of the policy.8 :ivar angr.Project project: The associated angr project instance. Registered using _register_project() method.9 :ivar angr.KnowledgeBase kb: The associated angr knowledgebase instance. Registered using _register_project() method.10 """11 def __init__(self, name, project=None, manager=None):12 """13 Constructor.14 :param str name: Name of this policy15 :param angr.Project project: The associated angr project.16 :param PolicyManager manager: The associated policy manager instance.17 """18 self.name = name19 self.project = project # type: angr.Project20 self.kb = None # type: angr.knowledgebase.KnowledgeBase21 if project:22 self.kb = project.kb23 self.manager = manager # type: PolicyManager24 #25 # Overriden methods from the base class26 #27 def __repr__(self):28 return "<Policy %s>" % self.name29 #30 # Public interfaces31 #32 def function_check(self, function):33 """34 Check if the policy is violated on a certain function.35 :param function: The function to check the policy against.36 :type function: angr.knowledge.Function or int37 :return: True if the policy is respected, False if the policy is violated.38 :rtype: bool39 """40 raise NotImplementedError()41 def functions_check(self, functions):42 """43 Check if the policy is violated on the given set of functions.44 :param iterable functions: A set of functions to check the policy against.45 :return: True if the policy is respected, False if the policy is violated.46 :rtype: bool47 """48 raise NotImplementedError()49 def program_check(self):50 """51 Check if the policy is violated in the entire program.52 :return: True if the policy is respected, False if the policy is violated.53 :rtype: bool54 """55 raise NotImplementedError()56 #57 # Private interfaces58 #59 def _add_result(self, r):60 if self.manager is not None:61 self.manager.add_result(r)62 @property63 def _failfast(self):64 if self.manager is None:65 return True66 else:67 return self.manager.failfast68 @property69 def _fast_cfg(self):70 if self.manager is not None:71 return self.manager.fast_cfg72 l.warning('Policy %s does not have an associated policy manager. The fast control flow graph is not cached.')73 tmp_kb = angr.KnowledgeBase(self.project, self.project.loader.main_bin)74 return self.project.analyses.CFGFast(kb=tmp_kb)75 #76 # Private methods77 #78 def _register_project(self, project, kb):79 """80 Associate an angr Project with this policy.81 :param angr.Project project: The angr project.82 :param angr.KnowledgeBase kb: The knowledgebase object.83 :return: None84 """85 self.project = project86 self.kb = kb87 def _register_manager(self, manager):88 """89 Associate a policy manager with this policy instance.90 :param PolicyManager manager: The policy manager.91 :return: None92 """...
configlib.py
Source:configlib.py
2# Use of this source code is governed by a BSD-style license that can be3# found in the LICENSE file.4"""This module defines helpers accessible to all BUILD.py files."""5import zmake.output_packers6def _register_project(**kwargs):7 kwargs.setdefault("project_dir", here) # noqa: F8218 register_project(**kwargs) # noqa: F8219def register_host_project(**kwargs):10 kwargs.setdefault("zephyr_board", "native_posix")11 kwargs.setdefault("supported_toolchains", ["llvm", "host"])12 kwargs.setdefault("output_packer", zmake.output_packers.ElfPacker)13 _register_project(**kwargs)14def register_host_test(test_name, **kwargs):15 kwargs.setdefault("is_test", True)16 register_host_project(project_name="test-{}".format(test_name), **kwargs)17def register_raw_project(**kwargs):18 kwargs.setdefault("supported_toolchains", ["coreboot-sdk", "zephyr"])19 kwargs.setdefault("output_packer", zmake.output_packers.RawBinPacker)20 _register_project(**kwargs)21def register_binman_project(**kwargs):22 kwargs.setdefault("output_packer", zmake.output_packers.BinmanPacker)23 register_raw_project(**kwargs)24def register_npcx_project(**kwargs):25 kwargs.setdefault("output_packer", zmake.output_packers.NpcxPacker)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!