dradis / dradis-ce

Dradis Framework: Collaboration and reporting for IT Security teams
https://dradis.com/ce/
GNU General Public License v2.0
672 stars 190 forks source link

Invalid characters may prevent backup files to be restored #116

Closed dormi closed 7 years ago

dormi commented 7 years ago

Steps to reproduce

Expected behavior

The file shold be imported, the issue created.

Actual behavior

Import fails with error Invalid project template format.

Proposed solution

Looks like nokogiri has problems parsing the xml file if it has invalid characters. We may try to "validate" characters before writing them to database?

System configuration

Dradis version:: 3.6

Ruby version: 2.2

OS version: macOs Sierra

dormi commented 7 years ago

In XML spec, not all unicode characters are allowed: https://www.w3.org/TR/2004/REC-xml-20040204/#NT-Char If we rename the attached dradis-template.txt as dradis-template.xml and try to open it with google chrome, we see an error due to invalid characters being present. The same happens when parsing that file with nokogiri gem. As a first approach to this problem, we may filter invalid characters when generating xml files from dradis. The idea would be to filter the first 32 unicode characters (control characters, except tabulation, next line and carriage return, that are allowed). A list with those characters is available here: https://unicode-table.com/en/#control-character

etdsoft commented 7 years ago

We need a better understanding of how common / widespread this problem is going to be with real-life use cases. Closing for now, will re-open in the future as needed.

djsekops commented 7 years ago

This happened to me, a simple copy and past of an output killed the backups and was very difficult to locate. Would certainly be worth doing if feasible.