Request to add JSON output format
choukalos opened this issue · 3 comments
Can you add a command line switch to output JSON format for automation?
Thanks!
Hand writing the output for each check with support for different output formats will get tiresome and messy quite quickly. The only way I can think to avoid this is to formalise a standard set of output fields, and then creating different renderers to render the fields into different formats (much like how the --format option uses Descriptor classes to render the core list/help commands). In order to do this each check would need to return the same sort of data. Looking at the current results, most of the checks appear to output a title, one or more lines of text and a table. So we could potentially create some kind of ScanResult
object that would have a name, url, messages and results properties. That would allow for both something similar to the current output and also for something like:
{
"scans": [
{
"name": "Unreachable paths",
"url": "http://demo.magentoconnect.com",
"results": [
{
"path": "downloader",
"response": 200,
"status": "fail"
},
{
"path": "downloader",
"response": 200,
"status": "fail"
}
]
},
{
"name": "Sitemap",
"url": "http://demo.magentoconnect.com",
"messages": [
"Sitemap is not declared in robots.txt",
"Sitemap is not accessible: http://demo.magentoconnect.com/sitemap.xml"
]
},
{
"name": "Installed Modules",
"url": "http://demo.magentoconnect.com",
"messages": [
"No detectable modules were found"
]
},
{
"name": "Patches",
"url": "http://demo.magentoconnect.com",
"results": [
{
"name": "SUPEE-ABC",
"status": "patched"
},
{
"name": "SUPEE-XYZ",
"status": "vulnerable"
}
]
}
]
}
I'm not entirely sure how you'd go about maintaining the current syntax highlighting with this approach though.
You're right. All results should be passed to a method that outputs based on the current format.
@choukalos You can now format as json with the --format=json
option.