PoC of new checklist

pull/819/head
Josselin 4 years ago
parent 7fe4253e1a
commit 3280291e10
  1. 20
      slither/utils/command_line.py
  2. 10
      slither/utils/output.py

@ -147,25 +147,29 @@ def convert_result_to_markdown(txt):
def output_results_to_markdown(all_results):
checks = defaultdict(list)
info = defaultdict(dict)
for results in all_results:
checks[results["check"]].append(results["description"])
checks[results["check"]].append(results)
info[results["check"]] = {"impact" : results["impact"], "confidence": results["confidence"]}
print("Summary")
for check in checks:
print(f" - [{check}](#{check}) ({len(checks[check])} results)")
counter = 0
for (check, results) in checks.items():
print(f"## {check}")
print(
"""
| Analyzed | Description |
|----------------|-----------|"""
)
print(f'Impact: {info[check]["impact"]}')
print(f'Confidence: {info[check]["confidence"]}')
for result in results:
result_markdown = convert_result_to_markdown(result)
print(
f"| <ul><li>[ ] TP</li><li>[ ] FP</li><li>[ ] Unknown</li></ul> | {result_markdown}"
" - [ ] ID-"+f"{counter}"
)
counter = counter + 1
print(result["markdown"])
if result["first_markdown_element"]:
print(result["first_markdown_element"])
print('\n')
def output_wiki(detector_classes, filter_wiki):

@ -236,6 +236,14 @@ class Output:
self._data["elements"] = []
self._data["description"] = "".join(_convert_to_description(d) for d in info)
self._data["markdown"] = "".join(_convert_to_markdown(d, markdown_root) for d in info)
self._data["first_markdown_element"] = ""
self._markdown_root = markdown_root
first_element_for_mardown = None
if info:
for elem in info:
if not isinstance(elem, str):
first_element_for_mardown = elem
id_txt = "".join(_convert_to_id(d) for d in info)
self._data["id"] = hashlib.sha3_256(id_txt.encode("utf-8")).hexdigest()
@ -250,6 +258,8 @@ class Output:
self._data["additional_fields"] = additional_fields
def add(self, add: SupportedOutput, additional_fields: Optional[Dict] = None):
if not self._data["first_markdown_element"]:
self._data["first_markdown_element"] = add.source_mapping_to_markdown(self._markdown_root)
if isinstance(add, Variable):
self.add_variable(add, additional_fields=additional_fields)
elif isinstance(add, Contract):

Loading…
Cancel
Save