rapid7 / recog

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

Enable fingerprint xsd validation and CI automation #410

Closed dabdine closed 2 years ago

dabdine commented 2 years ago

Description

This does not change any behavior (yet) in Go or Java, however.

Motivation and Context

Malformed XML is not handled well by recog_verify. In most cases, when a malformed document is produced, recog_verify will simply dump a stack trace. This change will now properly report validation errors as errors in the same format as example errors that were previously produced.

This should allow new PR submissions to pass more strict testing automatically, keeping the quality bar high while avoiding the burden on the reviewer for checking whether certain attributes & elements are present, and set to the right values.

How Has This Been Tested?

bundle exec rake tests

Types of changes

Checklist:

dabdine commented 2 years ago

Here's an example of an XML change (_encoding="base65") which will break CI because base65 is not in the enumeration allowed for the _encoding attribute, as specified by fingerprints.xsd:

https://github.com/dabdine/recog/pull/1

You'll see this in the log:

xml/telnet_banners.xml:67: FAIL: 67:0: ERROR: Element 'example', attribute '_encoding': [facet 'enumeration'] The value 'base65' is not an element of the set {'base64'}.