Skip to main content

No project description provided

Project description

kfc2snow

This is a simple CLI that can be used to facilitate importing data from a Keyfactor Command Instance into a ServiceNow instance.

Installation

From Source

  1. Clone the repository
  2. Install poetry: pip install --upgrade pip && pip install poetry
  3. Install dependencies: poetry install
  4. Run the CLI: kfc2snow --help
git clone https://github.com/Keyfactor/kfc-inv-2-snow.git
cd kfc-inv-2-snow
pip install --upgrade pip && pip install poetry
poetry install
poetry run pip install .
poetry run kfc2snow --help

Usage

Environment Variables

You can use the following environmental variables to authenticate with Keyfactor Command and ServiceNow while using the kfc2snow CLI.

Keyfactor Command AD/Basic Auth

Below is an example of how to set the environment variables for Keyfactor Command using AD/Basic Auth.

export KEYFACTOR_HOSTNAME=keyfactor.example.com
export KEYFACTOR_USERNAME=User
export KEYFACTOR_PASSWORD=MyPassword
export KEYFACTOR_DOMAIN=EXAMPLEDOMAIN
export SNOW_INSTANCE=https://example.service-now.com
export SNOW_USERNAME=MySnowUser
export SNOW_PASSWORD=MySnowPassword

Keyfactor Command OAuth Identity Provider

Below is an example of how to set the environment variables for Keyfactor Command using an OAuth identity provider.

export KEYFACTOR_HOSTNAME=keyfactor.example.com
export COMMAND_IDP_TOKENURL=https://<idp host>/realms/<realm_name>/protocol/openid-connect/token
export COMMAND_IDP_CLIENTID=MyOauthCilentId
export COMMAND_IDP_CLIENTSECRET=MyOauthClientSecret
export SNOW_INSTANCE=https://example.service-now.com
export SNOW_USERNAME=MySnowUser
export SNOW_PASSWORD=MySnowPassword

Full Example

Below is an example of how to set the environment variables for Keyfactor Command using AD/Basic Auth and doing a "full" deployment and import to ServiceNow.

kfc2snow create-tables \
    --keyfactor-hostname keyfactor.example.com \
    --keyfactor-username User \
    --keyfactor-password MyPassword \
    --keyfactor-domain EXAMPLEDOMAIN \
    --snow-url https://example.service-now.com \
    --snow-username MySnowUser \
    --snow-password MySnowPassword

kfc2snow import-certs \
    --keyfactor-hostname keyfactor.example.com \
    --keyfactor-username User \
    --keyfactor-password MyPassword \
    --keyfactor-domain EXAMPLEDOMAIN \
    --snow-url https://example.service-now.com \
    --snow-username MySnowUser \
    --snow-password MySnowPassword

Commands

create-tables

This command will create the necessary tables in ServiceNow for the import process.

kfc2snow create-tables --help
Usage: kfc2snow create-tables [OPTIONS]

  Create a ServiceNow table for certificates

Options:
  --keyfactor-hostname TEXT       Keyfactor instance hostname
  --keyfactor-username TEXT       Keyfactor username
  --keyfactor-password TEXT       Keyfactor password
  --keyfactor-domain TEXT         Keyfactor domain (if using AD auth)
  --command-idp-tokenurl TEXT     IDP token URL (if using OAuth2)
  --command-idp-clientid TEXT     OAuth2 client ID
  --command-idp-clientsecret TEXT
                                  OAuth2 client secret
  --snow-url TEXT                 ServiceNow instance URL
  --snow-username TEXT            ServiceNow username
  --snow-password TEXT            ServiceNow password
  --app-prefix TEXT               Application prefix (optional)
  --field-prefix TEXT             Field prefix (optional)
  --import-table-name TEXT        The system name of the `import table` to
                                  create in Service Now (optional)
  --import-table-label TEXT       The canonical name/label of the `import
                                  table` to create in Service Now (optional)
  --sys-table-name TEXT           The system name of the `sys table` to create
                                  in Service Now (optional)
  --sys-table-label TEXT          The canonical name/label of the `sys table`
                                  to create in Service Now (optional)
  --sys-table-parent TEXT         The sys name of the `sys table` to base the
                                  `sys table` on in Service Now (optional)
  --help                          Show this message and exit.

Here's what the table can look like in ServiceNow: snow_import_table.png

bash

Example with all fields specified:

kfc2snow create-tables \
    --keyfactor-hostname $KEYFACTOR_HOSTNAME \
    --keyfactor-username $KEYFACTOR_USERNAME \
    --keyfactor-password $KEYFACTOR_PASSWORD \
    --keyfactor-domain $KEYFACTOR_DOMAIN \
    --snow-url $SNOW_URL \
    --snow-username $SNOW_USERNAME \
    --snow-password $SNOW_PASSWORD \
    --app-prefix "x_keyfa_app_" \
    --field-prefix "kfc_" \
    --import-table-name "certificates_import" \
    --import-table-label "Keyfactor Command Certificate Import" \
    --sys-table-name "certificate_inventory" \
    --sys-table-label "Keyfactor Command Certificates"

import-certs

This command will import certificates from Keyfactor Command into ServiceNow.

kfc2snow import-certs --help
Usage: kfc2snow import-certs [OPTIONS]

  Import certificates into ServiceNow

Options:
  --keyfactor-hostname TEXT       Keyfactor instance hostname
  --keyfactor-username TEXT       Keyfactor username
  --keyfactor-password TEXT       Keyfactor password
  --keyfactor-domain TEXT         Keyfactor domain (if using AD auth)
  --command-idp-tokenurl TEXT     IDP token URL (if using OAuth2)
  --command-idp-clientid TEXT     OAuth2 client ID
  --command-idp-clientsecret TEXT
                                  OAuth2 client secret
  --snow-url TEXT                 ServiceNow instance URL
  --snow-username TEXT            ServiceNow username
  --snow-password TEXT            ServiceNow password
  --app-prefix TEXT               Application prefix (optional)
  --field-prefix TEXT             Field prefix (optional)
  --import-table-name TEXT        The system name of the `import table` to
                                  create in Service Now (optional)
  --import-table-label TEXT       The canonical name/label of the `import
                                  table` to create in Service Now (optional)
  --sys-table-name TEXT           The system name of the `sys table` to create
                                  in Service Now (optional)
  --sys-table-label TEXT          The canonical name/label of the `sys table`
                                  to create in Service Now (optional)
  --sys-table-parent TEXT         The sys name of the `sys table` to base the
                                  `sys table` on in Service Now (optional)
  --help                          Show this message and exit.

Here's what imported certificate data can look like in ServiceNow: kfc_inv_snow_import_rows.png

bash

Example with all fields specified:

kfc2snow import-certs \
    --keyfactor-hostname $KEYFACTOR_HOSTNAME \
    --keyfactor-username $KEYFACTOR_USERNAME \
    --keyfactor-password $KEYFACTOR_PASSWORD \
    --keyfactor-domain $KEYFACTOR_DOMAIN \
    --snow-url $SNOW_URL \
    --snow-username $SNOW_USERNAME \
    --snow-password $SNOW_PASSWORD \
    --app-prefix "x_keyfa_app_" \
    --field-prefix "kfc_" \
    --import-table-name "certificates_import" \
    --import-table-label "Keyfactor Command Certificate Import" \
    --sys-table-name "certificate_inventory" \
    --sys-table-label "Keyfactor Command Certificates"

Debugging

To enable debugging, set the DEBUG environment variable to 1 or pass the --debug flag to the CLI.

kfc2snow --debug create-tables
kfc2snow --debug import-certs

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

kfc_2_snow-0.1.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

kfc_2_snow-0.1.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file kfc_2_snow-0.1.0.tar.gz.

File metadata

  • Download URL: kfc_2_snow-0.1.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for kfc_2_snow-0.1.0.tar.gz
Algorithm Hash digest
SHA256 15ba8e0850f239d8b45e9c14cebaee999b75297817f012d5aed99726756d9e70
MD5 7e994d73af490d1c9ed91c0d3841e23b
BLAKE2b-256 9fb2f58432824fc39e7aeba89e13881c912ae6f391a33233f312205fcc62aab5

See more details on using hashes here.

File details

Details for the file kfc_2_snow-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kfc_2_snow-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for kfc_2_snow-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6cf4fd065eea8c28fed6d434161e09931acdb46e225325b9f933a48f0ff0240a
MD5 625a342a977439afe25537a22bc71639
BLAKE2b-256 8b931eb1c074a221c7bee2fe1bede8fd79a5b45c54b83c45d5e62bd531aec02d

See more details on using hashes here.

Supported by

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