Server
RegScale-CLI Server and API Wrapper
Introduction
This document provides a guide to running the RegScale-CLI in Server mode which provides both a GUI for uploading certain files and REST API wrapper to interact with the CLI by using HTTP requests instead of command-line interfaces.
What is it?
The RegScale-CLI Server provides:
- a REST API service for the RegScale-CLI through which any command that can be executed via the
regscale
CLI application can be accessed either via aGET
command (if no arguments are expected) or aPOST
command (if arguments are expected) - a GUI for uploading STIG files and other files to the platform for users who prefer a GUI over the commandline.
Why would you use it?
Operations using the RegScale-CLI can be reduced to GET
and POST
requests to your local machine or to a machine running the API Wrapper. This allows users to remotely call RegScale-CLI commands with an HTTP request rather than manually running the commands. The primary use case is for scheduling or automating RegScale-CLI commands and provides users with familiarity with REST APIs the ability to control RegScale-CLI via REST API requests through curl
, python
, Postman, etc.
To access the certain uploads via a browser interface.
Installation
RegScale-CLI must be installed with the server extra to add the additional required libraries. Install the RegScale-CLI "server" package using pip:
pip install "regscale-cli[server]"
Instructions
Use the following command to start up the CLI-Server.
regscale-rest
The following will appear in the terminal indicating the CLI is operating in Server mode using Flask.
Running on http://127.0.0.1:5555/
Swagger docs at http://127.0.0.1:5555/swagger/
Press CTRL+C to quit
Use the following command to start up the CLI-Server running in the background on Unix.
regscale-rest &
To run CLI-Server persistently on a remote Unix host, open up the desired port on the Unix host and start the RegScale-Server in the background (or through your preferred mechanism).
# Logged into remote unix host
# Open port 8000 on unix host
export REGSCALE_FLASK_PORT=8000
regscale-rest &
Features
When running in a directory initialized for use with RegScale-CLI, i.e. the presence of a configured or configurable init.yaml,
- REST API interface: The wrapper provides a REST API interface to the Click-based Python CLI, allowing for interaction via standard HTTP methods like POST and GET.
- Parameter passing: Parameters for the commands can be passed in the body of a POST request. This allows for dynamic and flexible command execution.
- No parameter GET requests: For commands that do not require parameters, GET requests can be used.
Usage
By default, the Flask REST API is started via regscale-rest
and all commands are endpoints. For example, below is the output of regscale about
run via the API interface using a curl
command.
> curl --silent localhost:5555/about | jq -r .output
.';;;;;;;;;;;;;;;;;;;;;;;;;,'..
.:lllllllllllllllllllllllllllllc:'.
.cliclicliclicliclicliclicliclooool;.
.cliclic###################;:looooooc'
.clicli, .;loooool'
.clicli, .:oolloc.
.clicli, .,cli,. .clllll,
.clicli. .,oxxxxd; .:lllll;
..cli. ';cdxxxxxo, .cllllc,
.:odddddddc. .;ccccc:.
..'. .;ldddddddl' .':ccccc:.
;xOOkl. 'coddddddl,. .;::::::;.
'x0000O: .:oooooool;. .,::::::;'.
'xO00OO: .;loooooo:,. .';::;::;'.
'xOOOOOc.'cllllllc' .,;;;;;;,.
'xOOOOOo:clllllc'. ';;;;;;'.
'xOOOOOdccccc:,. .',,,,'''.
'dOOOOkdc:::,. ..''''''..
'dkkkkko:;,. .''''','..
'dkkkkkl,. .''',,,'.
.lkkkkx;. ..',,,,.
.;cc:' .....
RegScale CLI Version: 5.7.0
Author: J. Travis Howerton ([email protected])
Copyright: RegScale Incorporated
Pre-Requisite: Python 3.9 or later
Website: https://www.regscale.com
Read the CLI Docs: https://regscale.readme.io/docs/overview
DISCLAIMER: RegScale does not conduct any form of security scanning for data imported by the customer. It is the customer's responsibility to ensure that data imported into the
platform using the Command Line Interface meets industry standard, minimum security screening requirements. RegScale has no liability for failing to scan any such data or for
any data imported by the customer that fails to meet such requirements.
Notice that we are piping to jq
to extract the output
key from the returned JSON object.
POST requests
POST requests can be used to pass parameters to a command. Here's an example:
import requests
data = {"param1": "value1", "param2": "value2"}
response = requests.post("http://<url>/command", data=data)
Updated 9 months ago