GVM RPC Server and Client
Project description
GVM RPC
A simple RPC server and client using Python's xmlrpc.server and xmlrpc.client in tandem with Greenbone's python-gvm package.
Installation
# PyPi Installation
pip install gvm-rpc
# GitHub Installation
python -m pip install git+'https://github.com/bnassif/gvm-rpc.git'
Usage
Client
The client, once imported, works exactly like the gvm.protocols.gmp.Gmp object.
Functions called against the client are proxied through the XML-RPC server where it is then sent to gvmd.sock for processing.
The returned lxml.etree objects are transformed to strings in transport, and transformed back into lxml.etree by the client.
Note: Because the
GvmServerProxyobject just relays attemptedobj.__getattr__()calls, IDE's will not be aware of potential Gmp calls.
Consult thepython-gvmusage documentation for available functions and parameters.
Basic Usage
from gvmrpc.client import GvmServerProxy
hostname = 'http://localhost:8000'
username = 'user'
password = 'secret'
client = GvmServerProxy(username, password, host)
# From here on, the client behaves similarly to the Gmp object
client.get_version()
client.get_targets()
...
# It is also possible to handle multiple calls at once using the custom MultiCall class
from .client import MultiCall
# Create a MutliCall instance
multi_call = MultiCall()
# Add calls to the MultiCall object
multi_call.get_version()
multi_call.get_targets()
# Execute the commands
multi_call()
Secure Usage
When the server is secured by an SSL, which it should always be because of Basic auth, it is necessary to assign an SSL context to the client.
from gvmrpc.client import GvmServerProxy
import ssl # We'll need this module
hostname = 'http://localhost:8000'
username = 'user'
password = 'secret'
# Create the context object
context = ssl.SSLContext(protocol=ssl.PROTOCOL_TLS)
# Bind the SSLContext to the client
client = GvmServerProxy(username, password, host, ssl_context=context)
Server
The server runs as a daemon on the GVS server you wish to manage.
The recommended deployment option is to use the accompanying Docker Image if running GVS in Docker.
Otherwise, the server can also be run as a system-level service.
For details on flags available at runtime for both deployments, consult the run.py script in the repo root.
Container Usage
When running GVM RPC as a sidecar container, it is important to bind the gvmd_socket_vol volume in the appropriate place.
You will likely also want to expose this container with an SSL-terminating reverse proxy like nginx to secure usage.
For an example on deploying the container as a sidecar via Docker Compose overrides, reference this example file.
System-Level Service
Running GVM RPC as a service involves additional overhead on maintaining the Python environment it will run in.
It is not recommended to use this option unless you know what you are doing.
For an example on how to do this with systemd, reference this example service.
Available Options
The provided runtime script defaults to serving without an SSL. Please review the options below and secure the server as necessary.
| flag | default | description |
|---|---|---|
--address |
127.0.0.1 |
The local address to listen on |
--port |
8000 |
The local port to listen on |
--socket |
/gvmd/gvmd.sock |
The path to the GVM socket |
--ssl-cert |
The path to the SSL certificate to be used | |
--ssl-key |
The path to the SSL key to be used |
Note: The SSL certificate and key must both be supplied or not supplied
License
MIT - Feel free to use, extend, and contribute.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gvmrpc-0.1.0.tar.gz.
File metadata
- Download URL: gvmrpc-0.1.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2a8fe012662ee033d7bb134cb2432e4d315cbb0a1e0f0243a02875df81b68cb
|
|
| MD5 |
419029183f2f8b84654e6f7c3ceb218f
|
|
| BLAKE2b-256 |
28efc0952498a38b84849226d46af906b848201b831a548cbeb22bec822a0614
|
Provenance
The following attestation bundles were made for gvmrpc-0.1.0.tar.gz:
Publisher:
release.yml on bnassif/gvm-rpc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gvmrpc-0.1.0.tar.gz -
Subject digest:
c2a8fe012662ee033d7bb134cb2432e4d315cbb0a1e0f0243a02875df81b68cb - Sigstore transparency entry: 578598613
- Sigstore integration time:
-
Permalink:
bnassif/gvm-rpc@d739dd8b2dcad9e96c75eb0eb3d10ccb1f871ef1 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bnassif
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d739dd8b2dcad9e96c75eb0eb3d10ccb1f871ef1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file gvmrpc-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gvmrpc-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
047b6f39b53a733104de7f961661ebcf0f5f2d3c01481a0d286dd91cf9845b5c
|
|
| MD5 |
970a51734c407097c393b5a35bf5175d
|
|
| BLAKE2b-256 |
0dfb60da3e0d059af0640cd5029c45b671760057d6672ad88c7842a1f1bf85e5
|
Provenance
The following attestation bundles were made for gvmrpc-0.1.0-py3-none-any.whl:
Publisher:
release.yml on bnassif/gvm-rpc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gvmrpc-0.1.0-py3-none-any.whl -
Subject digest:
047b6f39b53a733104de7f961661ebcf0f5f2d3c01481a0d286dd91cf9845b5c - Sigstore transparency entry: 578598614
- Sigstore integration time:
-
Permalink:
bnassif/gvm-rpc@d739dd8b2dcad9e96c75eb0eb3d10ccb1f871ef1 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bnassif
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d739dd8b2dcad9e96c75eb0eb3d10ccb1f871ef1 -
Trigger Event:
release
-
Statement type: