Exemplo n.º 1
0
class NewAgentTestCase(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.agent = Agent()  # Test add
        self.id = self.agent.add('TestAgent', 'any')

    @classmethod
    def tearDownClass(self):
        self.agent.remove()  # Test remove

    def test_valid_id(self):
        self.assertIsInstance(int(self.id), int, 'Returned ID is not valid')

    def test_get_key(self):
        self.assertTrue(self.agent.get_key(), 'Invalid key')

    def test_get(self):
        self.agent.get()
        self.assertEqual(self.agent.name, 'TestAgent')
Exemplo n.º 2
0
class NewAgentTestCase(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.agent = Agent()  # Test add
        self.id = self.agent.add("TestAgent", "any")

    @classmethod
    def tearDownClass(self):
        self.agent.remove()  # Test remove

    def test_valid_id(self):
        self.assertIsInstance(int(self.id), int, "Returned ID is not valid")

    def test_get_key(self):
        self.assertTrue(self.agent.get_key(), "Invalid key")

    def test_get(self):
        self.agent.get()
        self.assertEqual(self.agent.name, "TestAgent")
Exemplo n.º 3
0
import sys
import json

try:
    from wazuh import Wazuh
    from wazuh.agent import Agent
except Exception as e:
    print("No module 'wazuh' found.")
    sys.exit()

if __name__ == "__main__":

    # Creating wazuh object
    # It is possible to specify the ossec path (path argument) or get /etc/ossec-init.conf (get_init argument)
    print("\nWazuh:")
    myWazuh = Wazuh(get_init=True)
    print(myWazuh)

    print("\nAgents:")
    agents = Agent.get_agents_overview(status="all")
    print(json.dumps(agents, indent=4, sort_keys=True))

    print("\nAdding 'WazuhFrameworkTest':")
    agent = Agent()
    agent_id = agent.add("WazuhFrameworkTest", "Any")
    print("\nAgent added with ID: {0}".format(agent_id))
    print("\nAgent key: {0}".format(agent.get_key()))
    agent.get()
    print("\nAgent info:")
    print(json.dumps(agent.to_dict(), indent=4, sort_keys=True))
Exemplo n.º 4
0
#!/usr/bin/env python
import json
from sys import exit
from wazuh.agent import Agent
from wazuh.exception import WazuhException

agent = Agent()

try:
    agent_id = agent.add('WazuhTestAgent', 'Any')
except WazuhException as e:
    print("Error {0}: {1}.".format(e.code, e.message))
    exit(1)

agent_key = agent.get_key()
print("\nAgent added with:\n\tID: {0}\n\tKey: {1}".format(agent_id, agent_key))

agent.get()  # Load information generated by OSSEC
print("\nAgent info:")
print(json.dumps(agent.to_dict(), indent=4, sort_keys=True))