Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugs in runtest.py script #498

Open
Lopuiz opened this issue Oct 4, 2019 · 0 comments
Open

Bugs in runtest.py script #498

Lopuiz opened this issue Oct 4, 2019 · 0 comments
Labels

Comments

@Lopuiz
Copy link
Contributor

Lopuiz commented Oct 4, 2019

Hello team!

I tested Ruleset and I have noted two bugs in runtest.py script:

  1. When a test fails test_decoders.xml and test_ruleset.xml files don't remove.
    I think it is due the function run end with error message.

def run(self, selective_test=False):
for aFile in os.listdir(self._test_path):
aFile = os.path.join(self._test_path, aFile)
if aFile.endswith(".ini"):
if selective_test and not aFile.endswith(selective_test):
continue
print "- [ File = %s ] ---------" % (aFile)
tGroup = ConfigParser.RawConfigParser(dict_type=MultiOrderedDict)
tGroup.read([aFile])
tSections = tGroup.sections()
for t in tSections:
rule = tGroup.get(t, "rule")
alert = tGroup.get(t, "alert")
decoder = tGroup.get(t, "decoder")
for (name, value) in tGroup.items(t):
if name.startswith("log "):
if self._debug:
print "-" * 60
if name.endswith("pass"):
neg = False
elif name.endswith("fail"):
neg = True
else:
neg = False
self.runTest(value, rule, alert, decoder,
t, name, negate=neg)
print ""
if self._error:
sys.exit(1)

  1. We can't input a test file because it doesn't execute the test.
    It due lines 136-142 aren't tab correctly.
    if __name__ == "__main__":
    if len(sys.argv) == 2:
    selective_test = sys.argv[1]
    if not selective_test.endswith('.ini'):
    selective_test += '.ini'
    else:
    selective_test = False
    ossec_init = {}
    initconfigpath = "/etc/ossec-init.conf"
    getOssecConfig(ossec_init, initconfigpath)
    provisionDR(ossec_init["DIRECTORY"])
    OT = OssecTester(ossec_init["DIRECTORY"])
    OT.run(selective_test)
    cleanDR(ossec_init["DIRECTORY"])

Best regards,
Eva

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants