audithub-client 1.1.17__tar.gz → 1.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {audithub_client-1.1.17 → audithub_client-1.2.0}/PKG-INFO +3 -1
- {audithub_client-1.1.17 → audithub_client-1.2.0}/README.md +1 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/__main__.py +1 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/create_project.py +0 -1
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/create_temp_version_via_local_archive.py +0 -1
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/create_version_via_local_archive.py +0 -1
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_latest_version.py +0 -1
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_project.py +0 -1
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_version_comments.py +0 -1
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/monitor_task.py +5 -7
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/put_organization_restrictions.py +0 -1
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/send_digest.py +2 -2
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/start_orca_task.py +2 -3
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/start_picus_v2_task.py +0 -1
- audithub_client-1.2.0/audithub_client/api/start_scout_task.py +46 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/start_vanguard_task.py +1 -2
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/library/auth.py +2 -1
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/library/http_download.py +1 -2
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/library/net_utils.py +1 -2
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/library/utils.py +1 -1
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/create_version_via_local_archive.py +2 -4
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/download_artifact.py +1 -1
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/get_task_info.py +8 -9
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/start_picus_v2_task.py +4 -4
- audithub_client-1.2.0/audithub_client/scripts/start_scout_task.py +89 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/start_vanguard_task.py +37 -23
- {audithub_client-1.1.17 → audithub_client-1.2.0}/pyproject.toml +10 -1
- {audithub_client-1.1.17 → audithub_client-1.2.0}/LICENSE +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/__init__.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/__init__.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/add_user_to_organization.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/create_organization.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/create_temp_version_via_url.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/create_version_via_url.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/delete_organization.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_configuration.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_my_organizations.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_my_profile.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_organization_projects.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_organization_restrictions.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_organization_users.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_organizations.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_task_archive.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_task_artifact.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_task_info.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_task_logs.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_tasks.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_users.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_version_archive.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/models/__init__.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/qa_cleanup.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/remove_user_from_organization.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/library/__init__.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/library/context.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/library/http.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/library/invocation_common.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/library/json_dump.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/library/logging_level.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/library/orca_utils.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/library/ssl.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/py.typed +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/create_version_via_url.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/get_configuration.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/get_my_organizations.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/get_my_profile.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/get_task_archive.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/get_task_artifact.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/get_task_logs.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/get_users.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/get_version_archive.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/monitor_task.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/qa_cleanup.py +0 -0
- {audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/start_orca_task.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: audithub-client
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: A Python client that can access Veridise AuditHub via its REST API, providing CLI access
|
|
5
5
|
License: AGPLv3
|
|
6
6
|
License-File: LICENSE
|
|
@@ -12,6 +12,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.13
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
15
16
|
Requires-Dist: cyclopts
|
|
16
17
|
Requires-Dist: httpx
|
|
17
18
|
Requires-Dist: humanize
|
|
@@ -102,6 +103,7 @@ Some interesting commands are the following:
|
|
|
102
103
|
- `monitor-task` Monitor a task's progress. Will exit with an exit status of 1 if the task did not complete successfully.
|
|
103
104
|
- `start-defi-vanguard-task` Start a Vanguard (static analysis) task for a specific version of a project.
|
|
104
105
|
- `start-picus-v2-task` Start a Picus V2 (Rust version) task for a module of a specific version of a project.
|
|
106
|
+
- `start-scout-task` Start a Scout scan for a specific version of a project.
|
|
105
107
|
|
|
106
108
|
> **Note:** all `ah start-...` commands support a `--wait` option that automatically invokes `ah monitor-task` on the newly started task, to wait for it to finish and exit with 0 on success or non-zero on failure.
|
|
107
109
|
|
|
@@ -80,6 +80,7 @@ Some interesting commands are the following:
|
|
|
80
80
|
- `monitor-task` Monitor a task's progress. Will exit with an exit status of 1 if the task did not complete successfully.
|
|
81
81
|
- `start-defi-vanguard-task` Start a Vanguard (static analysis) task for a specific version of a project.
|
|
82
82
|
- `start-picus-v2-task` Start a Picus V2 (Rust version) task for a module of a specific version of a project.
|
|
83
|
+
- `start-scout-task` Start a Scout scan for a specific version of a project.
|
|
83
84
|
|
|
84
85
|
> **Note:** all `ah start-...` commands support a `--wait` option that automatically invokes `ah monitor-task` on the newly started task, to wait for it to finish and exit with 0 on success or non-zero on failure.
|
|
85
86
|
|
|
@@ -23,6 +23,7 @@ from .scripts.monitor_task import monitor_task # noqa
|
|
|
23
23
|
from .scripts.qa_cleanup import qa_cleanup # noqa
|
|
24
24
|
from .scripts.start_orca_task import start_orca_task # noqa
|
|
25
25
|
from .scripts.start_picus_v2_task import start_picus_v2_task # noqa
|
|
26
|
+
from .scripts.start_scout_task import start_scout_task # noqa
|
|
26
27
|
from .scripts.start_vanguard_task import ( # noqa
|
|
27
28
|
start_defi_vanguard_task,
|
|
28
29
|
start_zk_vanguard_task,
|
|
@@ -57,9 +57,7 @@ def api_monitor_task(context: AuditHubContext, input: MonitorTaskArgs) -> bool:
|
|
|
57
57
|
status = task_message["status"]
|
|
58
58
|
if task_message["finished_at"]:
|
|
59
59
|
logger.info("Task finished with status: %s", status)
|
|
60
|
-
|
|
61
|
-
return True
|
|
62
|
-
return False
|
|
60
|
+
return status == "Succeeded"
|
|
63
61
|
if status == "Running":
|
|
64
62
|
logger.info("Task started")
|
|
65
63
|
elif status in {"Pending", "Queued"}:
|
|
@@ -107,8 +105,8 @@ def api_monitor_task(context: AuditHubContext, input: MonitorTaskArgs) -> bool:
|
|
|
107
105
|
)
|
|
108
106
|
elif kind == "TaskStepLogMessage":
|
|
109
107
|
print(f"[{task_message["step_code"]}] {task_message["entry"]}")
|
|
110
|
-
except ConnectionClosedOK
|
|
111
|
-
logger.info("Websocket client: All server logs are received."
|
|
112
|
-
except Exception
|
|
113
|
-
logger.exception(
|
|
108
|
+
except ConnectionClosedOK:
|
|
109
|
+
logger.info("Websocket client: All server logs are received.")
|
|
110
|
+
except Exception:
|
|
111
|
+
logger.exception("Failed to stream task logs")
|
|
114
112
|
return False
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
from dataclasses import dataclass
|
|
3
|
-
from datetime import datetime, timedelta
|
|
3
|
+
from datetime import UTC, datetime, timedelta
|
|
4
4
|
from typing import Optional
|
|
5
5
|
|
|
6
6
|
from ..library.auth import authentication_retry
|
|
@@ -16,7 +16,7 @@ class SendDigestNotificationsArgs:
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
def get_query_timestamp(days_to_include: int):
|
|
19
|
-
return (datetime.now(
|
|
19
|
+
return (datetime.now(UTC) - timedelta(days=days_to_include)).isoformat()
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
def api_send_digest_notifications(
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
1
|
import logging
|
|
3
2
|
from dataclasses import asdict, dataclass
|
|
4
3
|
from typing import Literal, Optional
|
|
@@ -128,9 +127,9 @@ def api_start_orca_task(
|
|
|
128
127
|
data = {
|
|
129
128
|
"name": input.name,
|
|
130
129
|
"parameters": asdict(input.parameters),
|
|
131
|
-
"specs_override":
|
|
130
|
+
"specs_override": [asdict(spec) for spec in input.specs],
|
|
132
131
|
"hints_override": (
|
|
133
|
-
|
|
132
|
+
[asdict(hint) for hint in input.hints] if input.hints else None
|
|
134
133
|
),
|
|
135
134
|
"deployment_script_path_override": input.deployment_script_path_override,
|
|
136
135
|
"on_chain": input.on_chain,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from dataclasses import asdict, dataclass
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from ..library.auth import authentication_retry
|
|
6
|
+
from ..library.context import AuditHubContext
|
|
7
|
+
from ..library.http import POST
|
|
8
|
+
from ..library.net_utils import ensure_success, response_json
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class ScoutParameters:
|
|
15
|
+
input_limit: Optional[list[str]] = None
|
|
16
|
+
extra_context: Optional[str] = None
|
|
17
|
+
generate_pocs: bool = False
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass
|
|
21
|
+
class StartScoutTaskArgs:
|
|
22
|
+
organization_id: int
|
|
23
|
+
project_id: int
|
|
24
|
+
version_id: int
|
|
25
|
+
budget: str
|
|
26
|
+
parameters: ScoutParameters
|
|
27
|
+
name: Optional[str] = None
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def api_start_scout_task(context: AuditHubContext, input: StartScoutTaskArgs):
|
|
31
|
+
logger.debug("Starting Scout")
|
|
32
|
+
data = {
|
|
33
|
+
"budget": input.budget,
|
|
34
|
+
"parameters": asdict(input.parameters),
|
|
35
|
+
}
|
|
36
|
+
if input.name is not None:
|
|
37
|
+
data["name"] = input.name
|
|
38
|
+
|
|
39
|
+
response = authentication_retry(
|
|
40
|
+
context,
|
|
41
|
+
POST,
|
|
42
|
+
url=f"{context.base_url}/organizations/{input.organization_id}/projects/{input.project_id}/versions/{input.version_id}/tools/agent",
|
|
43
|
+
json=data,
|
|
44
|
+
)
|
|
45
|
+
ensure_success(response)
|
|
46
|
+
return response_json(response)
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
1
|
import logging
|
|
3
2
|
from dataclasses import dataclass
|
|
4
3
|
from typing import Literal, Optional
|
|
@@ -55,7 +54,7 @@ class StartVanguardTaskArgs:
|
|
|
55
54
|
cross_version_triage: Optional[bool]
|
|
56
55
|
|
|
57
56
|
input_limit: Optional[list[str]]
|
|
58
|
-
tool_name: Literal["vanguard", "vanguard-v2", "zk-vanguard"]
|
|
57
|
+
tool_name: Literal["vanguard", "vanguard-v2", "zk-vanguard-v2"]
|
|
59
58
|
|
|
60
59
|
|
|
61
60
|
def api_start_vanguard_task(context: AuditHubContext, input: StartVanguardTaskArgs):
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
|
-
from typing import Tuple
|
|
3
2
|
|
|
4
3
|
from httpx import Client
|
|
5
4
|
|
|
@@ -11,7 +10,7 @@ from .ssl import get_verify_ssl
|
|
|
11
10
|
|
|
12
11
|
def download_from_url(
|
|
13
12
|
url: str, output_file: Path, timeout=DEFAULT_REQUEST_TIMEOUT
|
|
14
|
-
) ->
|
|
13
|
+
) -> tuple[int, str]:
|
|
15
14
|
"""This is a `curl -o`/`wget -O` equivalent"""
|
|
16
15
|
with Client(timeout=timeout, verify=get_verify_ssl(url)) as client:
|
|
17
16
|
with client.stream("GET", url) as response:
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from json import JSONDecodeError
|
|
2
2
|
from pathlib import Path
|
|
3
|
-
from typing import Tuple
|
|
4
3
|
|
|
5
4
|
from humanize import naturalsize
|
|
6
5
|
|
|
@@ -26,7 +25,7 @@ def response_json(response: Response):
|
|
|
26
25
|
) from None
|
|
27
26
|
|
|
28
27
|
|
|
29
|
-
def download_file(response: Response, output_file: Path) ->
|
|
28
|
+
def download_file(response: Response, output_file: Path) -> tuple[int, str]:
|
|
30
29
|
bytes_written = 0
|
|
31
30
|
with output_file.open("wb") as f:
|
|
32
31
|
for chunk in response.iter_bytes(chunk_size=8192):
|
|
@@ -20,7 +20,7 @@ def get_dict_of_fields_except(data_class_object, exceptions: set[str]) -> dict:
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
def instantiate_from_args(data_class: type, args: Namespace):
|
|
23
|
-
class_fields =
|
|
23
|
+
class_fields = {e.name for e in fields(data_class)}
|
|
24
24
|
return data_class(**{k: v for (k, v) in vars(args).items() if k in class_fields})
|
|
25
25
|
|
|
26
26
|
|
|
@@ -39,10 +39,8 @@ def add_folder_to_zip(
|
|
|
39
39
|
if current_root.name in excluded_directories:
|
|
40
40
|
continue
|
|
41
41
|
if any(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
current_root.relative_to(source_folder).parents,
|
|
45
|
-
)
|
|
42
|
+
str(p) in excluded_directories
|
|
43
|
+
for p in current_root.relative_to(source_folder).parents
|
|
46
44
|
):
|
|
47
45
|
continue
|
|
48
46
|
for file_name in files:
|
|
@@ -66,16 +66,15 @@ def get_task_info(
|
|
|
66
66
|
if exit_code == 0:
|
|
67
67
|
print("No findings reported by this task, exiting with 0")
|
|
68
68
|
if exit_code == 0 and check_completed:
|
|
69
|
-
for step in task_info.get("steps",
|
|
69
|
+
for step in task_info.get("steps", []):
|
|
70
70
|
completed = step.get("completed_without_timeout", None)
|
|
71
|
-
if completed is not None:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
)
|
|
71
|
+
if completed is not None and not completed:
|
|
72
|
+
exit_code = 2
|
|
73
|
+
print(
|
|
74
|
+
"Step",
|
|
75
|
+
step.get("code"),
|
|
76
|
+
"reported that it hit a timeout and could not complete its work",
|
|
77
|
+
)
|
|
79
78
|
|
|
80
79
|
logger.debug("Finished.")
|
|
81
80
|
sys.exit(exit_code)
|
{audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/start_picus_v2_task.py
RENAMED
|
@@ -29,7 +29,7 @@ def start_picus_v2_task(
|
|
|
29
29
|
Literal["cvc5", "cvc5-ff-int", "z3", "multi-solver", "z3bv", "bitwuzla"]
|
|
30
30
|
] = None,
|
|
31
31
|
solver_timeout: Optional[int] = None,
|
|
32
|
-
time_limit:
|
|
32
|
+
time_limit: int = 1800000,
|
|
33
33
|
assume_deterministic: Optional[list[str]] = None,
|
|
34
34
|
enable_debug: Optional[BooleanArg] = None,
|
|
35
35
|
wait: TaskWaitType = False,
|
|
@@ -56,11 +56,11 @@ def start_picus_v2_task(
|
|
|
56
56
|
z3bv is the z3 bitvector solver.
|
|
57
57
|
|
|
58
58
|
solver_timeout:
|
|
59
|
-
Timeout set for each solver query, in milliseconds (default
|
|
59
|
+
Timeout set for each solver query, in milliseconds (If not provided, default is 5 seconds).
|
|
60
60
|
|
|
61
61
|
time_limit:
|
|
62
62
|
Global timeout. If Picus takes longer than the time_limit provided then it will terminate.
|
|
63
|
-
Value in milliseconds (
|
|
63
|
+
Value in milliseconds (if set to 0, it means unlimited).
|
|
64
64
|
|
|
65
65
|
assume_deterministic:
|
|
66
66
|
An optional list of modules inside the selected source file.
|
|
@@ -79,7 +79,7 @@ def start_picus_v2_task(
|
|
|
79
79
|
source=source,
|
|
80
80
|
solver=solver,
|
|
81
81
|
solver_timeout=solver_timeout,
|
|
82
|
-
time_limit=time_limit,
|
|
82
|
+
time_limit=None if time_limit == 0 else time_limit,
|
|
83
83
|
assume_deterministic=assume_deterministic,
|
|
84
84
|
enable_debug=enable_debug,
|
|
85
85
|
)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import sys
|
|
3
|
+
from typing import Annotated, Optional
|
|
4
|
+
|
|
5
|
+
from cyclopts import Parameter
|
|
6
|
+
|
|
7
|
+
from ..api.get_configuration import api_get_configuration
|
|
8
|
+
from ..api.monitor_task import MonitorTaskArgs, api_monitor_task
|
|
9
|
+
from ..api.start_scout_task import (
|
|
10
|
+
ScoutParameters,
|
|
11
|
+
StartScoutTaskArgs,
|
|
12
|
+
api_start_scout_task,
|
|
13
|
+
)
|
|
14
|
+
from ..library.invocation_common import (
|
|
15
|
+
AuditHubContextType,
|
|
16
|
+
BooleanArg,
|
|
17
|
+
OrganizationIdType,
|
|
18
|
+
ProjectIdType,
|
|
19
|
+
TaskNameType,
|
|
20
|
+
TaskWaitType,
|
|
21
|
+
VersionIdType,
|
|
22
|
+
app,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
logger = logging.getLogger(__name__)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@app.command
|
|
29
|
+
def start_scout_task(
|
|
30
|
+
*,
|
|
31
|
+
organization_id: OrganizationIdType,
|
|
32
|
+
project_id: ProjectIdType,
|
|
33
|
+
version_id: VersionIdType,
|
|
34
|
+
budget: str,
|
|
35
|
+
name: TaskNameType = None,
|
|
36
|
+
input_limit: Annotated[
|
|
37
|
+
Optional[list[str]], Parameter(consume_multiple=True, negative_iterable=())
|
|
38
|
+
] = None,
|
|
39
|
+
extra_context: Optional[str] = None,
|
|
40
|
+
generate_pocs: BooleanArg = False,
|
|
41
|
+
wait: TaskWaitType = False,
|
|
42
|
+
rpc_context: AuditHubContextType,
|
|
43
|
+
):
|
|
44
|
+
"""
|
|
45
|
+
Start a Scout scan for a specific version of a project. Outputs the task id.
|
|
46
|
+
|
|
47
|
+
Parameters
|
|
48
|
+
----------
|
|
49
|
+
budget:
|
|
50
|
+
The name of the budget class to use. For valid names, run `ah get-configuration ai_budgets`.
|
|
51
|
+
|
|
52
|
+
input_limit:
|
|
53
|
+
Source files to process, with paths relative to the version root.
|
|
54
|
+
Files must be inside the project's src_path. If omitted, all files in src_path are processed.
|
|
55
|
+
|
|
56
|
+
extra_context:
|
|
57
|
+
Extra context for the scan, supplied as Markdown text.
|
|
58
|
+
|
|
59
|
+
generate_pocs
|
|
60
|
+
"""
|
|
61
|
+
try:
|
|
62
|
+
configuration = api_get_configuration(rpc_context)
|
|
63
|
+
supported_budgets = {e["name"] for e in configuration["ai_budgets"]}
|
|
64
|
+
if budget not in supported_budgets:
|
|
65
|
+
raise ValueError(f"'{budget}' is not a valid budget name.")
|
|
66
|
+
|
|
67
|
+
rpc_input = StartScoutTaskArgs(
|
|
68
|
+
organization_id=organization_id,
|
|
69
|
+
project_id=project_id,
|
|
70
|
+
version_id=version_id,
|
|
71
|
+
budget=budget,
|
|
72
|
+
name=name,
|
|
73
|
+
parameters=ScoutParameters(
|
|
74
|
+
input_limit=input_limit,
|
|
75
|
+
extra_context=extra_context,
|
|
76
|
+
generate_pocs=generate_pocs,
|
|
77
|
+
),
|
|
78
|
+
)
|
|
79
|
+
ret = api_start_scout_task(rpc_context, rpc_input)
|
|
80
|
+
task_id = ret["task_id"]
|
|
81
|
+
print(task_id)
|
|
82
|
+
if wait and not api_monitor_task(
|
|
83
|
+
rpc_context,
|
|
84
|
+
MonitorTaskArgs(organization_id=organization_id, task_id=task_id),
|
|
85
|
+
):
|
|
86
|
+
sys.exit(1)
|
|
87
|
+
except Exception as ex:
|
|
88
|
+
logger.error("Error %s", str(ex), exc_info=ex)
|
|
89
|
+
sys.exit(1)
|
{audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/start_vanguard_task.py
RENAMED
|
@@ -59,6 +59,8 @@ def decode_std_lib_custom_detector_from_string(e: str):
|
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
def validate_std_lib_custom_detector(_t, v):
|
|
62
|
+
if v is None:
|
|
63
|
+
return True
|
|
62
64
|
for e in v:
|
|
63
65
|
decode_std_lib_custom_detector_from_string(e)
|
|
64
66
|
return True
|
|
@@ -91,7 +93,7 @@ ZKDetectorType = Annotated[
|
|
|
91
93
|
validator=lambda _t, v: len(v) > 0,
|
|
92
94
|
consume_multiple=True,
|
|
93
95
|
negative_iterable=(),
|
|
94
|
-
help="One or more detector(s) to use for analyzing the sources. For a list of valid detector names, please run `ah get-configuration
|
|
96
|
+
help="One or more detector(s) to use for analyzing the sources. For a list of valid detector names, please run `ah get-configuration vanguard_v2_zk_detectors`.",
|
|
95
97
|
),
|
|
96
98
|
]
|
|
97
99
|
|
|
@@ -107,14 +109,14 @@ ZKInputLimitType = Annotated[
|
|
|
107
109
|
str,
|
|
108
110
|
Parameter(
|
|
109
111
|
negative_iterable=(),
|
|
110
|
-
help="
|
|
112
|
+
help="An LLZK source file to process.",
|
|
111
113
|
),
|
|
112
114
|
]
|
|
113
115
|
|
|
114
116
|
supported_detectors_keys = {
|
|
115
117
|
"vanguard": "vanguard_v2_defi_detectors",
|
|
116
118
|
"vanguard-v2": "vanguard_v2_defi_detectors",
|
|
117
|
-
"zk-vanguard": "
|
|
119
|
+
"zk-vanguard-v2": "vanguard_v2_zk_detectors",
|
|
118
120
|
}
|
|
119
121
|
|
|
120
122
|
|
|
@@ -130,14 +132,14 @@ def start_vanguard_common(
|
|
|
130
132
|
cross_version_triage: Optional[bool] = None,
|
|
131
133
|
wait: bool = False,
|
|
132
134
|
rpc_context: AuditHubContextType,
|
|
133
|
-
tool_name: Literal["vanguard", "vanguard-v2", "zk-vanguard"],
|
|
135
|
+
tool_name: Literal["vanguard", "vanguard-v2", "zk-vanguard-v2"],
|
|
134
136
|
):
|
|
135
137
|
try:
|
|
136
138
|
configuration = api_get_configuration(rpc_context)
|
|
137
139
|
|
|
138
|
-
supported_detectors =
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
supported_detectors = {
|
|
141
|
+
e["code"] for e in configuration[supported_detectors_keys[tool_name]]
|
|
142
|
+
}
|
|
141
143
|
for d in detector:
|
|
142
144
|
if d not in supported_detectors:
|
|
143
145
|
raise ValueError(f"'{d}' is not a valid detector name.")
|
|
@@ -181,10 +183,14 @@ def start_defi_vanguard_task(
|
|
|
181
183
|
version_id: VersionIdType,
|
|
182
184
|
name: TaskNameType = None,
|
|
183
185
|
cross_version_triage: CrossVersionTriageType = False,
|
|
184
|
-
detector: DefiV2DetectorType =
|
|
185
|
-
embedded_custom_detectors: DefiV2CustomDetectorFromVersionType =
|
|
186
|
-
std_lib_custom_detectors:
|
|
187
|
-
|
|
186
|
+
detector: Optional[DefiV2DetectorType] = None,
|
|
187
|
+
embedded_custom_detectors: Optional[DefiV2CustomDetectorFromVersionType] = None,
|
|
188
|
+
std_lib_custom_detectors: Optional[
|
|
189
|
+
DefiV2CustomDetectorFromStandardLibraryType
|
|
190
|
+
] = None,
|
|
191
|
+
org_lib_custom_detectors: Optional[
|
|
192
|
+
DefiV2CustomDetectorFromOrganizationLibraryType
|
|
193
|
+
] = None,
|
|
188
194
|
input_limit: DefiInputLimitType = None,
|
|
189
195
|
wait: TaskWaitType = False,
|
|
190
196
|
rpc_context: AuditHubContextType,
|
|
@@ -193,17 +199,25 @@ def start_defi_vanguard_task(
|
|
|
193
199
|
Start a DeFi Vanguard V2 (static analysis) task for a specific version of a project. Outputs the task id.
|
|
194
200
|
|
|
195
201
|
"""
|
|
202
|
+
if detector is None:
|
|
203
|
+
detector = []
|
|
204
|
+
|
|
196
205
|
custom_detectors: CustomDetectorsForTask = []
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
206
|
+
if embedded_custom_detectors:
|
|
207
|
+
for relative_path in embedded_custom_detectors:
|
|
208
|
+
custom_detectors.append(
|
|
209
|
+
CustomDetectorFromVersion(relative_path=relative_path)
|
|
210
|
+
)
|
|
211
|
+
if std_lib_custom_detectors:
|
|
212
|
+
for encoded_custom_detector in std_lib_custom_detectors:
|
|
213
|
+
custom_detectors.append(
|
|
214
|
+
decode_std_lib_custom_detector_from_string(encoded_custom_detector)
|
|
215
|
+
)
|
|
216
|
+
if org_lib_custom_detectors:
|
|
217
|
+
for custom_detector_id in org_lib_custom_detectors:
|
|
218
|
+
custom_detectors.append(
|
|
219
|
+
CustomDetectorFromOrganizationLibrary(id=custom_detector_id)
|
|
220
|
+
)
|
|
207
221
|
|
|
208
222
|
start_vanguard_common(
|
|
209
223
|
organization_id=organization_id,
|
|
@@ -233,7 +247,7 @@ def start_zk_vanguard_task(
|
|
|
233
247
|
rpc_context: AuditHubContextType,
|
|
234
248
|
):
|
|
235
249
|
"""
|
|
236
|
-
Start a ZK Vanguard (static analysis) task for a specific version of a project. Outputs the task id.
|
|
250
|
+
Start a ZK Vanguard v2 (static analysis) task for a specific version of a project. Outputs the task id.
|
|
237
251
|
|
|
238
252
|
"""
|
|
239
253
|
start_vanguard_common(
|
|
@@ -245,5 +259,5 @@ def start_zk_vanguard_task(
|
|
|
245
259
|
input_limit=[input_limit],
|
|
246
260
|
wait=wait,
|
|
247
261
|
rpc_context=rpc_context,
|
|
248
|
-
tool_name="zk-vanguard",
|
|
262
|
+
tool_name="zk-vanguard-v2",
|
|
249
263
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "audithub-client"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.2.0"
|
|
4
4
|
description = "A Python client that can access Veridise AuditHub via its REST API, providing CLI access"
|
|
5
5
|
authors = ["Nikos Chondros <nikos@veridise.com>"]
|
|
6
6
|
license = "AGPLv3"
|
|
@@ -33,6 +33,15 @@ pre-commit-hooks = "*"
|
|
|
33
33
|
profile = "black"
|
|
34
34
|
src_paths = ["audithub_client"]
|
|
35
35
|
|
|
36
|
+
[tool.ruff.lint]
|
|
37
|
+
extend-ignore = [
|
|
38
|
+
"C408", # Unnecessary collection constructor call.
|
|
39
|
+
"PLC0414", # Import alias is identical to the original name.
|
|
40
|
+
"PLW0602", # Global variable declared without assignment in the function.
|
|
41
|
+
"SIM117", # Nested with statements that can be combined into one.
|
|
42
|
+
"UP045", # Replace Optional[X] annotations with X | None.
|
|
43
|
+
]
|
|
44
|
+
|
|
36
45
|
|
|
37
46
|
[tool.poetry.scripts]
|
|
38
47
|
ah = "audithub_client.__main__:main"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/add_user_to_organization.py
RENAMED
|
File without changes
|
|
File without changes
|
{audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/create_temp_version_via_url.py
RENAMED
|
File without changes
|
{audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/create_version_via_url.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_my_organizations.py
RENAMED
|
File without changes
|
|
File without changes
|
{audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_organization_projects.py
RENAMED
|
File without changes
|
|
File without changes
|
{audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/api/get_organization_users.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/library/invocation_common.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/create_version_via_url.py
RENAMED
|
File without changes
|
{audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/get_configuration.py
RENAMED
|
File without changes
|
{audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/get_my_organizations.py
RENAMED
|
File without changes
|
|
File without changes
|
{audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/get_task_archive.py
RENAMED
|
File without changes
|
{audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/get_task_artifact.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{audithub_client-1.1.17 → audithub_client-1.2.0}/audithub_client/scripts/get_version_archive.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|