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/asyncio/services/audit.py
CHANGED
@@ -8,10 +8,7 @@ from __future__ import annotations
|
|
8
8
|
|
9
9
|
import datetime
|
10
10
|
from collections.abc import Mapping
|
11
|
-
from typing import Any, Dict, Iterable, List, Optional, Sequence, Union
|
12
|
-
|
13
|
-
from pydantic import TypeAdapter
|
14
|
-
from typing_extensions import Literal
|
11
|
+
from typing import Any, Dict, Iterable, List, Optional, Sequence, Union
|
15
12
|
|
16
13
|
import pangea.exceptions as pexc
|
17
14
|
from pangea.asyncio.services.base import ServiceBaseAsync
|
@@ -20,13 +17,11 @@ from pangea.response import PangeaResponse, PangeaResponseResult
|
|
20
17
|
from pangea.services.audit.audit import AuditBase
|
21
18
|
from pangea.services.audit.exceptions import AuditException
|
22
19
|
from pangea.services.audit.models import (
|
23
|
-
AuditSchema,
|
24
20
|
DownloadFormat,
|
25
21
|
DownloadRequest,
|
26
22
|
DownloadResult,
|
27
23
|
Event,
|
28
24
|
ExportRequest,
|
29
|
-
ForwardingConfiguration,
|
30
25
|
LogBulkResult,
|
31
26
|
LogResult,
|
32
27
|
PublishedRoot,
|
@@ -39,9 +34,6 @@ from pangea.services.audit.models import (
|
|
39
34
|
SearchRequest,
|
40
35
|
SearchResultOutput,
|
41
36
|
SearchResultRequest,
|
42
|
-
ServiceConfig,
|
43
|
-
ServiceConfigFilter,
|
44
|
-
ServiceConfigListResult,
|
45
37
|
)
|
46
38
|
from pangea.services.audit.util import format_datetime
|
47
39
|
|
@@ -603,298 +595,6 @@ class AuditAsync(ServiceBaseAsync, AuditBase):
|
|
603
595
|
)
|
604
596
|
return await self.request.post("v1/download_results", DownloadResult, data=input.model_dump(exclude_none=True))
|
605
597
|
|
606
|
-
async def get_service_config(self, config_id: str) -> PangeaResponse[ServiceConfig]:
|
607
|
-
"""
|
608
|
-
Get a service config.
|
609
|
-
|
610
|
-
OperationId: audit_post_v1beta_config
|
611
|
-
|
612
|
-
Args:
|
613
|
-
id: The config ID
|
614
|
-
"""
|
615
|
-
|
616
|
-
response = await self.request.post("v1beta/config", PangeaResponseResult, data={"id": config_id})
|
617
|
-
response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
|
618
|
-
return cast(PangeaResponse[ServiceConfig], response)
|
619
|
-
|
620
|
-
@overload
|
621
|
-
async def create_service_config(
|
622
|
-
self,
|
623
|
-
version: Literal[1],
|
624
|
-
name: str,
|
625
|
-
*,
|
626
|
-
cold_query_result_retention: str | None = None,
|
627
|
-
hot_storage: str | None = None,
|
628
|
-
query_result_retention: str | None = None,
|
629
|
-
redact_service_config_id: str | None = None,
|
630
|
-
redaction_fields: Sequence[str] | None = None,
|
631
|
-
retention: str | None = None,
|
632
|
-
vault_key_id: str | None = None,
|
633
|
-
vault_service_config_id: str | None = None,
|
634
|
-
vault_sign: bool | None = None,
|
635
|
-
) -> PangeaResponse[ServiceConfig]:
|
636
|
-
"""
|
637
|
-
Create a v1 service config.
|
638
|
-
|
639
|
-
OperationId: audit_post_v1beta_config_create
|
640
|
-
|
641
|
-
Args:
|
642
|
-
name: Configuration name
|
643
|
-
cold_query_result_retention: Retention window for cold query result / state information.
|
644
|
-
hot_storage: Retention window to keep audit logs in hot storage.
|
645
|
-
query_result_retention: Length of time to preserve server-side query result caching.
|
646
|
-
redact_service_config_id: A redact service config that will be used to redact PII from logs.
|
647
|
-
redaction_fields: Fields to perform redaction against.
|
648
|
-
retention: Retention window to store audit logs.
|
649
|
-
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
650
|
-
vault_service_config_id: A vault service config that will be used to sign logs.
|
651
|
-
vault_sign: Enable/disable event signing.
|
652
|
-
"""
|
653
|
-
|
654
|
-
@overload
|
655
|
-
async def create_service_config(
|
656
|
-
self,
|
657
|
-
version: Literal[2],
|
658
|
-
name: str,
|
659
|
-
*,
|
660
|
-
schema: AuditSchema,
|
661
|
-
cold_query_result_retention: str | None = None,
|
662
|
-
forwarding_configuration: ForwardingConfiguration | None = None,
|
663
|
-
hot_storage: str | None = None,
|
664
|
-
query_result_retention: str | None = None,
|
665
|
-
redact_service_config_id: str | None = None,
|
666
|
-
retention: str | None = None,
|
667
|
-
vault_key_id: str | None = None,
|
668
|
-
vault_service_config_id: str | None = None,
|
669
|
-
vault_sign: bool | None = None,
|
670
|
-
) -> PangeaResponse[ServiceConfig]:
|
671
|
-
"""
|
672
|
-
Create a v2 service config.
|
673
|
-
|
674
|
-
OperationId: audit_post_v1beta_config_create
|
675
|
-
|
676
|
-
Args:
|
677
|
-
name: Configuration name
|
678
|
-
schema: Audit log field configuration. Only settable at create time.
|
679
|
-
cold_query_result_retention: Retention window for cold query result / state information.
|
680
|
-
forwarding_configuration: Configuration for forwarding audit logs to external systems.
|
681
|
-
hot_storage: Retention window to keep audit logs in hot storage.
|
682
|
-
query_result_retention: Length of time to preserve server-side query result caching.
|
683
|
-
redact_service_config_id: A redact service config that will be used to redact PII from logs.
|
684
|
-
retention: Retention window to store audit logs.
|
685
|
-
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
686
|
-
vault_service_config_id: A vault service config that will be used to sign logs.
|
687
|
-
vault_sign: Enable/disable event signing.
|
688
|
-
"""
|
689
|
-
|
690
|
-
@overload
|
691
|
-
async def create_service_config(
|
692
|
-
self,
|
693
|
-
version: Literal[3],
|
694
|
-
name: str,
|
695
|
-
*,
|
696
|
-
schema: AuditSchema,
|
697
|
-
cold_storage: str | None = None,
|
698
|
-
hot_storage: str | None = None,
|
699
|
-
warm_storage: str | None = None,
|
700
|
-
redact_service_config_id: str | None = None,
|
701
|
-
vault_service_config_id: str | None = None,
|
702
|
-
vault_key_id: str | None = None,
|
703
|
-
vault_sign: bool | None = None,
|
704
|
-
forwarding_configuration: ForwardingConfiguration | None = None,
|
705
|
-
) -> PangeaResponse[ServiceConfig]:
|
706
|
-
"""
|
707
|
-
Create a v3 service config.
|
708
|
-
|
709
|
-
OperationId: audit_post_v1beta_config_create
|
710
|
-
|
711
|
-
Args:
|
712
|
-
name: Configuration name
|
713
|
-
schema: Audit log field configuration. Only settable at create time.
|
714
|
-
cold_storage: Retention window for logs in cold storage. Deleted afterwards.
|
715
|
-
hot_storage: Retention window for logs in hot storage. Migrated to warm, cold, or deleted afterwards.
|
716
|
-
warm_storage: Retention window for logs in warm storage. Migrated to cold or deleted afterwards.
|
717
|
-
redact_service_config_id: A redact service config that will be used to redact PII from logs.
|
718
|
-
vault_service_config_id: A vault service config that will be used to sign logs.
|
719
|
-
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
720
|
-
vault_sign: Enable/disable event signing.
|
721
|
-
forwarding_configuration: Configuration for forwarding audit logs to external systems.
|
722
|
-
"""
|
723
|
-
|
724
|
-
async def create_service_config(
|
725
|
-
self,
|
726
|
-
version: Literal[1, 2, 3],
|
727
|
-
name: str,
|
728
|
-
*,
|
729
|
-
cold_query_result_retention: str | None = None,
|
730
|
-
cold_storage: str | None = None,
|
731
|
-
forwarding_configuration: ForwardingConfiguration | None = None,
|
732
|
-
hot_storage: str | None = None,
|
733
|
-
query_result_retention: str | None = None,
|
734
|
-
redact_service_config_id: str | None = None,
|
735
|
-
redaction_fields: Sequence[str] | None = None,
|
736
|
-
retention: str | None = None,
|
737
|
-
schema: AuditSchema | None = None,
|
738
|
-
vault_key_id: str | None = None,
|
739
|
-
vault_service_config_id: str | None = None,
|
740
|
-
vault_sign: bool | None = None,
|
741
|
-
warm_storage: str | None = None,
|
742
|
-
) -> PangeaResponse[ServiceConfig]:
|
743
|
-
"""
|
744
|
-
Create a service config.
|
745
|
-
|
746
|
-
OperationId: audit_post_v1beta_config_create
|
747
|
-
|
748
|
-
Args:
|
749
|
-
name: Configuration name
|
750
|
-
cold_query_result_retention: Retention window for cold query result / state information.
|
751
|
-
cold_storage: Retention window for logs in cold storage. Deleted afterwards.
|
752
|
-
forwarding_configuration: Configuration for forwarding audit logs to external systems.
|
753
|
-
hot_storage: Retention window to keep audit logs in hot storage.
|
754
|
-
query_result_retention: Length of time to preserve server-side query result caching.
|
755
|
-
redact_service_config_id: A redact service config that will be used to redact PII from logs.
|
756
|
-
redaction_fields: Fields to perform redaction against.
|
757
|
-
retention: Retention window to store audit logs.
|
758
|
-
schema: Audit log field configuration. Only settable at create time.
|
759
|
-
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
760
|
-
vault_service_config_id: A vault service config that will be used to sign logs.
|
761
|
-
vault_sign: Enable/disable event signing.
|
762
|
-
warm_storage: Retention window for logs in warm storage. Migrated to cold or deleted afterwards.
|
763
|
-
"""
|
764
|
-
|
765
|
-
response = await self.request.post(
|
766
|
-
"v1beta/config/create",
|
767
|
-
PangeaResponseResult,
|
768
|
-
data={
|
769
|
-
"cold_query_result_retention": cold_query_result_retention,
|
770
|
-
"cold_storage": cold_storage,
|
771
|
-
"forwarding_configuration": forwarding_configuration,
|
772
|
-
"hot_storage": hot_storage,
|
773
|
-
"name": name,
|
774
|
-
"query_result_retention": query_result_retention,
|
775
|
-
"redact_service_config_id": redact_service_config_id,
|
776
|
-
"redaction_fields": redaction_fields,
|
777
|
-
"retention": retention,
|
778
|
-
"schema": schema,
|
779
|
-
"vault_key_id": vault_key_id,
|
780
|
-
"vault_service_config_id": vault_service_config_id,
|
781
|
-
"vault_sign": vault_sign,
|
782
|
-
"warm_storage": warm_storage,
|
783
|
-
"version": version,
|
784
|
-
},
|
785
|
-
)
|
786
|
-
response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
|
787
|
-
return cast(PangeaResponse[ServiceConfig], response)
|
788
|
-
|
789
|
-
async def update_service_config(
|
790
|
-
self,
|
791
|
-
config_id: str,
|
792
|
-
*,
|
793
|
-
name: str,
|
794
|
-
updated_at: datetime.datetime,
|
795
|
-
# Optionals.
|
796
|
-
cold_query_result_retention: str | None = None,
|
797
|
-
cold_storage: str | None = None,
|
798
|
-
forwarding_configuration: ForwardingConfiguration | None = None,
|
799
|
-
hot_storage: str | None = None,
|
800
|
-
query_result_retention: str | None = None,
|
801
|
-
redact_service_config_id: str | None = None,
|
802
|
-
retention: str | None = None,
|
803
|
-
schema: AuditSchema | None = None,
|
804
|
-
vault_key_id: str | None = None,
|
805
|
-
vault_service_config_id: str | None = None,
|
806
|
-
vault_sign: bool | None = None,
|
807
|
-
warm_storage: str | None = None,
|
808
|
-
) -> PangeaResponse[ServiceConfig]:
|
809
|
-
"""
|
810
|
-
Update a service config.
|
811
|
-
|
812
|
-
OperationId: audit_post_v1beta_config_update
|
813
|
-
|
814
|
-
Args:
|
815
|
-
id: The config ID
|
816
|
-
name: Configuration name
|
817
|
-
updated_at: The DB timestamp when this config was last updated at
|
818
|
-
cold_query_result_retention: Retention window for cold query result / state information.
|
819
|
-
cold_storage: Retention window for logs in cold storage. Deleted afterwards.
|
820
|
-
forwarding_configuration: Configuration for forwarding audit logs to external systems
|
821
|
-
hot_storage: Retention window to keep audit logs in hot storage
|
822
|
-
query_result_retention: Length of time to preserve server-side query result caching
|
823
|
-
redact_service_config_id: A redact service config that will be used to redact PII from logs
|
824
|
-
retention: Retention window to store audit logs
|
825
|
-
schema: Audit log field configuration
|
826
|
-
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
827
|
-
vault_service_config_id: A vault service config that will be used to sign logs
|
828
|
-
vault_sign: Enable/disable event signing
|
829
|
-
warm_storage: Retention window for logs in warm storage. Migrated to cold or deleted afterwards.
|
830
|
-
"""
|
831
|
-
|
832
|
-
response = await self.request.post(
|
833
|
-
"v1beta/config/update",
|
834
|
-
PangeaResponseResult,
|
835
|
-
data={
|
836
|
-
"id": config_id,
|
837
|
-
"name": name,
|
838
|
-
"updated_at": updated_at,
|
839
|
-
# Optionals.
|
840
|
-
"cold_query_result_retention": cold_query_result_retention,
|
841
|
-
"cold_storage": cold_storage,
|
842
|
-
"forwarding_configuration": forwarding_configuration,
|
843
|
-
"hot_storage": hot_storage,
|
844
|
-
"query_result_retention": query_result_retention,
|
845
|
-
"redact_service_config_id": redact_service_config_id,
|
846
|
-
"retention": retention,
|
847
|
-
"schema": schema,
|
848
|
-
"vault_key_id": vault_key_id,
|
849
|
-
"vault_service_config_id": vault_service_config_id,
|
850
|
-
"vault_sign": vault_sign,
|
851
|
-
"warm_storage": warm_storage,
|
852
|
-
},
|
853
|
-
)
|
854
|
-
response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
|
855
|
-
return cast(PangeaResponse[ServiceConfig], response)
|
856
|
-
|
857
|
-
async def delete_service_config(self, config_id: str) -> PangeaResponse[ServiceConfig]:
|
858
|
-
"""
|
859
|
-
Delete a service config.
|
860
|
-
|
861
|
-
OperationId: audit_post_v1beta_config_delete
|
862
|
-
|
863
|
-
Args:
|
864
|
-
id: The config ID
|
865
|
-
"""
|
866
|
-
|
867
|
-
response = await self.request.post("v1beta/config/delete", PangeaResponseResult, data={"id": config_id})
|
868
|
-
response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
|
869
|
-
return cast(PangeaResponse[ServiceConfig], response)
|
870
|
-
|
871
|
-
async def list_service_configs(
|
872
|
-
self,
|
873
|
-
*,
|
874
|
-
filter: ServiceConfigFilter | None = None,
|
875
|
-
last: str | None = None,
|
876
|
-
order: Literal["asc", "desc"] | None = None,
|
877
|
-
order_by: Literal["id", "created_at", "updated_at"] | None = None,
|
878
|
-
size: int | None = None,
|
879
|
-
) -> PangeaResponse[ServiceConfigListResult]:
|
880
|
-
"""
|
881
|
-
List service configs.
|
882
|
-
|
883
|
-
OperationId: audit_post_v1beta_config_list
|
884
|
-
|
885
|
-
Args:
|
886
|
-
last: Reflected value from a previous response to obtain the next page of results.
|
887
|
-
order: Order results asc(ending) or desc(ending).
|
888
|
-
order_by: Which field to order results by.
|
889
|
-
size: Maximum results to include in the response.
|
890
|
-
"""
|
891
|
-
|
892
|
-
return await self.request.post(
|
893
|
-
"v1beta/config/list",
|
894
|
-
ServiceConfigListResult,
|
895
|
-
data={"filter": filter, "last": last, "order": order, "order_by": order_by, "size": size},
|
896
|
-
)
|
897
|
-
|
898
598
|
async def update_published_roots(self, result: SearchResultOutput):
|
899
599
|
"""Fetches series of published root hashes from Arweave
|
900
600
|
|
pangea/asyncio/services/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
|
@@ -436,7 +437,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
436
437
|
) -> None:
|
437
438
|
super().__init__(token, config, logger_name=logger_name)
|
438
439
|
|
439
|
-
async def check(self, token:
|
440
|
+
async def check(self, token: m.Token) -> PangeaResponse[m.ClientTokenCheckResult]:
|
440
441
|
"""
|
441
442
|
Check a token
|
442
443
|
|
@@ -445,7 +446,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
445
446
|
OperationId: authn_post_v2_client_token_check
|
446
447
|
|
447
448
|
Args:
|
448
|
-
token
|
449
|
+
token: A token value
|
449
450
|
|
450
451
|
Returns:
|
451
452
|
A PangeaResponse with a token and its information in the response.result field.
|
@@ -453,14 +454,11 @@ class AuthNAsync(ServiceBaseAsync):
|
|
453
454
|
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/client/token/check-post).
|
454
455
|
|
455
456
|
Examples:
|
456
|
-
response = authn.client.token_endpoints.check(
|
457
|
+
response = await authn.client.token_endpoints.check(
|
457
458
|
token="ptu_wuk7tvtpswyjtlsx52b7yyi2l7zotv4a",
|
458
459
|
)
|
459
460
|
"""
|
460
|
-
|
461
|
-
return await self.request.post(
|
462
|
-
"v2/client/token/check", m.ClientTokenCheckResult, data=input.model_dump(exclude_none=True)
|
463
|
-
)
|
461
|
+
return await self.request.post("v2/client/token/check", m.ClientTokenCheckResult, data={"token": token})
|
464
462
|
|
465
463
|
class UserAsync(ServiceBaseAsync):
|
466
464
|
service_name = _SERVICE_NAME
|
@@ -479,7 +477,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
479
477
|
async def create(
|
480
478
|
self,
|
481
479
|
email: str,
|
482
|
-
profile:
|
480
|
+
profile: Mapping[str, str],
|
483
481
|
*,
|
484
482
|
username: str | None = None,
|
485
483
|
) -> PangeaResponse[m.UserCreateResult]:
|
@@ -870,7 +868,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
870
868
|
|
871
869
|
async def update(
|
872
870
|
self,
|
873
|
-
profile:
|
871
|
+
profile: Mapping[str, str],
|
874
872
|
id: str | None = None,
|
875
873
|
email: str | None = None,
|
876
874
|
*,
|
pangea/asyncio/services/authz.py
CHANGED
@@ -3,13 +3,15 @@
|
|
3
3
|
|
4
4
|
from __future__ import annotations
|
5
5
|
|
6
|
+
from collections.abc import Mapping, Sequence
|
6
7
|
from typing import Any
|
7
8
|
|
8
9
|
from pangea.asyncio.services.base import ServiceBaseAsync
|
9
10
|
from pangea.config import PangeaConfig
|
10
11
|
from pangea.response import PangeaResponse
|
11
12
|
from pangea.services.authz import (
|
12
|
-
|
13
|
+
BulkCheckRequestItem,
|
14
|
+
BulkCheckResult,
|
13
15
|
CheckResult,
|
14
16
|
ItemOrder,
|
15
17
|
ListResourcesRequest,
|
@@ -19,7 +21,6 @@ from pangea.services.authz import (
|
|
19
21
|
Resource,
|
20
22
|
Subject,
|
21
23
|
Tuple,
|
22
|
-
TupleCreateRequest,
|
23
24
|
TupleCreateResult,
|
24
25
|
TupleDeleteRequest,
|
25
26
|
TupleDeleteResult,
|
@@ -73,7 +74,7 @@ class AuthZAsync(ServiceBaseAsync):
|
|
73
74
|
|
74
75
|
super().__init__(token, config, logger_name, config_id=config_id)
|
75
76
|
|
76
|
-
async def tuple_create(self, tuples:
|
77
|
+
async def tuple_create(self, tuples: Sequence[Tuple]) -> PangeaResponse[TupleCreateResult]:
|
77
78
|
"""Create tuples.
|
78
79
|
|
79
80
|
Create tuples in the AuthZ Service. The request will fail if there is no schema
|
@@ -102,10 +103,7 @@ class AuthZAsync(ServiceBaseAsync):
|
|
102
103
|
)
|
103
104
|
"""
|
104
105
|
|
105
|
-
|
106
|
-
return await self.request.post(
|
107
|
-
"v1/tuple/create", TupleCreateResult, data=input_data.model_dump(exclude_none=True)
|
108
|
-
)
|
106
|
+
return await self.request.post("v1/tuple/create", TupleCreateResult, data={"tuples": tuples})
|
109
107
|
|
110
108
|
async def tuple_list(
|
111
109
|
self,
|
@@ -190,8 +188,8 @@ class AuthZAsync(ServiceBaseAsync):
|
|
190
188
|
Check if a subject has permission to perform an action on the resource.
|
191
189
|
|
192
190
|
Args:
|
193
|
-
resource
|
194
|
-
action
|
191
|
+
resource: The resource to check.
|
192
|
+
action: The action to check.
|
195
193
|
subject: The subject to check.
|
196
194
|
debug: Setting this value to True will provide a detailed analysis of the check.
|
197
195
|
attributes: Additional attributes for the check.
|
@@ -213,8 +211,44 @@ class AuthZAsync(ServiceBaseAsync):
|
|
213
211
|
)
|
214
212
|
"""
|
215
213
|
|
216
|
-
|
217
|
-
|
214
|
+
return await self.request.post(
|
215
|
+
"v1/check",
|
216
|
+
CheckResult,
|
217
|
+
data={"resource": resource, "action": action, "subject": subject, "debug": debug, "attributes": attributes},
|
218
|
+
)
|
219
|
+
|
220
|
+
async def bulk_check(
|
221
|
+
self,
|
222
|
+
checks: Sequence[BulkCheckRequestItem],
|
223
|
+
*,
|
224
|
+
debug: bool | None = None,
|
225
|
+
attributes: Mapping[str, Any] | None = None,
|
226
|
+
) -> PangeaResponse[BulkCheckResult]:
|
227
|
+
"""Perform a bulk check request
|
228
|
+
|
229
|
+
Perform multiple checks in a single request to see if a subjects have
|
230
|
+
permission to do actions on the resources.
|
231
|
+
|
232
|
+
Args:
|
233
|
+
checks: Check requests to perform.
|
234
|
+
debug: In the event of an allowed check, return a path that granted access.
|
235
|
+
attributes: A JSON object of attribute data.
|
236
|
+
|
237
|
+
Examples:
|
238
|
+
await authz.bulk_check(
|
239
|
+
checks=[
|
240
|
+
BulkCheckRequestItem(
|
241
|
+
resource=Resource(type="file", id="file_1"),
|
242
|
+
action="read",
|
243
|
+
subject=Subject(type="user", id="user_1", action="read"),
|
244
|
+
)
|
245
|
+
]
|
246
|
+
)
|
247
|
+
"""
|
248
|
+
|
249
|
+
return await self.request.post(
|
250
|
+
"v1/check/bulk", BulkCheckResult, data={"checks": checks, "debug": debug, "attributes": attributes}
|
251
|
+
)
|
218
252
|
|
219
253
|
async def list_resources(
|
220
254
|
self, type: str, action: str, subject: Subject, attributes: dict[str, Any] | None = None
|
pangea/asyncio/services/intel.py
CHANGED
@@ -3,9 +3,10 @@
|
|
3
3
|
|
4
4
|
# TODO: Modernize.
|
5
5
|
# ruff: noqa: UP006, UP035
|
6
|
+
from __future__ import annotations
|
6
7
|
|
7
8
|
import hashlib
|
8
|
-
from typing import List, Optional
|
9
|
+
from typing import List, Literal, Optional
|
9
10
|
|
10
11
|
import pangea.services.intel as m
|
11
12
|
from pangea.asyncio.services.base import ServiceBaseAsync
|
@@ -77,11 +78,11 @@ class FileIntelAsync(ServiceBaseAsync):
|
|
77
78
|
|
78
79
|
async def hash_reputation_bulk(
|
79
80
|
self,
|
80
|
-
hashes:
|
81
|
-
hash_type:
|
82
|
-
provider:
|
83
|
-
verbose:
|
84
|
-
raw:
|
81
|
+
hashes: list[str],
|
82
|
+
hash_type: Literal["sha256", "sha", "md5"],
|
83
|
+
provider: Literal["reversinglabs", "crowdstrike"] | None = None,
|
84
|
+
verbose: bool | None = None,
|
85
|
+
raw: bool | None = None,
|
85
86
|
) -> PangeaResponse[m.FileReputationBulkResult]:
|
86
87
|
"""
|
87
88
|
Reputation check
|
@@ -89,11 +90,11 @@ class FileIntelAsync(ServiceBaseAsync):
|
|
89
90
|
Retrieve hash-based file reputation from a provider, including an optional detailed report.
|
90
91
|
|
91
92
|
Args:
|
92
|
-
hashes
|
93
|
-
hash_type
|
94
|
-
provider
|
95
|
-
verbose
|
96
|
-
raw
|
93
|
+
hashes: The hash of each file to be looked up
|
94
|
+
hash_type: One of "sha256", "sha", "md5"
|
95
|
+
provider: Use reputation data from these providers: "reversinglabs" or "crowdstrike"
|
96
|
+
verbose: Echo the API parameters in the response
|
97
|
+
raw: Include raw data from this provider
|
97
98
|
|
98
99
|
Raises:
|
99
100
|
PangeaAPIException: If an API Error happens
|
@@ -101,12 +102,8 @@ class FileIntelAsync(ServiceBaseAsync):
|
|
101
102
|
Returns:
|
102
103
|
A PangeaResponse where the sanctioned source(s) are in the
|
103
104
|
response.result field. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/file-intel).
|
104
|
-
|
105
|
-
Examples:
|
106
|
-
FIXME:
|
107
|
-
|
108
105
|
"""
|
109
|
-
input = m.FileReputationBulkRequest(
|
106
|
+
input = m.FileReputationBulkRequest(
|
110
107
|
hashes=hashes, hash_type=hash_type, verbose=verbose, raw=raw, provider=provider
|
111
108
|
)
|
112
109
|
return await self.request.post(
|
@@ -158,8 +155,8 @@ class FileIntelAsync(ServiceBaseAsync):
|
|
158
155
|
|
159
156
|
async def filepath_reputation_bulk(
|
160
157
|
self,
|
161
|
-
filepaths:
|
162
|
-
provider:
|
158
|
+
filepaths: list[str],
|
159
|
+
provider: Literal["reversinglabs", "crowdstrike"] | None = None,
|
163
160
|
verbose: Optional[bool] = None,
|
164
161
|
raw: Optional[bool] = None,
|
165
162
|
) -> PangeaResponse[m.FileReputationBulkResult]:
|
@@ -172,10 +169,10 @@ class FileIntelAsync(ServiceBaseAsync):
|
|
172
169
|
OperationId: file_intel_post_v1_reputation
|
173
170
|
|
174
171
|
Args:
|
175
|
-
filepaths
|
176
|
-
provider
|
177
|
-
verbose
|
178
|
-
raw
|
172
|
+
filepaths: The path list to the files to be looked up
|
173
|
+
provider: Use reputation data from these providers: "reversinglabs" or "crowdstrike"
|
174
|
+
verbose: Echo the API parameters in the response
|
175
|
+
raw: Include raw data from this provider
|
179
176
|
|
180
177
|
Raises:
|
181
178
|
PangeaAPIException: If an API Error happens
|
@@ -183,9 +180,6 @@ class FileIntelAsync(ServiceBaseAsync):
|
|
183
180
|
Returns:
|
184
181
|
A PangeaResponse where the sanctioned source(s) are in the
|
185
182
|
response.result field. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/file-intel).
|
186
|
-
|
187
|
-
Examples:
|
188
|
-
FIXME:
|
189
183
|
"""
|
190
184
|
hashes = []
|
191
185
|
for filepath in filepaths:
|
@@ -321,7 +315,7 @@ class DomainIntelAsync(ServiceBaseAsync):
|
|
321
315
|
provider="whoisxml",
|
322
316
|
)
|
323
317
|
"""
|
324
|
-
input = m.DomainWhoIsRequest(domain=domain, verbose=verbose, provider=provider, raw=raw)
|
318
|
+
input = m.DomainWhoIsRequest(domain=domain, verbose=verbose, provider=provider, raw=raw)
|
325
319
|
return await self.request.post("v1/whois", m.DomainWhoIsResult, data=input.model_dump(exclude_none=True))
|
326
320
|
|
327
321
|
|