Package: pangea-sdk
Pangea Python SDKA Python SDK for integrating with Pangea services. Supports Python v3.7 and
above.InstallationVia pip:$pip3installpangea-sdkVia poetry:$poetryaddpangea-sdkUsageDocumentationExamplesGeneral usage would be to create a token for a service through thePangea Consoleand then construct an API client for that respective service.
The below example shows how this can be done forSecure Audit Logto log a
simple event:importosfrompangea.configimportPangeaConfigfrompangea.servicesimportAudit# Load client configuration from environment variables `PANGEA_AUDIT_TOKEN` and# `PANGEA_DOMAIN`.token=os.getenv("PANGEA_AUDIT_TOKEN")domain=os.getenv("PANGEA_DOMAIN")config=PangeaConfig(domain=domain)# Create a Secure Audit Log client.audit=Audit(token,config)# Log a basic event.response=audit.log(message="Hello, World!")asyncio supportasyncio support is available through thepangea.asyncio.servicesmodule. The
previous example may be rewritten to utilize async/await syntax like so:importasyncioimportosfrompangea.asyncio.servicesimportAuditAsyncfrompangea.configimportPangeaConfig# Load client configuration from environment variables `PANGEA_AUDIT_TOKEN` and# `PANGEA_DOMAIN`.token=os.getenv("PANGEA_AUDIT_TOKEN")domain=os.getenv("PANGEA_DOMAIN")config=PangeaConfig(domain=domain)# Create a Secure Audit Log client.audit=AuditAsync(token,config=config)asyncdefmain():# Log a basic event.response=awaitaudit.log(message="Hello, World!")awaitaudit.close()if__name__=="__main__":asyncio.run(main())Secure Audit Log - Integrity ToolsThe Python Pangea SDK also includes some extra features to validate Audit Service log's integrity. Here we explain how to run them.Verify audit dataVerify that an event or a list of events has not been tampered with. Usage:usage: python -m pangea.verify_audit [-h] [--file PATH]
or
usage: poetry run python -m pangea.verify_audit [-h] [--file PATH]

Pangea Audit Verifier

options:
  -h, --help            show this help message and exit
  --file PATH, -f PATH  Input file (default: standard input).It accepts multiple file formats:a Verification Artifact from the Pangea User Consolea search response from the REST API:$curl-H"Authorization: Bearer${PANGEA_TOKEN}"-XPOST-H'Content-Type: application/json'--data'{"verbose": true}'https://audit.aws.us.pangea.cloud/v1/searchBulk Download Audit DataDownload all audit logs for a given time range. Start and end date should be provided,
a variety of formats is supported, including ISO-8601. The result is stored in a
json file (one json per line).usage: python -m pangea.dump_audit [-h] [--token TOKEN] [--domain DOMAIN] [--output OUTPUT] start end
or
usage: poetry run python -m pangea.dump_audit [-h] [--token TOKEN] [--domain DOMAIN] [--output OUTPUT] start end

Pangea Audit Dump Tool

positional arguments:
  start                 Start timestamp. Supports a variety of formats, including ISO-8601. e.g.: 2023-06-05T18:05:15.030667Z
  end                   End timestamp. Supports a variety of formats, including ISO-8601. e.g.: 2023-06-05T18:05:15.030667Z

options:
  -h, --help            show this help message and exit
  --token TOKEN, -t TOKEN
                        Pangea token (default: env PANGEA_TOKEN)
  --domain DOMAIN, -d DOMAIN
                        Pangea base domain (default: env PANGEA_DOMAIN)
  --output OUTPUT, -o OUTPUT
                        Output file name. Default: dump-<timestamp>Perform Exhaustive Verification of Audit DataThis script performs extensive verification on a range of events of the log stream. Apart from verifying the hash
and the membership proof, it checks that there are no omissions in the stream, i.e. all the events are present and properly located.usage: python -m pangea.deep_verify [-h] [--token TOKEN] [--domain DOMAIN] --file FILE
or
usage: poetry run python -m pangea.deep_verify [-h] [--token TOKEN] [--domain DOMAIN] --file FILE

Pangea Audit Event Deep Verifier

options:
  -h, --help            show this help message and exit
  --token TOKEN, -t TOKEN
                        Pangea token (default: env PANGEA_TOKEN)
  --domain DOMAIN, -d DOMAIN
                        Pangea base domain (default: env PANGEA_DOMAIN)
  --file FILE, -f FILE  Event input file. Must be a collection of JSON Objects separated by newlinesIt accepts multiple file formats:a Verification Artifact from the Pangea User Consolea file generated by thedump_auditcommanda search response from the REST API (seeverify_audit)