示例#1
0
	def test_rules_attributes(self):
		i = 1
		for r in Rules.all():
			if ("name" not in r) or ("action" not in r):
				self.fail("Missing attributes in rule #" + str(i))

			if r.action not in Rules.ACTIONS.values():
				self.fail("Unknown action in rule: " + r.name)

			if len(r) > 2:
				self.fail("Unsupported attributes in rule: " + r.name)

			i += 1
示例#2
0
文件: tracer.py 项目: xsuchy/tracer
	def _apply_rules(self, process):
		parent = process.parent
		rule = Rules.find(parent.name)

		if not rule or not rule["action"]:
			return process

		if rule["action"] == Rules.ACTIONS["CALL-PARENT"]:
			return self._apply_rules(parent)

		# Only PRINT action left
		# PRINT rule is defined for parent process
		return parent
示例#3
0
	def render_system(self):
		uptime = datetime.now() - datetime.fromtimestamp(System.boot_time())
		uptime = str(uptime).split('.')[0]

		users = set([user.name for user in psutil.get_users()])
		package_managers = System.package_manager().names()

		view = SystemView()
		view.assign('python', System.python_version())
		view.assign('distribution', System.distribution())
		view.assign('package_managers', package_managers)
		view.assign('init', System.init_system())
		view.assign('uptime', uptime)
		view.assign('user', System.user())
		view.assign('users', users)
		view.assign('version', __version__)
		view.assign('rules_count', len(Rules.all()))
		view.assign('applications_count', len(Applications.all()))
		view.render()
示例#4
0
    def render_system(self):
        uptime = datetime.now() - datetime.fromtimestamp(System.boot_time())
        uptime = str(uptime).split('.')[0]

        users = set([user.name for user in psutil.get_users()])
        package_managers = System.package_manager().names()

        view = SystemView()
        view.assign('python', System.python_version())
        view.assign('distribution', System.distribution())
        view.assign('package_managers', package_managers)
        view.assign('init', System.init_system())
        view.assign('uptime', uptime)
        view.assign('user', System.user())
        view.assign('users', users)
        view.assign('version', __version__)
        view.assign('rules_count', len(Rules.all()))
        view.assign('applications_count', len(Applications.all()))
        view.render()
示例#5
0
	def render_rules(self):
		view = RulesView()
		view.assign('rules', Rules.all())
		view.render()
示例#6
0
	def test_rules_types(self):
		for rule in Rules.all():
			self.assertIsInstance(rule, Rule)
示例#7
0
	def test_app_with_no_rule(self):
		self.assertIsNone(Rules.find("NON_EXISTING_APPLICATION"))
示例#8
0
	def test_rules_duplicity(self):
		rules = Rules.all()
		for r in rules:
			if rules.count(r) > 1:
				self.fail("Duplicate rules for: " + r.name)
示例#9
0
 def render_rules(self):
     view = RulesView()
     view.assign('rules', Rules.all())
     view.render()
示例#10
0
	def test_rules_duplicity(self):
		rules = Rules.all()
		for r in rules:
			if self._count(r["name"], rules) > 1:
				self.fail("Duplicate rules for: " + r["name"])