pangea-sdk 6.2.0b2__py3-none-any.whl → 6.4.0__py3-none-any.whl
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.
- pangea/__init__.py +1 -1
- pangea/asyncio/request.py +25 -154
- pangea/asyncio/services/__init__.py +0 -1
- pangea/asyncio/services/ai_guard.py +40 -130
- pangea/asyncio/services/audit.py +1 -301
- pangea/asyncio/services/authn.py +7 -9
- pangea/asyncio/services/authz.py +45 -11
- pangea/asyncio/services/intel.py +20 -26
- pangea/asyncio/services/prompt_guard.py +2 -112
- pangea/asyncio/services/redact.py +4 -265
- pangea/asyncio/services/vault.py +52 -40
- pangea/request.py +30 -167
- pangea/response.py +6 -6
- pangea/services/__init__.py +0 -1
- pangea/services/ai_guard.py +96 -542
- pangea/services/audit/audit.py +2 -301
- pangea/services/audit/models.py +65 -307
- pangea/services/authn/authn.py +6 -8
- pangea/services/authn/models.py +183 -151
- pangea/services/authz.py +101 -57
- pangea/services/base.py +2 -3
- pangea/services/intel.py +32 -19
- pangea/services/prompt_guard.py +2 -193
- pangea/services/redact.py +7 -473
- pangea/services/vault/models/common.py +11 -12
- pangea/services/vault/models/keys.py +4 -9
- pangea/services/vault/models/secret.py +3 -8
- pangea/services/vault/vault.py +52 -40
- {pangea_sdk-6.2.0b2.dist-info → pangea_sdk-6.4.0.dist-info}/METADATA +34 -15
- pangea_sdk-6.4.0.dist-info/RECORD +60 -0
- pangea/asyncio/services/management.py +0 -576
- pangea/services/management.py +0 -720
- pangea_sdk-6.2.0b2.dist-info/RECORD +0 -62
- {pangea_sdk-6.2.0b2.dist-info → pangea_sdk-6.4.0.dist-info}/WHEEL +0 -0
pangea/services/audit/models.py
CHANGED
@@ -11,7 +11,7 @@ import enum
|
|
11
11
|
from typing import Any, Dict, List, Optional, Sequence, Union
|
12
12
|
|
13
13
|
from pydantic import Field
|
14
|
-
from typing_extensions import Annotated
|
14
|
+
from typing_extensions import Annotated
|
15
15
|
|
16
16
|
from pangea.response import APIRequestModel, APIResponseModel, PangeaDateTime, PangeaResponseResult
|
17
17
|
|
@@ -120,20 +120,25 @@ class Event(Dict[str, Any]):
|
|
120
120
|
|
121
121
|
|
122
122
|
class EventEnvelope(APIResponseModel):
|
123
|
-
|
124
|
-
Contain extra information about an event.
|
123
|
+
event: Optional[dict[str, Any]] = None
|
125
124
|
|
126
|
-
|
127
|
-
|
128
|
-
signature
|
129
|
-
|
130
|
-
|
125
|
+
signature: Optional[str] = None
|
126
|
+
"""
|
127
|
+
This is the signature of the hash of the canonicalized event that can be
|
128
|
+
verified with the public key provided in the public_key field. Signatures
|
129
|
+
cannot be used with the redaction feature turned on. If redaction is
|
130
|
+
required, the user needs to perform redaction before computing the signature
|
131
|
+
that is to be sent with the message. The SDK facilitates this for users.
|
131
132
|
"""
|
132
133
|
|
133
|
-
event: Dict[str, Any]
|
134
|
-
signature: Optional[str] = None
|
135
134
|
public_key: Optional[str] = None
|
136
|
-
|
135
|
+
"""
|
136
|
+
The base64-encoded ed25519 public key used for the signature, if one is
|
137
|
+
provided
|
138
|
+
"""
|
139
|
+
|
140
|
+
received_at: Optional[PangeaDateTime] = None
|
141
|
+
"""A Pangea provided timestamp of when the event was received."""
|
137
142
|
|
138
143
|
|
139
144
|
class LogRequest(APIRequestModel):
|
@@ -184,21 +189,28 @@ class LogBulkRequest(APIRequestModel):
|
|
184
189
|
|
185
190
|
|
186
191
|
class LogResult(PangeaResponseResult):
|
192
|
+
envelope: Optional[EventEnvelope] = None
|
187
193
|
"""
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
hash -- Event envelope hash.
|
192
|
-
unpublished_root -- The current unpublished root.
|
193
|
-
membership_proof -- A proof for verifying the unpublished root.
|
194
|
-
consistency_proof -- If prev_root was present in the request, this proof verifies that the new unpublished root is a continuation of the prev_root
|
194
|
+
The sealed envelope containing the event that was logged. Includes event
|
195
|
+
metadata such as optional client-side signature details and server-added
|
196
|
+
timestamps.
|
195
197
|
"""
|
196
198
|
|
197
|
-
|
198
|
-
hash
|
199
|
+
hash: Annotated[Optional[str], Field(max_length=64, min_length=64)] = None
|
200
|
+
"""The hash of the event data."""
|
201
|
+
|
199
202
|
unpublished_root: Optional[str] = None
|
203
|
+
"""The current unpublished root."""
|
204
|
+
|
200
205
|
membership_proof: Optional[str] = None
|
206
|
+
"""A proof for verifying that the buffer_root contains the received event"""
|
207
|
+
|
201
208
|
consistency_proof: Optional[List[str]] = None
|
209
|
+
"""
|
210
|
+
If prev_buffer_root was present in the request, this proof verifies that the
|
211
|
+
new unpublished root is a continuation of prev_unpublished_root
|
212
|
+
"""
|
213
|
+
|
202
214
|
consistency_verification: EventVerification = EventVerification.NONE
|
203
215
|
membership_verification: EventVerification = EventVerification.NONE
|
204
216
|
signature_verification: EventVerification = EventVerification.NONE
|
@@ -361,29 +373,47 @@ class RootResult(PangeaResponseResult):
|
|
361
373
|
|
362
374
|
|
363
375
|
class SearchEvent(APIResponseModel):
|
376
|
+
envelope: EventEnvelope
|
377
|
+
|
378
|
+
membership_proof: Optional[str] = None
|
379
|
+
"""A cryptographic proof that the record has been persisted in the log"""
|
380
|
+
|
381
|
+
hash: Annotated[Optional[str], Field(max_length=64, min_length=64)] = None
|
382
|
+
"""The record's hash"""
|
383
|
+
|
384
|
+
published: Optional[bool] = None
|
385
|
+
"""
|
386
|
+
If true, a root has been published after this event. If false, there is no
|
387
|
+
published root for this event
|
364
388
|
"""
|
365
|
-
Event information received after a search request
|
366
389
|
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
membership_proof -- A cryptographic proof that the record has been persisted in the log.
|
372
|
-
consistency_verification -- Consistency verification calculated if required.
|
373
|
-
membership_verification -- Membership verification calculated if required.
|
374
|
-
signature_verification -- Signature verification calculated if required.
|
375
|
-
fpe_context -- The context data needed to decrypt secure audit events that have been redacted with format preserving encryption.
|
390
|
+
imported: Optional[bool] = None
|
391
|
+
"""
|
392
|
+
If true, the even was imported manually and not logged by the standard
|
393
|
+
procedure. Some features such as tamper proofing may not be available
|
376
394
|
"""
|
377
395
|
|
378
|
-
envelope: EventEnvelope
|
379
|
-
hash: str
|
380
|
-
membership_proof: Optional[str] = None
|
381
|
-
published: Optional[bool] = None
|
382
396
|
leaf_index: Optional[int] = None
|
397
|
+
"""
|
398
|
+
The index of the leaf of the Merkle Tree where this record was inserted or
|
399
|
+
null if published=false
|
400
|
+
"""
|
401
|
+
|
402
|
+
valid_signature: Optional[bool] = None
|
403
|
+
"""
|
404
|
+
Result of the verification of the Vault signature, if the event was signed
|
405
|
+
and the parameter `verify_signature` is `true`
|
406
|
+
"""
|
407
|
+
|
408
|
+
fpe_context: Optional[str] = None
|
409
|
+
"""
|
410
|
+
The context data needed to decrypt secure audit events that have been
|
411
|
+
redacted with format preserving encryption.
|
412
|
+
"""
|
413
|
+
|
383
414
|
consistency_verification: EventVerification = EventVerification.NONE
|
384
415
|
membership_verification: EventVerification = EventVerification.NONE
|
385
416
|
signature_verification: EventVerification = EventVerification.NONE
|
386
|
-
fpe_context: Optional[str] = None
|
387
417
|
|
388
418
|
|
389
419
|
class SearchResultOutput(PangeaResponseResult):
|
@@ -502,275 +532,3 @@ class ExportRequest(APIRequestModel):
|
|
502
532
|
Whether or not to include the root hash of the tree and the membership proof
|
503
533
|
for each record.
|
504
534
|
"""
|
505
|
-
|
506
|
-
|
507
|
-
class AuditSchemaField(APIResponseModel):
|
508
|
-
"""A description of a field in an audit log."""
|
509
|
-
|
510
|
-
id: str
|
511
|
-
"""Prefix name / identity for the field."""
|
512
|
-
|
513
|
-
type: Literal["boolean", "datetime", "integer", "string", "string-unindexed", "text"]
|
514
|
-
"""The data type for the field."""
|
515
|
-
|
516
|
-
description: Optional[str] = None
|
517
|
-
"""Human display description of the field."""
|
518
|
-
|
519
|
-
name: Optional[str] = None
|
520
|
-
"""Human display name/title of the field."""
|
521
|
-
|
522
|
-
redact: Optional[bool] = None
|
523
|
-
"""If true, redaction is performed against this field (if configured.) Only valid for string type."""
|
524
|
-
|
525
|
-
required: Optional[bool] = None
|
526
|
-
"""If true, this field is required to exist in all logged events."""
|
527
|
-
|
528
|
-
size: Optional[int] = None
|
529
|
-
"""The maximum size of the field. Only valid for strings, which limits number of UTF-8 characters."""
|
530
|
-
|
531
|
-
ui_default_visible: Optional[bool] = None
|
532
|
-
"""If true, this field is visible by default in audit UIs."""
|
533
|
-
|
534
|
-
|
535
|
-
class AuditSchema(APIResponseModel):
|
536
|
-
"""A description of acceptable fields for an audit log."""
|
537
|
-
|
538
|
-
client_signable: Optional[bool] = None
|
539
|
-
"""If true, records contain fields to support client/vault signing."""
|
540
|
-
|
541
|
-
save_malformed: Optional[str] = None
|
542
|
-
"""Save (or reject) malformed AuditEvents."""
|
543
|
-
|
544
|
-
tamper_proofing: Optional[bool] = None
|
545
|
-
"""If true, records contain fields to support tamper-proofing."""
|
546
|
-
|
547
|
-
fields: Optional[List[AuditSchemaField]] = None
|
548
|
-
"""List of field definitions."""
|
549
|
-
|
550
|
-
|
551
|
-
class ForwardingConfiguration(APIResponseModel):
|
552
|
-
"""Configuration for forwarding audit logs to external systems."""
|
553
|
-
|
554
|
-
type: str
|
555
|
-
"""Type of forwarding configuration."""
|
556
|
-
|
557
|
-
forwarding_enabled: Optional[bool] = False
|
558
|
-
"""Whether forwarding is enabled."""
|
559
|
-
|
560
|
-
event_url: Optional[str] = None
|
561
|
-
"""URL where events will be written to. Must use HTTPS."""
|
562
|
-
|
563
|
-
ack_url: Optional[str] = None
|
564
|
-
"""If indexer acknowledgement is required, this must be provided along with a 'channel_id'."""
|
565
|
-
|
566
|
-
channel_id: Optional[str] = None
|
567
|
-
"""An optional splunk channel included in each request if indexer acknowledgement is required."""
|
568
|
-
|
569
|
-
public_cert: Optional[str] = None
|
570
|
-
"""Public certificate if a self signed TLS cert is being used."""
|
571
|
-
|
572
|
-
index: Optional[str] = None
|
573
|
-
"""Optional splunk index passed in the record bodies."""
|
574
|
-
|
575
|
-
vault_config_id: Optional[str] = None
|
576
|
-
"""The vault config used to store the HEC token."""
|
577
|
-
|
578
|
-
vault_secret_id: Optional[str] = None
|
579
|
-
"""The secret ID where the HEC token is stored in vault."""
|
580
|
-
|
581
|
-
|
582
|
-
class ServiceConfigV1(PangeaResponseResult):
|
583
|
-
"""Configuration options available for audit service"""
|
584
|
-
|
585
|
-
id: Optional[str] = None
|
586
|
-
"""The config ID"""
|
587
|
-
|
588
|
-
version: Literal[1] = 1
|
589
|
-
|
590
|
-
created_at: Optional[str] = None
|
591
|
-
"""The DB timestamp when this config was created. Ignored when submitted."""
|
592
|
-
|
593
|
-
updated_at: Optional[str] = None
|
594
|
-
"""The DB timestamp when this config was last updated at"""
|
595
|
-
|
596
|
-
name: Optional[str] = None
|
597
|
-
"""Configuration name"""
|
598
|
-
|
599
|
-
retention: Optional[str] = None
|
600
|
-
"""Retention window to store audit logs."""
|
601
|
-
|
602
|
-
cold_query_result_retention: Optional[str] = None
|
603
|
-
"""Retention window for cold query result / state information."""
|
604
|
-
|
605
|
-
hot_storage: Optional[str] = None
|
606
|
-
"""Retention window to keep audit logs in hot storage."""
|
607
|
-
|
608
|
-
query_result_retention: Optional[str] = None
|
609
|
-
"""Length of time to preserve server-side query result caching."""
|
610
|
-
|
611
|
-
redact_service_config_id: Optional[str] = None
|
612
|
-
"""A redact service config that will be used to redact PII from logs."""
|
613
|
-
|
614
|
-
redaction_fields: Optional[List[str]] = None
|
615
|
-
"""Fields to perform redaction against."""
|
616
|
-
|
617
|
-
vault_service_config_id: Optional[str] = None
|
618
|
-
"""A vault service config that will be used to sign logs."""
|
619
|
-
|
620
|
-
vault_key_id: Optional[str] = None
|
621
|
-
"""ID of the Vault key used for signing. If missing, use a default Audit key"""
|
622
|
-
|
623
|
-
vault_sign: Optional[bool] = None
|
624
|
-
"""Enable/disable event signing"""
|
625
|
-
|
626
|
-
|
627
|
-
class ServiceConfigV2(PangeaResponseResult):
|
628
|
-
"""Configuration options available for audit service"""
|
629
|
-
|
630
|
-
audit_schema: AuditSchema = Field(alias="schema")
|
631
|
-
"""Audit log field configuration. Only settable at create time."""
|
632
|
-
|
633
|
-
version: Literal[2] = 2
|
634
|
-
|
635
|
-
cold_query_result_retention: Optional[str] = None
|
636
|
-
"""Retention window for cold query result / state information."""
|
637
|
-
|
638
|
-
created_at: Optional[str] = None
|
639
|
-
"""The DB timestamp when this config was created. Ignored when submitted."""
|
640
|
-
|
641
|
-
hot_storage: Optional[str] = None
|
642
|
-
"""Retention window to keep audit logs in hot storage."""
|
643
|
-
|
644
|
-
id: Optional[str] = None
|
645
|
-
"""The config ID"""
|
646
|
-
|
647
|
-
name: Optional[str] = None
|
648
|
-
"""Configuration name"""
|
649
|
-
|
650
|
-
query_result_retention: Optional[str] = None
|
651
|
-
"""Length of time to preserve server-side query result caching."""
|
652
|
-
|
653
|
-
redact_service_config_id: Optional[str] = None
|
654
|
-
"""A redact service config that will be used to redact PII from logs."""
|
655
|
-
|
656
|
-
retention: Optional[str] = None
|
657
|
-
"""Retention window to store audit logs."""
|
658
|
-
|
659
|
-
updated_at: Optional[str] = None
|
660
|
-
"""The DB timestamp when this config was last updated at"""
|
661
|
-
|
662
|
-
vault_key_id: Optional[str] = None
|
663
|
-
"""ID of the Vault key used for signing. If missing, use a default Audit key"""
|
664
|
-
|
665
|
-
vault_service_config_id: Optional[str] = None
|
666
|
-
"""A vault service config that will be used to sign logs."""
|
667
|
-
|
668
|
-
vault_sign: Optional[bool] = None
|
669
|
-
"""Enable/disable event signing"""
|
670
|
-
|
671
|
-
forwarding_configuration: Optional[ForwardingConfiguration] = None
|
672
|
-
"""Configuration for forwarding audit logs to external systems."""
|
673
|
-
|
674
|
-
|
675
|
-
class ServiceConfigV3(PangeaResponseResult):
|
676
|
-
"""Configuration options available for audit service"""
|
677
|
-
|
678
|
-
audit_schema: AuditSchema = Field(alias="schema")
|
679
|
-
"""Audit log field configuration. Only settable at create time."""
|
680
|
-
|
681
|
-
version: Literal[3] = 3
|
682
|
-
"""Version of the service config."""
|
683
|
-
|
684
|
-
cold_storage: Optional[str] = None
|
685
|
-
"""Retention window for logs in cold storage. Deleted afterwards."""
|
686
|
-
|
687
|
-
created_at: Optional[str] = None
|
688
|
-
"""The DB timestamp when this config was created. Ignored when submitted."""
|
689
|
-
|
690
|
-
forwarding_configuration: Optional[ForwardingConfiguration] = None
|
691
|
-
"""Configuration for forwarding audit logs to external systems."""
|
692
|
-
|
693
|
-
hot_storage: Optional[str] = None
|
694
|
-
"""Retention window for logs in hot storage. Migrated to warm, cold, or deleted afterwards."""
|
695
|
-
|
696
|
-
id: Optional[str] = None
|
697
|
-
"""The config ID"""
|
698
|
-
|
699
|
-
name: Optional[str] = None
|
700
|
-
"""Configuration name"""
|
701
|
-
|
702
|
-
redact_service_config_id: Optional[str] = None
|
703
|
-
"""A redact service config that will be used to redact PII from logs."""
|
704
|
-
|
705
|
-
updated_at: Optional[str] = None
|
706
|
-
"""The DB timestamp when this config was last updated at"""
|
707
|
-
|
708
|
-
vault_key_id: Optional[str] = None
|
709
|
-
"""ID of the Vault key used for signing. If missing, use a default Audit key"""
|
710
|
-
|
711
|
-
vault_service_config_id: Optional[str] = None
|
712
|
-
"""A vault service config that will be used to sign logs."""
|
713
|
-
|
714
|
-
vault_sign: Optional[bool] = None
|
715
|
-
"""Enable/disable event signing"""
|
716
|
-
|
717
|
-
warm_storage: Optional[str] = None
|
718
|
-
"""Retention window for logs in warm storage. Migrated to cold or deleted afterwards."""
|
719
|
-
|
720
|
-
|
721
|
-
ServiceConfig = Annotated[
|
722
|
-
Union[ServiceConfigV1, ServiceConfigV2, ServiceConfigV3],
|
723
|
-
Field(discriminator="version"),
|
724
|
-
]
|
725
|
-
"""Configuration options available for audit service"""
|
726
|
-
|
727
|
-
|
728
|
-
class ServiceConfigFilter(APIRequestModel):
|
729
|
-
id: Optional[str] = None
|
730
|
-
"""Only records where id equals this value."""
|
731
|
-
|
732
|
-
id__contains: Optional[Sequence[str]] = None
|
733
|
-
"""Only records where id includes each substring."""
|
734
|
-
|
735
|
-
id__in: Optional[Sequence[str]] = None
|
736
|
-
"""Only records where id equals one of the provided substrings."""
|
737
|
-
|
738
|
-
created_at: Optional[str] = None
|
739
|
-
"""Only records where created_at equals this value."""
|
740
|
-
|
741
|
-
created_at__gt: Optional[str] = None
|
742
|
-
"""Only records where created_at is greater than this value."""
|
743
|
-
|
744
|
-
created_at__gte: Optional[str] = None
|
745
|
-
"""Only records where created_at is greater than or equal to this value."""
|
746
|
-
|
747
|
-
created_at__lt: Optional[str] = None
|
748
|
-
"""Only records where created_at is less than this value."""
|
749
|
-
|
750
|
-
created_at__lte: Optional[str] = None
|
751
|
-
"""Only records where created_at is less than or equal to this value."""
|
752
|
-
|
753
|
-
updated_at: Optional[str] = None
|
754
|
-
"""Only records where updated_at equals this value."""
|
755
|
-
|
756
|
-
updated_at__gt: Optional[str] = None
|
757
|
-
"""Only records where updated_at is greater than this value."""
|
758
|
-
|
759
|
-
updated_at__gte: Optional[str] = None
|
760
|
-
"""Only records where updated_at is greater than or equal to this value."""
|
761
|
-
|
762
|
-
updated_at__lt: Optional[str] = None
|
763
|
-
"""Only records where updated_at is less than this value."""
|
764
|
-
|
765
|
-
updated_at__lte: Optional[str] = None
|
766
|
-
"""Only records where updated_at is less than or equal to this value."""
|
767
|
-
|
768
|
-
|
769
|
-
class ServiceConfigListResult(PangeaResponseResult):
|
770
|
-
count: int
|
771
|
-
"""The total number of service configs matched by the list request."""
|
772
|
-
|
773
|
-
last: str
|
774
|
-
"""Used to fetch the next page of the current listing when provided in a repeated request's last parameter."""
|
775
|
-
|
776
|
-
items: Sequence[ServiceConfig]
|
pangea/services/authn/authn.py
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
|
7
7
|
from __future__ import annotations
|
8
8
|
|
9
|
+
from collections.abc import Mapping
|
9
10
|
from typing import Dict, List, Literal, Optional, Union
|
10
11
|
|
11
12
|
import pangea.services.authn.models as m
|
@@ -437,7 +438,7 @@ class AuthN(ServiceBase):
|
|
437
438
|
):
|
438
439
|
super().__init__(token, config, logger_name=logger_name)
|
439
440
|
|
440
|
-
def check(self, token:
|
441
|
+
def check(self, token: m.Token) -> PangeaResponse[m.ClientTokenCheckResult]:
|
441
442
|
"""
|
442
443
|
Check a token
|
443
444
|
|
@@ -446,7 +447,7 @@ class AuthN(ServiceBase):
|
|
446
447
|
OperationId: authn_post_v2_client_token_check
|
447
448
|
|
448
449
|
Args:
|
449
|
-
token
|
450
|
+
token: A token value
|
450
451
|
|
451
452
|
Returns:
|
452
453
|
A PangeaResponse with a token and its information in the response.result field.
|
@@ -458,10 +459,7 @@ class AuthN(ServiceBase):
|
|
458
459
|
token="ptu_wuk7tvtpswyjtlsx52b7yyi2l7zotv4a",
|
459
460
|
)
|
460
461
|
"""
|
461
|
-
|
462
|
-
return self.request.post(
|
463
|
-
"v2/client/token/check", m.ClientTokenCheckResult, data=input.model_dump(exclude_none=True)
|
464
|
-
)
|
462
|
+
return self.request.post("v2/client/token/check", m.ClientTokenCheckResult, data={"token": token})
|
465
463
|
|
466
464
|
class User(ServiceBase):
|
467
465
|
service_name = _SERVICE_NAME
|
@@ -481,7 +479,7 @@ class AuthN(ServiceBase):
|
|
481
479
|
def create(
|
482
480
|
self,
|
483
481
|
email: str,
|
484
|
-
profile:
|
482
|
+
profile: Mapping[str, str],
|
485
483
|
*,
|
486
484
|
username: str | None = None,
|
487
485
|
) -> PangeaResponse[m.UserCreateResult]:
|
@@ -868,7 +866,7 @@ class AuthN(ServiceBase):
|
|
868
866
|
|
869
867
|
def update(
|
870
868
|
self,
|
871
|
-
profile:
|
869
|
+
profile: Mapping[str, str],
|
872
870
|
id: str | None = None,
|
873
871
|
email: str | None = None,
|
874
872
|
*,
|