Skip to main content

Contextal platform management library and tool

Project description

Contextal Python Package

This package provides a simple way to interact with Contextal Platform via API. It includes a Python library and command-line tools to perform essential tasks such as file uploads, scenario management, and retrieval of analysis results.

Installation

pip install contextal

Usage

Library example

Here's an example of how to use the library to upload a file and obtain the results from scenarios (if any):

from contextal import Config, Platform
from time import sleep

config = Config()
config.url = "http://contextal.my_company.lan"
#config.token = "my_token"
platform = Platform(config)
file = open("my_sample", "rb")
work = platform.submit_work(file)
sleep(1)
actions = platform.get_actions(work["work_id"])
print(actions)

Command line examples

# create default profile
ctx config create local_cloud http://contextal.my_company.lan --set-default
# create additional profile
ctx config create public_cloud https://contextal.my_company.com --token glpat-my-token
# upload file
ctx work submit my_sample --profile public_cloud
#upload file using default profile
ctx work submit my_sample
# check work results
ctx work graph MY_WORK_ID --pretty
# check scenarios results (i.e. the recommended actions) for a work
ctx work actions MY_WORK_ID --pretty

Add a new scenario:

ctx scenario add "-"<<EOF
{
    "action": "BLOCK",
    "creator": "me@my_company.com",
    "context": null,
    "description": "Block all mails containing windows link files",
    "local_query": "object_type=\"LNK\" && @has_root(object_type == \"Email\")",
    "max_ver": null,
    "min_ver": 1,
    "name": "MAIL_WITH_LNK"
}
EOF
# call the reload option to make Contextal Platform start using any new scenarios
ctx scenario reload

Scenarios can be downloaded and used as a backup or template for new ones:

ctx scenario details SCENARIO_ID > scenario1.backup
# modify scenario using jq command
cat scenario1.backup | jq '.name="MAIL_WITH_PE"|.local_query="object_type=\"PE\" && @has_root(object_type == \"Email\")"' > scenario2
# add scenario2
ctx scenario add scenario2
# call the reload option to make Contextal Platform start using any new scenarios
ctx scenario reload

License

This package is distributed under the MIT License. See the LICENSE.txt file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

contextal-0.0.1.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

contextal-0.0.1-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file contextal-0.0.1.tar.gz.

File metadata

  • Download URL: contextal-0.0.1.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for contextal-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d7f7981cf2c8d10c16b18773e0ded82cfb7fb7a12ffeb9b76144456c6cb3eb28
MD5 25addf0b076e3c96ad6fc267ef6c9a35
BLAKE2b-256 cadd6f46ed57d1920fa47fddfe35729d5ae193f67e22d150304c649e0a9b5e7f

See more details on using hashes here.

File details

Details for the file contextal-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: contextal-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for contextal-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0a8c41ae7ef55cd38354f06641a88979e6eb0fe5c4157c32584fac281004ab5e
MD5 00336cad3e7d614c7b165b3af96a5ff4
BLAKE2b-256 6c0ab00ebd54117a821a9093451321d739c788edbb4317a58bb846c7eff4d83a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page