Merge "Add more_info URL to the JSON output"
This commit is contained in:
commit
71f4df31b6
|
@ -65,6 +65,7 @@ This formatter outputs the issues in JSON.
|
||||||
"line_range": [
|
"line_range": [
|
||||||
5
|
5
|
||||||
],
|
],
|
||||||
|
"more_info": "https://docs.openstack.org/developer/bandit/",
|
||||||
"test_name": "blacklist_calls",
|
"test_name": "blacklist_calls",
|
||||||
"test_id": "B301"
|
"test_id": "B301"
|
||||||
}
|
}
|
||||||
|
@ -84,6 +85,7 @@ import logging
|
||||||
import operator
|
import operator
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from bandit.core import docs_utils
|
||||||
from bandit.core import test_properties
|
from bandit.core import test_properties
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -114,12 +116,15 @@ def report(manager, fileobj, sev_level, conf_level, lines=-1):
|
||||||
collector = []
|
collector = []
|
||||||
for r in results:
|
for r in results:
|
||||||
d = r.as_dict()
|
d = r.as_dict()
|
||||||
|
d['more_info'] = docs_utils.get_url(d['test_id'])
|
||||||
if len(results[r]) > 1:
|
if len(results[r]) > 1:
|
||||||
d['candidates'] = [c.as_dict() for c in results[r]]
|
d['candidates'] = [c.as_dict() for c in results[r]]
|
||||||
collector.append(d)
|
collector.append(d)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
collector = [r.as_dict() for r in results]
|
collector = [r.as_dict() for r in results]
|
||||||
|
for elem in collector:
|
||||||
|
elem['more_info'] = docs_utils.get_url(elem['test_id'])
|
||||||
|
|
||||||
itemgetter = operator.itemgetter
|
itemgetter = operator.itemgetter
|
||||||
if manager.agg_type == 'vuln':
|
if manager.agg_type == 'vuln':
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
[bug/1695890] The ``more_info`` URL link displayed in the HTML output is
|
||||||
|
now also available in the JSON output.
|
|
@ -94,3 +94,5 @@ class JsonFormatterTests(testtools.TestCase):
|
||||||
data['results'][0]['line_range'])
|
data['results'][0]['line_range'])
|
||||||
self.assertEqual(self.check_name, data['results'][0]['test_name'])
|
self.assertEqual(self.check_name, data['results'][0]['test_name'])
|
||||||
self.assertIn('candidates', data['results'][0])
|
self.assertIn('candidates', data['results'][0])
|
||||||
|
self.assertIn('more_info', data['results'][0])
|
||||||
|
self.assertIsNotNone(data['results'][0]['more_info'])
|
||||||
|
|
Loading…
Reference in New Issue