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

Wrong syntax in policy rule file #58

Open
Amixtika opened this issue Jun 25, 2024 · 1 comment
Open

Wrong syntax in policy rule file #58

Amixtika opened this issue Jun 25, 2024 · 1 comment

Comments

@Amixtika
Copy link

Amixtika commented Jun 25, 2024

When using the policy mode, the rules is created with invalid syntax, the following code change will resolve this issue:

            `fh.write(f'{rule["action"]} (gid:{rule["gid"]}; sid:{rule["sid"]}; enable;)\n')`

Note the added ; add the end of the line, this way SNORT loads the policy file correctly.

The instructions in the generated rules file is also incorrect, these can be updated with the following change:

# Prepare rules for output
    log.info(f'Writing rules to:  {conf.rule_path}')
    header = ('#-------------------------------------------------------------------\n'
              f'#  Rules file created by {SCRIPT_NAME}  at {conf.start_time}\n'
              '#  \n'
              '#  To Use this file: in your snort.lua, you need the following settings:\n'
              '#  ips =\n'
              '#  {{\n'
              '#  rules = [\n'
              f'#      include = "{conf.rule_path}",\n'
              '#  ],\n')
    if conf.rule_mode == 'policy':
        header += ('#  states = [\n' 
                   f'#      include "{conf.policy_path}",\n'
                   '#  ],\n'
                   '#      ...\n'
                   '#  }}\n#\n'
                   '#  detection=\n'
                   '#  {{\n'
                   '#      global_default_rule_state = false,\n')
    header += '#      ...\n'
    header += '#  }}\n#\n'

@amishmm
Copy link

amishmm commented Jun 25, 2024

Pull request is the right way to post / propose your code changes.

Pull requests documentation

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

No branches or pull requests

2 participants