Skip to content

Commit

Permalink
[client] Add markings support for upload pending api (#839)
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-julien authored Feb 13, 2025
1 parent 53a2461 commit 0de9da3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pycti/api/opencti_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,12 +712,13 @@ def upload_pending_file(self, **kwargs):
data = kwargs.get("data", None)
mime_type = kwargs.get("mime_type", "text/plain")
entity_id = kwargs.get("entity_id", None)
file_markings = kwargs.get("file_markings", [])

if file_name is not None:
self.app_logger.info("Uploading a file.")
query = """
mutation UploadPending($file: Upload!, $entityId: String) {
uploadPending(file: $file, entityId: $entityId) {
mutation UploadPending($file: Upload!, $entityId: String, $file_markings: [String!]) {
uploadPending(file: $file, entityId: $entityId, file_markings: $file_markings) {
id
name
}
Expand All @@ -731,7 +732,11 @@ def upload_pending_file(self, **kwargs):
mime_type = magic.from_file(file_name, mime=True)
return self.query(
query,
{"file": (File(file_name, data, mime_type)), "entityId": entity_id},
{
"file": (File(file_name, data, mime_type)),
"entityId": entity_id,
"file_markings": file_markings,
},
)
else:
self.app_logger.error("[upload] Missing parameter: file_name")
Expand Down
2 changes: 2 additions & 0 deletions pycti/connector/opencti_connector_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,7 @@ def send_stix2_bundle(self, bundle: str, **kwargs) -> list:
event_version = kwargs.get("event_version", None)
bypass_validation = kwargs.get("bypass_validation", False)
entity_id = kwargs.get("entity_id", None)
file_markings = kwargs.get("file_markings", None)
file_name = kwargs.get("file_name", None)
bundle_send_to_queue = kwargs.get("send_to_queue", self.bundle_send_to_queue)
cleanup_inconsistent_bundle = kwargs.get("cleanup_inconsistent_bundle", False)
Expand Down Expand Up @@ -1658,6 +1659,7 @@ def send_stix2_bundle(self, bundle: str, **kwargs) -> list:
data=bundle,
mime_type="application/json",
entity_id=entity_id,
file_markings=file_markings,
)
return []
elif validation_mode == "draft" and not draft_id:
Expand Down

0 comments on commit 0de9da3

Please sign in to comment.