audithub-client 1.1.16__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.
Files changed (73) hide show
  1. {audithub_client-1.1.16 → audithub_client-1.2.0}/PKG-INFO +19 -12
  2. {audithub_client-1.1.16 → audithub_client-1.2.0}/README.md +17 -11
  3. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/__main__.py +1 -0
  4. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/create_project.py +0 -1
  5. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/create_temp_version_via_local_archive.py +0 -1
  6. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/create_version_via_local_archive.py +0 -1
  7. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/get_latest_version.py +0 -1
  8. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/get_project.py +0 -1
  9. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/get_version_comments.py +0 -1
  10. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/monitor_task.py +5 -7
  11. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/put_organization_restrictions.py +0 -1
  12. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/send_digest.py +2 -2
  13. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/start_orca_task.py +4 -4
  14. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/start_picus_v2_task.py +0 -1
  15. audithub_client-1.2.0/audithub_client/api/start_scout_task.py +46 -0
  16. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/start_vanguard_task.py +1 -2
  17. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/library/auth.py +2 -1
  18. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/library/http_download.py +1 -2
  19. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/library/invocation_common.py +3 -3
  20. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/library/json_dump.py +2 -4
  21. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/library/net_utils.py +1 -2
  22. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/library/utils.py +1 -1
  23. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/scripts/create_version_via_local_archive.py +2 -4
  24. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/scripts/download_artifact.py +1 -1
  25. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/scripts/get_task_info.py +8 -9
  26. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/scripts/start_orca_task.py +5 -0
  27. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/scripts/start_picus_v2_task.py +4 -4
  28. audithub_client-1.2.0/audithub_client/scripts/start_scout_task.py +89 -0
  29. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/scripts/start_vanguard_task.py +37 -23
  30. {audithub_client-1.1.16 → audithub_client-1.2.0}/pyproject.toml +12 -1
  31. {audithub_client-1.1.16 → audithub_client-1.2.0}/LICENSE +0 -0
  32. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/__init__.py +0 -0
  33. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/__init__.py +0 -0
  34. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/add_user_to_organization.py +0 -0
  35. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/create_organization.py +0 -0
  36. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/create_temp_version_via_url.py +0 -0
  37. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/create_version_via_url.py +0 -0
  38. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/delete_organization.py +0 -0
  39. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/get_configuration.py +0 -0
  40. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/get_my_organizations.py +0 -0
  41. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/get_my_profile.py +0 -0
  42. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/get_organization_projects.py +0 -0
  43. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/get_organization_restrictions.py +0 -0
  44. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/get_organization_users.py +0 -0
  45. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/get_organizations.py +0 -0
  46. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/get_task_archive.py +0 -0
  47. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/get_task_artifact.py +0 -0
  48. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/get_task_info.py +0 -0
  49. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/get_task_logs.py +0 -0
  50. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/get_tasks.py +0 -0
  51. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/get_users.py +0 -0
  52. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/get_version_archive.py +0 -0
  53. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/models/__init__.py +0 -0
  54. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/qa_cleanup.py +0 -0
  55. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/api/remove_user_from_organization.py +0 -0
  56. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/library/__init__.py +0 -0
  57. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/library/context.py +0 -0
  58. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/library/http.py +0 -0
  59. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/library/logging_level.py +0 -0
  60. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/library/orca_utils.py +0 -0
  61. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/library/ssl.py +0 -0
  62. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/py.typed +0 -0
  63. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/scripts/create_version_via_url.py +0 -0
  64. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/scripts/get_configuration.py +0 -0
  65. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/scripts/get_my_organizations.py +0 -0
  66. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/scripts/get_my_profile.py +0 -0
  67. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/scripts/get_task_archive.py +0 -0
  68. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/scripts/get_task_artifact.py +0 -0
  69. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/scripts/get_task_logs.py +0 -0
  70. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/scripts/get_users.py +0 -0
  71. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/scripts/get_version_archive.py +0 -0
  72. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/scripts/monitor_task.py +0 -0
  73. {audithub_client-1.1.16 → audithub_client-1.2.0}/audithub_client/scripts/qa_cleanup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: audithub-client
3
- Version: 1.1.16
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
@@ -23,9 +24,14 @@ Description-Content-Type: text/markdown
23
24
  This is the AuditHub client, a Python module that allows programmatic access to Veridise AuditHub via its REST API.
24
25
 
25
26
  # Installing
27
+ - To install the CLI as a package, use a package manager such as `pip install audithub-client`
28
+
29
+ # Developing
26
30
  - Allocate and activate a venv, e.g., `python -m venv .venv && source .venv/bin/activate`
27
31
  - Make sure you have `poetry` installed. If it cannot be found globally, you can install it in the local venv with `pip install poetry`
28
32
  - Run `poetry install`
33
+ - If you are developing on top of this repository, install the git hooks with `poetry run pre-commit install`
34
+ - If you are developing on top of this repository, you can run the hooks manually across the repository with `poetry run pre-commit run --all-files`
29
35
 
30
36
  # Configuring
31
37
  All commands support configuration via command line arguments. Additionally, some arguments can also be specified as environment variables.
@@ -37,19 +43,19 @@ The required arguments for any API call are the following (the name inside the p
37
43
  - `dev`: https://keycloak.dev.veridise.tools/auth/realms/veridise/.well-known/openid-configuration
38
44
  - `production`: https://sso.veridise.com/auth/realms/veridise/.well-known/openid-configuration
39
45
  - `--oidc-client-id` (`AUDITHUB_OIDC_CLIENT_ID`): The OIDC client id (to be supplied by Veridise upon request)
40
- - `--oidc-client-secret` (`AUDITHUB_OIDC_CLIENT_SECRET`): The OIDC client secret (to be supplied by Veridise upon request).
46
+ - `--oidc-client-secret` (`AUDITHUB_OIDC_CLIENT_SECRET`): The OIDC client secret (to be supplied by Veridise upon request).
41
47
 
42
48
  Note: use `ah --help` to see the global arguments, applicable to all commands.
43
- Note: any logging output produced by the `ah` script is directed to stderr, so that output
49
+ Note: any logging output produced by the `ah` script is directed to stderr, so that output
44
50
 
45
51
  **Important**: please note that the `client_id` and `client_secret` pair should be considered sensitive information, as anyone with access to these can trigger AuditHub actions that account towards the usage limits of the organization that was issued these credentials.
46
52
 
47
- We suggest to set these arguments in the environment for ease of use.
48
- One approach is to use [direnv](https://direnv.net), for which we provide two sample files: `envrc-sample-dev` and `envrc-sample-production`.
53
+ We suggest to set these arguments in the environment for ease of use.
54
+ One approach is to use [direnv](https://direnv.net), for which we provide two sample files: `envrc-sample-dev` and `envrc-sample-production`.
49
55
  If you would like to use this utility, copy one of the samples corresponding to your target environment as `.envrc`, edit `.envrc` to fill in your credentials, and you can then use the below command line utilities.
50
56
 
51
57
  # Command line usage
52
- We offer a global `ah` script, that offers commands that make API calls.
58
+ We offer a global `ah` script, that offers commands that make API calls.
53
59
  Use `ah --help` to list all supported commands, as well as the global options that apply to all commands.
54
60
  To get help for a specific command, use `ah command --help`. For example: `ah get-task-info --help`.
55
61
 
@@ -70,7 +76,7 @@ This should output information about your user profile in AuditHub, and can help
70
76
 
71
77
 
72
78
  # API Usage
73
- If you would like to use this module as a library, utilized by your own Python code, you can import the corresponding function from the API call you are interested in.
79
+ If you would like to use this module as a library, utilized by your own Python code, you can import the corresponding function from the API call you are interested in.
74
80
  e.g., to invoke the `get_my_profile` function programmatically, you can do the following:
75
81
  ```python
76
82
  from audithub_client.api.get_my_profile import api_get_my_profile
@@ -79,16 +85,16 @@ from os import getenv
79
85
 
80
86
  # Fill in the corresponding values below
81
87
  rpc_context = AuditHubContext(
82
- base_url=getenv("AUDITHUB_BASE_URL"),
83
- oidc_configuration_url=getenv("AUDITHUB_OIDC_CONFIGURATION_URL"),
84
- oidc_client_id=getenv("AUDITHUB_OIDC_CLIENT_ID"),
88
+ base_url=getenv("AUDITHUB_BASE_URL"),
89
+ oidc_configuration_url=getenv("AUDITHUB_OIDC_CONFIGURATION_URL"),
90
+ oidc_client_id=getenv("AUDITHUB_OIDC_CLIENT_ID"),
85
91
  oidc_client_secret=getenv("AUDITHUB_OIDC_CLIENT_SECRET")
86
92
  )
87
93
  print(api_get_my_profile(rpc_context))
88
94
  ```
89
95
 
90
96
  # Script reference
91
- For a current script reference, please use `ah --help`.
97
+ For a current script reference, please use `ah --help`.
92
98
  Some interesting commands are the following:
93
99
  - `create-version-via-local-archive` Create a new version for a project by uploading a local .zip archive, or creating one on the fly from a local folder.
94
100
  - `create-version-via-url` Create a new version for a project by asking AuditHub to either download an archive or clone a Git repository.
@@ -97,6 +103,7 @@ Some interesting commands are the following:
97
103
  - `monitor-task` Monitor a task's progress. Will exit with an exit status of 1 if the task did not complete successfully.
98
104
  - `start-defi-vanguard-task` Start a Vanguard (static analysis) task for a specific version of a project.
99
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.
100
107
 
101
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.
102
109
 
@@ -142,5 +149,5 @@ Use `make image-versioned` to build an image tagger with both `latest` and the c
142
149
  Finally, use `make push` to push latest and `make push-versioned` to push the image tagger with the current version.
143
150
 
144
151
  As a side note, for `docker build --platform=linux/amd64,linux/arm64 ...` to work, the machine's container runtime needs to support multi-platform builds. Specifically for Docker, this requires switching from the "classic" image store to the containerd image store as outlined [here](https://docs.docker.com/build/building/multi-platform/).
145
- For Docker Desktop, you can set the "Use containerd for pulling and storing images" option in the user interface as described [here](https://docs.docker.com/desktop/features/containerd/).
152
+ For Docker Desktop, you can set the "Use containerd for pulling and storing images" option in the user interface as described [here](https://docs.docker.com/desktop/features/containerd/).
146
153
 
@@ -1,9 +1,14 @@
1
1
  This is the AuditHub client, a Python module that allows programmatic access to Veridise AuditHub via its REST API.
2
2
 
3
3
  # Installing
4
+ - To install the CLI as a package, use a package manager such as `pip install audithub-client`
5
+
6
+ # Developing
4
7
  - Allocate and activate a venv, e.g., `python -m venv .venv && source .venv/bin/activate`
5
8
  - Make sure you have `poetry` installed. If it cannot be found globally, you can install it in the local venv with `pip install poetry`
6
9
  - Run `poetry install`
10
+ - If you are developing on top of this repository, install the git hooks with `poetry run pre-commit install`
11
+ - If you are developing on top of this repository, you can run the hooks manually across the repository with `poetry run pre-commit run --all-files`
7
12
 
8
13
  # Configuring
9
14
  All commands support configuration via command line arguments. Additionally, some arguments can also be specified as environment variables.
@@ -15,19 +20,19 @@ The required arguments for any API call are the following (the name inside the p
15
20
  - `dev`: https://keycloak.dev.veridise.tools/auth/realms/veridise/.well-known/openid-configuration
16
21
  - `production`: https://sso.veridise.com/auth/realms/veridise/.well-known/openid-configuration
17
22
  - `--oidc-client-id` (`AUDITHUB_OIDC_CLIENT_ID`): The OIDC client id (to be supplied by Veridise upon request)
18
- - `--oidc-client-secret` (`AUDITHUB_OIDC_CLIENT_SECRET`): The OIDC client secret (to be supplied by Veridise upon request).
23
+ - `--oidc-client-secret` (`AUDITHUB_OIDC_CLIENT_SECRET`): The OIDC client secret (to be supplied by Veridise upon request).
19
24
 
20
25
  Note: use `ah --help` to see the global arguments, applicable to all commands.
21
- Note: any logging output produced by the `ah` script is directed to stderr, so that output
26
+ Note: any logging output produced by the `ah` script is directed to stderr, so that output
22
27
 
23
28
  **Important**: please note that the `client_id` and `client_secret` pair should be considered sensitive information, as anyone with access to these can trigger AuditHub actions that account towards the usage limits of the organization that was issued these credentials.
24
29
 
25
- We suggest to set these arguments in the environment for ease of use.
26
- One approach is to use [direnv](https://direnv.net), for which we provide two sample files: `envrc-sample-dev` and `envrc-sample-production`.
30
+ We suggest to set these arguments in the environment for ease of use.
31
+ One approach is to use [direnv](https://direnv.net), for which we provide two sample files: `envrc-sample-dev` and `envrc-sample-production`.
27
32
  If you would like to use this utility, copy one of the samples corresponding to your target environment as `.envrc`, edit `.envrc` to fill in your credentials, and you can then use the below command line utilities.
28
33
 
29
34
  # Command line usage
30
- We offer a global `ah` script, that offers commands that make API calls.
35
+ We offer a global `ah` script, that offers commands that make API calls.
31
36
  Use `ah --help` to list all supported commands, as well as the global options that apply to all commands.
32
37
  To get help for a specific command, use `ah command --help`. For example: `ah get-task-info --help`.
33
38
 
@@ -48,7 +53,7 @@ This should output information about your user profile in AuditHub, and can help
48
53
 
49
54
 
50
55
  # API Usage
51
- If you would like to use this module as a library, utilized by your own Python code, you can import the corresponding function from the API call you are interested in.
56
+ If you would like to use this module as a library, utilized by your own Python code, you can import the corresponding function from the API call you are interested in.
52
57
  e.g., to invoke the `get_my_profile` function programmatically, you can do the following:
53
58
  ```python
54
59
  from audithub_client.api.get_my_profile import api_get_my_profile
@@ -57,16 +62,16 @@ from os import getenv
57
62
 
58
63
  # Fill in the corresponding values below
59
64
  rpc_context = AuditHubContext(
60
- base_url=getenv("AUDITHUB_BASE_URL"),
61
- oidc_configuration_url=getenv("AUDITHUB_OIDC_CONFIGURATION_URL"),
62
- oidc_client_id=getenv("AUDITHUB_OIDC_CLIENT_ID"),
65
+ base_url=getenv("AUDITHUB_BASE_URL"),
66
+ oidc_configuration_url=getenv("AUDITHUB_OIDC_CONFIGURATION_URL"),
67
+ oidc_client_id=getenv("AUDITHUB_OIDC_CLIENT_ID"),
63
68
  oidc_client_secret=getenv("AUDITHUB_OIDC_CLIENT_SECRET")
64
69
  )
65
70
  print(api_get_my_profile(rpc_context))
66
71
  ```
67
72
 
68
73
  # Script reference
69
- For a current script reference, please use `ah --help`.
74
+ For a current script reference, please use `ah --help`.
70
75
  Some interesting commands are the following:
71
76
  - `create-version-via-local-archive` Create a new version for a project by uploading a local .zip archive, or creating one on the fly from a local folder.
72
77
  - `create-version-via-url` Create a new version for a project by asking AuditHub to either download an archive or clone a Git repository.
@@ -75,6 +80,7 @@ Some interesting commands are the following:
75
80
  - `monitor-task` Monitor a task's progress. Will exit with an exit status of 1 if the task did not complete successfully.
76
81
  - `start-defi-vanguard-task` Start a Vanguard (static analysis) task for a specific version of a project.
77
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.
78
84
 
79
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.
80
86
 
@@ -120,4 +126,4 @@ Use `make image-versioned` to build an image tagger with both `latest` and the c
120
126
  Finally, use `make push` to push latest and `make push-versioned` to push the image tagger with the current version.
121
127
 
122
128
  As a side note, for `docker build --platform=linux/amd64,linux/arm64 ...` to work, the machine's container runtime needs to support multi-platform builds. Specifically for Docker, this requires switching from the "classic" image store to the containerd image store as outlined [here](https://docs.docker.com/build/building/multi-platform/).
123
- For Docker Desktop, you can set the "Use containerd for pulling and storing images" option in the user interface as described [here](https://docs.docker.com/desktop/features/containerd/).
129
+ For Docker Desktop, you can set the "Use containerd for pulling and storing images" option in the user interface as described [here](https://docs.docker.com/desktop/features/containerd/).
@@ -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,
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env python3
2
1
  from dataclasses import dataclass
3
2
 
4
3
  from ..library.auth import authentication_retry
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env python3
2
1
  from dataclasses import dataclass
3
2
 
4
3
  from ..library.auth import authentication_retry
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env python3
2
1
  from dataclasses import dataclass
3
2
 
4
3
  from ..library.auth import authentication_retry
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env python3
2
1
  from dataclasses import dataclass
3
2
 
4
3
  from ..library.auth import authentication_retry
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env python3
2
1
  from dataclasses import dataclass
3
2
 
4
3
  from ..library.auth import authentication_retry
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env python3
2
1
  from dataclasses import dataclass
3
2
  from datetime import datetime
4
3
  from typing import Optional
@@ -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
- if status == "Succeeded":
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 as ex:
111
- logger.info("Websocket client: All server logs are received.", ex.reason)
112
- except Exception as ex: # pylint: disable=broad-exception-caught
113
- logger.exception(ex)
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,4 +1,3 @@
1
- #!/usr/bin/env python3
2
1
  from dataclasses import dataclass
3
2
 
4
3
  from ..library.auth import authentication_retry
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env python3
2
2
  from dataclasses import dataclass
3
- from datetime import datetime, timedelta, timezone
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(timezone.utc) - timedelta(days=days_to_include)).isoformat()
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
@@ -114,6 +113,7 @@ class StartOrCaTaskArgs:
114
113
  specs: list[VSpec]
115
114
  hints: Optional[list[Hint]]
116
115
  deployment_script_path_override: Optional[str]
116
+ auxiliary_deployment_script: Optional[str]
117
117
  on_chain: bool
118
118
  deployment_info_file: Optional[str]
119
119
 
@@ -127,16 +127,16 @@ def api_start_orca_task(
127
127
  data = {
128
128
  "name": input.name,
129
129
  "parameters": asdict(input.parameters),
130
- "specs_override": list([asdict(spec) for spec in input.specs]),
130
+ "specs_override": [asdict(spec) for spec in input.specs],
131
131
  "hints_override": (
132
- list([asdict(hint) for hint in input.hints]) if input.hints else None
132
+ [asdict(hint) for hint in input.hints] if input.hints else None
133
133
  ),
134
134
  "deployment_script_path_override": input.deployment_script_path_override,
135
135
  "on_chain": input.on_chain,
136
136
  "deployment_info_file": input.deployment_info_file,
137
+ "auxiliary_deployment_script": input.auxiliary_deployment_script,
137
138
  }
138
139
  logger.debug("Posting data: %s", data)
139
-
140
140
  response = authentication_retry(
141
141
  context,
142
142
  POST,
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env python3
2
1
  import logging
3
2
  from dataclasses import dataclass
4
3
  from typing import Optional
@@ -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,7 +1,8 @@
1
1
  import json
2
2
  import logging
3
3
  import time
4
- from typing import Callable, Optional
4
+ from collections.abc import Callable
5
+ from typing import Optional
5
6
 
6
7
  from httpx import Client, Timeout, get, post
7
8
 
@@ -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
- ) -> Tuple[int, str]:
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:
@@ -6,10 +6,10 @@ from .context import AuditHubContext
6
6
 
7
7
  app = App(
8
8
  help="""\
9
- This is the Veridise AuditHub CLI client, that allows access to AuditHub via its REST API.
10
- When you have Veridise AuditHub credentials, you can use this tool to,
9
+ This is the Veridise AuditHub CLI client, that allows access to AuditHub via its REST API.
10
+ When you have Veridise AuditHub credentials, you can use this tool to,
11
11
  e.g., create new versions for projects, launch Veridise tools, monitor their progress, and obtain the results.
12
- This tool can be used in CI/CD pipelines to assist in verifying new versions of projects.
12
+ This tool can be used in CI/CD pipelines to assist in verifying new versions of projects.
13
13
  """,
14
14
  )
15
15
 
@@ -7,11 +7,9 @@ from tabulate import tabulate
7
7
 
8
8
  OutputType = Annotated[
9
9
  Literal["raw", "json", "json-pretty", "pprint", "list", "table", "none"],
10
- Parameter(
11
- help="""\
10
+ Parameter(help="""\
12
11
  The output format. Options are: 'raw': Python print(), 'json': single-line JSON, 'json-pretty': multi-line JSON, 'pprint': Python pprint(), 'list': list element per line, 'table': tabular view, 'none': omit output completely.
13
- """
14
- ),
12
+ """),
15
13
  ]
16
14
 
17
15
 
@@ -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) -> Tuple[int, str]:
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 = set(map(lambda e: e.name, fields(data_class)))
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
- map(
43
- lambda p: str(p) in excluded_directories,
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:
@@ -63,7 +63,7 @@ def download_artifact(
63
63
  )
64
64
  matched_artifacts = [
65
65
  e
66
- for e in task_info.get("artifacts", list())
66
+ for e in task_info.get("artifacts", [])
67
67
  if e.get("step_code") == step_code and e.get("name") == name
68
68
  ]
69
69
  if len(matched_artifacts) > 1:
@@ -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", list()):
69
+ for step in task_info.get("steps", []):
70
70
  completed = step.get("completed_without_timeout", None)
71
- if completed is not None:
72
- if not completed:
73
- exit_code = 2
74
- print(
75
- "Step",
76
- step.get("code"),
77
- "reported that it hit a timeout and could not complete its work",
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)
@@ -49,6 +49,7 @@ def start_orca_task(
49
49
  ] = None,
50
50
  fork_network: Optional[str] = None,
51
51
  fork_block_number: Optional[int] = None,
52
+ auxiliary_deployment_script: Optional[str] = None,
52
53
  embedded_specs: Annotated[
53
54
  Optional[list[str]], Parameter(consume_multiple=True, negative_iterable=())
54
55
  ] = None,
@@ -116,6 +117,9 @@ def start_orca_task(
116
117
  deployment_script_path:
117
118
  An optional deployment script path to be used during deployment. If provided, it overrides the value set in project level.
118
119
 
120
+ auxiliary_deployment_script:
121
+ An optional deployment script path to be used during deployment for on chain fuzzing.
122
+
119
123
  on_chain:
120
124
  Specifies whether to enable on chain fuzzing.
121
125
 
@@ -196,6 +200,7 @@ def start_orca_task(
196
200
  deployment_script_path_override=deployment_script_path,
197
201
  on_chain=on_chain,
198
202
  deployment_info_file=deployment_info_file,
203
+ auxiliary_deployment_script=auxiliary_deployment_script,
199
204
  )
200
205
  logger.debug("Starting...")
201
206
  logger.debug(str(input))
@@ -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: Optional[int] = None,
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: 5000 ms).
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 (default: unlimited).
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)
@@ -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 vanguard_zk_detectors`.",
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="A circom source file to process.",
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": "vanguard_zk_detectors",
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 = set(
139
- [e["code"] for e in configuration[supported_detectors_keys[tool_name]]]
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 = list(),
185
- embedded_custom_detectors: DefiV2CustomDetectorFromVersionType = list(),
186
- std_lib_custom_detectors: DefiV2CustomDetectorFromStandardLibraryType = list(),
187
- org_lib_custom_detectors: DefiV2CustomDetectorFromOrganizationLibraryType = list(),
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
- for relative_path in embedded_custom_detectors:
198
- custom_detectors.append(CustomDetectorFromVersion(relative_path=relative_path))
199
- for encoded_custom_detector in std_lib_custom_detectors:
200
- custom_detectors.append(
201
- decode_std_lib_custom_detector_from_string(encoded_custom_detector)
202
- )
203
- for custom_detector_id in org_lib_custom_detectors:
204
- custom_detectors.append(
205
- CustomDetectorFromOrganizationLibrary(id=custom_detector_id)
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.1.16"
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"
@@ -26,11 +26,22 @@ isort = "*"
26
26
  ruff = "*"
27
27
  mypy = "*"
28
28
  types-tabulate = "*"
29
+ pre-commit = "*"
30
+ pre-commit-hooks = "*"
29
31
 
30
32
  [tool.isort]
31
33
  profile = "black"
32
34
  src_paths = ["audithub_client"]
33
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
+
34
45
 
35
46
  [tool.poetry.scripts]
36
47
  ah = "audithub_client.__main__:main"