Skip to content

Commit 599d9b8

Browse files
committed
Fix group name and id handling
1 parent f95fa95 commit 599d9b8

7 files changed

Lines changed: 10 additions & 19 deletions

File tree

mythx_cli/analysis/report.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,11 @@ def analysis_report(
4949
:param min_severity: Ignore SWC IDs below the designated level
5050
:param swc_blacklist: A comma-separated list of SWC IDs to ignore
5151
:param swc_whitelist: A comma-separated list of SWC IDs to include
52-
:param table_sort_key: The column to sort the default table output by
5352
:return:
5453
"""
5554

5655
issues_list: List[
57-
Tuple[DetectedIssuesResponse, Optional[AnalysisInputResponse]]
56+
Tuple[str, DetectedIssuesResponse, Optional[AnalysisInputResponse]]
5857
] = []
5958
formatter: BaseFormatter = FORMAT_RESOLVER[ctx["fmt"]]
6059
for uuid in uuids:
@@ -77,7 +76,7 @@ def analysis_report(
7776
issues_list.append((uuid, resp, inp))
7877

7978
LOGGER.debug(
80-
f"{uuid}: Printing report for {len(issues_list)} issue items with sort key \"{ctx['table_sort_key']}\""
79+
f"Printing report for {len(issues_list)} issue items with sort key \"{ctx['table_sort_key']}\""
8180
)
8281
write_or_print(
8382
formatter.format_detected_issues(

mythx_cli/analyze/command.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import click
88
from mythx_models.response import (
99
AnalysisInputResponse,
10+
AnalysisSubmissionResponse,
1011
DetectedIssuesResponse,
1112
GroupCreationResponse,
1213
)
@@ -209,7 +210,7 @@ def analyze(
209210
group_id = resp.identifier
210211
group_name = resp.name or ""
211212

212-
if group_id:
213+
if group_id or group_name:
213214
# associate all following analyses to the passed or newly created group
214215
group_mw = GroupDataMiddleware(group_id=group_id, group_name=group_name)
215216
ctx["client"].handler.middlewares.append(group_mw)
@@ -297,7 +298,7 @@ def analyze(
297298
for job in bar:
298299
# attach execution mode, submit, poll
299300
job.update({"analysis_mode": mode})
300-
resp = ctx["client"].analyze(**job)
301+
resp: AnalysisSubmissionResponse = ctx["client"].analyze(**job)
301302
uuids.append(resp.uuid)
302303

303304
if async_flag:
@@ -308,7 +309,7 @@ def analyze(
308309
return
309310

310311
issues_list: List[
311-
Tuple[DetectedIssuesResponse, Optional[AnalysisInputResponse]]
312+
Tuple[str, DetectedIssuesResponse, Optional[AnalysisInputResponse]]
312313
] = []
313314
formatter: BaseFormatter = FORMAT_RESOLVER[ctx["fmt"]]
314315
for uuid in uuids:

mythx_cli/group/close.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,5 @@ def group_close(ctx, identifiers: List[str]) -> None:
2525
LOGGER.debug(f"Closing group for ID {identifier}")
2626
resp: GroupCreationResponse = ctx["client"].seal_group(group_id=identifier)
2727
write_or_print(
28-
"Closed group with ID {} and name '{}'".format(
29-
resp.group.identifier, resp.group.name
30-
)
28+
"Closed group with ID {} and name '{}'".format(resp.identifier, resp.name)
3129
)

mythx_cli/render/command.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
import click
66
import htmlmin
77
import jinja2
8-
from mythx_models.response import (
9-
AnalysisInputResponse,
10-
AnalysisStatusResponse,
11-
DetectedIssuesResponse,
12-
)
8+
from mythx_models.response import AnalysisInputResponse, DetectedIssuesResponse
139
from pythx import Client
1410

1511
from mythx_cli.render.util import get_analysis_info
@@ -107,7 +103,7 @@ def render(
107103
template = env.get_template(template_name)
108104

109105
issues_list: List[
110-
Tuple[DetectedIssuesResponse, Optional[AnalysisInputResponse]]
106+
Tuple[str, DetectedIssuesResponse, Optional[AnalysisInputResponse]]
111107
] = []
112108
if len(target) == 24:
113109
LOGGER.debug(f"Identified group target {target}")

mythx_cli/render/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def get_analysis_info(
1818
min_severity: Optional[str],
1919
swc_blacklist: Optional[List[str]],
2020
swc_whitelist: Optional[List[str]],
21-
) -> Tuple[AnalysisStatusResponse, DetectedIssuesResponse, AnalysisInputResponse]:
21+
) -> Tuple[str, AnalysisStatusResponse, DetectedIssuesResponse, AnalysisInputResponse]:
2222
"""Fetch information related to the specified analysis job UUID.
2323
2424
Given a UUID, this function will query the MythX API for the

tests/test_analyze_solidity.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import os
22
from copy import deepcopy
3-
from unittest import mock
43

54
import pytest
6-
from black import out
75
from click.testing import CliRunner
86
from mythx_models.response import (
97
AnalysisInputResponse,

tests/test_status.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import json
2-
from unittest.mock import patch
32

43
from click.testing import CliRunner
54
from mythx_models.response import AnalysisStatusResponse, GroupStatusResponse

0 commit comments

Comments
 (0)