rapid7 / recog

Pattern recognition for hosts, services, and content
Other
671 stars 199 forks source link

Simplify log format and include recog XML filename #430

Closed mkienow-r7 closed 2 years ago

mkienow-r7 commented 2 years ago

Description

A follow-up to #429 that simplifies the log format and includes the recog XML filename in the output. Other minor changes include: moving the main method to the bottom fo the file, small PEP 8 correction (two blank lines between top-level function), corrected method comment.

Motivation and Context

Make the output similar to our other tests.

How Has This Been Tested?

Current log output

$ python3 update_cpes.py xml/http_servers.xml official-cpe-dictionary_v2.3.xml
CRITICAL:root:Expecting exactly 3 arguments; recog XML file, CPE 2.3 XML dictionary, JSON remapping, got 2

$ python3 update_cpes.py xml/http_servers.xml official-cpe-dictionary_v2.3.xml cpe-remap.yaml
ERROR:root:Product squeezebox from vendor logitech invalid for CPE a and no mapping.
ERROR:root:Product bashttpd from vendor avleen_vig invalid for CPE a and no mapping.
ERROR:root:Product envoy from vendor istio invalid for CPE a and no mapping.
...

Updated log output

$ python3 update_cpes.py xml/http_servers.xml official-cpe-dictionary_v2.3.xml
CRITICAL: Expecting exactly 3 arguments; recog XML file, CPE 2.3 XML dictionary, JSON remapping, got 2

$ python3 update_cpes.py xml/http_servers.xml official-cpe-dictionary_v2.3.xml cpe-remap.yaml
xml/http_servers.xml: ERROR: Product squeezebox from vendor logitech invalid for CPE a and no mapping.
xml/http_servers.xml: ERROR: Product bashttpd from vendor avleen_vig invalid for CPE a and no mapping.
xml/http_servers.xml: ERROR: Product envoy from vendor istio invalid for CPE a and no mapping.
...

Types of changes

Checklist: