Skip to content

Instantly share code, notes, and snippets.

@xentrick
Created June 24, 2019 21:49
Show Gist options
  • Select an option

  • Save xentrick/ce341407fb99c9bab209b080b65955a6 to your computer and use it in GitHub Desktop.

Select an option

Save xentrick/ce341407fb99c9bab209b080b65955a6 to your computer and use it in GitHub Desktop.
Flycheck issues
(require 'flycheck)

(defgroup flycheck-snort nil
  "snortism intergrate with flycheck"
  :prefix "flycheck-snortism"
  :group 'flycheck

(flycheck-define-checker snortism
  "A linter for Snort rules."
  ;; Addition checker options include snort, pyse, visruleparser
  :command ("rulecritic" source-inplace) ;; source from temp file in working dir
  :error-patterns
  ((error line-start
          "Error: "
          (message)
          line-end))
          ;; " line: "
          ;; line
          ;; line-end))
  :modes snort-mode
  :predicate (lambda () (message "Snortism looaded %s" buffer-file-name))
  :verify)

(defun flycheck-snort-unsetup ()
  "Utility function, used for testing only."
  (interactive)
  (setq flycheck-checkers (remove 'snortism flycheck-checkers)))

;;;###autoload
(defun flycheck-snort-setup ()
  "Setup flycheck-snort"
  (interactive)
  (add-to-list 'flycheck-checkers 'snortism))

(provide 'flycheck-snort)
;; flycheck-snort.el ends here

Compile

-*- mode: compilation; default-directory: "~/tmp/flysnorttest/" -*-
Compilation started at Mon Jun 24 17:44:00

rulecritic /home/nmavis/tmp/flysnorttest/local.rules
Error: invalid rule direction
 line 1: alert tcp $blah -> $blah (msg:"TEST"; content:"THIS"; metadata: servi
                            ^

Compilation finished at Mon Jun 24 17:44:00

Verify

Syntax checkers for buffer local.rules in snort-mode:

First checker to run:

  snortism
    - may enable: yes
    - predicate:  t
    - executable: Found at /home/nmavis/bin/rulecritic

Flycheck Mode is enabled. Use SPC u C-c ! x to enable disabled checkers.

--------------------

Flycheck version: 32snapshot (package: 20190619.1410)
Emacs version:    26.2
System:           x86_64-pc-linux-gnu
Window system:    x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment