Skip to main content

Contextal Platform management library and tools.

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-1.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-1.0.1-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: contextal-1.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-1.0.1.tar.gz
Algorithm Hash digest
SHA256 5dd54fe276940a3cec25e2bdb4e9f8f52172f938670004afb0a22845bd4ef7ef
MD5 e768b918c3427f4dc05cc14e514ab80a
BLAKE2b-256 4bc9c1e649cc8493517326576b348a4824e699df1a62acbb9d0c24e3b8995f97

See more details on using hashes here.

File details

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

File metadata

  • Download URL: contextal-1.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-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 66698b99439282982f0bbac0441c28cced5147d7094fc00c6a9d5c7fe0275503
MD5 b5033c201c79255cf60c02add3883209
BLAKE2b-256 0f6ecfe7b76c1a976675acc8a07c030499bdd35f7434a4891f9b9383467787b8

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