Skip to content

Commit 308049b

Browse files
authored
Merge pull request #80 from onekey-sec/upload-firmware-options
feat: extend upload-firmware with timeout/monitoring/label arguments
2 parents 0984af4 + 6128f5f commit 308049b

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

‎onekey_client/cli/firmware_upload.py‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@
3535
@click.option(
3636
"--sbom", help="Firmware SBOM", type=click.Path(exists=True, path_type=Path)
3737
)
38+
@click.option(
39+
"--timeout",
40+
help="Timeout for HTTP requests",
41+
type=click.IntRange(min=1, max=600),
42+
default=60,
43+
)
44+
@click.option("--monitoring", is_flag=True, default=False, help="Enable monitoring")
45+
@click.option("--label", multiple=True, help="Add a label (repeatable)")
3846
@click.argument(
3947
"filename", type=click.Path(exists=True, path_type=Path), required=False
4048
)
@@ -45,8 +53,11 @@ def upload_firmware(
4553
vendor_name: str,
4654
product_group_name: str,
4755
analysis_configuration_name: str,
56+
timeout: int,
57+
monitoring: bool,
4858
version: str | None,
4959
name: str | None,
60+
label: tuple[str],
5061
sbom: Path | None,
5162
filename: Path | None,
5263
):
@@ -75,11 +86,16 @@ def upload_firmware(
7586
product_group_id=product_group_id,
7687
version=version,
7788
analysis_configuration_id=analysis_configuration_id,
89+
labels=list(label),
7890
)
7991

8092
try:
8193
res = client.upload_firmware(
82-
metadata, filename, sbom_path=sbom, enable_monitoring=False
94+
metadata,
95+
filename,
96+
sbom_path=sbom,
97+
enable_monitoring=monitoring,
98+
timeout=timeout,
8399
)
84100
click.echo(res["id"])
85101
except QueryError as e:

‎onekey_client/client.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ def upload_firmware(
225225
"notes": metadata.notes,
226226
"enableMonitoring": enable_monitoring,
227227
"analysisConfigurationId": str(metadata.analysis_configuration_id),
228+
"labels": metadata.labels,
228229
},
229230
"vendorName": metadata.vendor_name,
230231
"productName": metadata.product_name,

‎onekey_client/models.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ class FirmwareMetadata(BaseModel):
1919
product_category: str | None = None
2020
product_group_id: UUID
2121
analysis_configuration_id: UUID
22+
labels: list[str] | None = None

0 commit comments

Comments
 (0)