| 1 |
General Installation Instructions for OSPD-based Scanners |
| 2 |
========================================================= |
| 3 |
|
| 4 |
This is a general description about installing an ospd-based scanner wrapper |
| 5 |
implementation. |
| 6 |
|
| 7 |
The actual scanner implementation usually has individual installation |
| 8 |
instructions and may refer to this general guide. |
| 9 |
|
| 10 |
In the following guide, replace `ospd-scanner` with the name of the actual OSPD |
| 11 |
scanner. |
| 12 |
|
| 13 |
|
| 14 |
Install in a Virtual Environment |
| 15 |
-------------------------------- |
| 16 |
|
| 17 |
The recommended way to install `ospd-scanner` is to do so inside a virtual |
| 18 |
environment (`virtualenv` or `venv`). |
| 19 |
|
| 20 |
This way, the server and its dependency are well isolated from system-wide |
| 21 |
updates, making it easier to upgrade it, delete it, or install dependencies |
| 22 |
only for it. |
| 23 |
|
| 24 |
Refer to the Python documentation for setting up virtual environments for |
| 25 |
further information. |
| 26 |
|
| 27 |
First you need to create a virtual environment somewhere on your system, for |
| 28 |
example with the following command: |
| 29 |
|
| 30 |
virtualenv ospd-scanner |
| 31 |
|
| 32 |
Installing `ospd-scanner` inside your newly created virtual environment could |
| 33 |
then be done with the following command: |
| 34 |
|
| 35 |
ospd-scanner/bin/pip install ospd_scanner-x.y.z.tar.gz |
| 36 |
|
| 37 |
Note: As `ospd` is not (yet) available through PyPI, you probably want to |
| 38 |
install it manually first inside your virtual environment prior to installing |
| 39 |
`ospd-scanner`. |
| 40 |
|
| 41 |
To run `ospd-scanner`, just start the Python script installed inside the |
| 42 |
virtual environment: |
| 43 |
|
| 44 |
ospd-scanner/bin/ospd-scanner |
| 45 |
|
| 46 |
|
| 47 |
Install (Sub-)System-wide |
| 48 |
------------------------- |
| 49 |
|
| 50 |
To install `ospd-scanner` into directory `<prefix>` run this command: |
| 51 |
|
| 52 |
python3 setup.py install --prefix=<prefix> |
| 53 |
|
| 54 |
The default for `<prefix>` is `/usr/local`. |
| 55 |
|
| 56 |
Be aware that this might automatically download and install missing |
| 57 |
Python packages. To prevent this, you should install the prerequisites |
| 58 |
first with the mechanism of your system (for example via `apt` or `rpm`). |
| 59 |
|
| 60 |
You may need to set the `PYTHONPATH` like this before running |
| 61 |
the install command: |
| 62 |
|
| 63 |
export PYTHONPATH=<prefix>/lib/python3.7/site-packages/ |
| 64 |
|
| 65 |
The actual value for `PYTHONPATH` depends on your Python version. |
| 66 |
|
| 67 |
Creating certificates |
| 68 |
--------------------- |
| 69 |
|
| 70 |
An OSPD service can be started using a Unix domain socket (only on |
| 71 |
respective systems) or using a TCP socket. The latter uses TLS-based |
| 72 |
encryption and authorization while the first is not encrypted and uses |
| 73 |
the standard file access rights for authorization. |
| 74 |
|
| 75 |
For the TCP socket communication it is mandatory to use adequate |
| 76 |
TLS certificates which you need for each of your OSPD service. You may use |
| 77 |
the same certificates for all services if you like. |
| 78 |
|
| 79 |
By default, those certificates are used which are also used by GVM |
| 80 |
(see paths with `ospd-scanner --help`). Of course this works only |
| 81 |
if installed in the same environment. |
| 82 |
|
| 83 |
In case you do not have already a certificate to use, you may quickly |
| 84 |
create your own one (can be used for multiple ospd daemons) using the |
| 85 |
`gvm-manage-certs` tool provided with `gvmd` |
| 86 |
(<https://github.com/greenbone/gvmd>): |
| 87 |
|
| 88 |
gvm-manage-certs -s |
| 89 |
|
| 90 |
And sign it with the CA checked for by the client. The client is usually |
| 91 |
Greenbone Vulnerability Manager for which a global trusted CA certificate |
| 92 |
can be configured. |
| 93 |
|
| 94 |
|
| 95 |
Registering an OSP daemon at Greenbone Vulnerability Manager |
| 96 |
------------------------------------------------------------ |
| 97 |
|
| 98 |
The file [README](../README.md) explains how to control the OSP daemon via |
| 99 |
command line. |
| 100 |
|
| 101 |
It is also possible to register an OSP daemon at the Greenbone Vulnerability |
| 102 |
Manager and then use GMP clients to control the OSP daemon, for example the |
| 103 |
web interface GSA. |
| 104 |
|
| 105 |
You can register either via the GUI (`Configuration -> Scanners`) and create |
| 106 |
a new Scanner there. |
| 107 |
|
| 108 |
Or you can create a scanner via `gvmd` command line (adjust host, |
| 109 |
port, paths, etc. for your daemon): |
| 110 |
|
| 111 |
gvmd --create-scanner="OSP Scanner" --scanner-host=127.0.0.1 --scanner-port=1234 \ |
| 112 |
--scanner-type="OSP" --scanner-ca-pub=/usr/var/lib/gvm/CA/cacert.pem \ |
| 113 |
--scanner-key-pub=/usr/var/lib/gvm/CA/clientcert.pem \ |
| 114 |
--scanner-key-priv=/usr/var/lib/gvm/private/CA/clientkey.pem |
| 115 |
|
| 116 |
or for local running ospd-scanner via file socket: |
| 117 |
|
| 118 |
gvmd --create-scanner="OSP Scanner" --scanner-type="OSP" --scanner-host=/var/run/ospd-scanner.sock |
| 119 |
|
| 120 |
Please note that the scanner created via `gvmd` like above will be created with |
| 121 |
read permissions to all pre-configured roles. |
| 122 |
|
| 123 |
Check whether Greenbone Vulnerability Manager can connect to the OSP daemon: |
| 124 |
|
| 125 |
$ gvmd --get-scanners |
| 126 |
08b69003-5fc2-4037-a479-93b440211c73 OpenVAS Default |
| 127 |
3566ddf1-cecf-4491-8bcc-5d62a87404c3 OSP Scanner |
| 128 |
|
| 129 |
$ gvmd --verify-scanner=3566ddf1-cecf-4491-8bcc-5d62a87404c3 |
| 130 |
Scanner version: 1.0. |
| 131 |
|
| 132 |
Of course, using GMP via command line tools provided by |
| 133 |
[gvm-tools](https://github.com/greenbone/gvm-tools) to register an OSP Scanner |
| 134 |
is also possible as a third option. |
| 135 |
|
| 136 |
|
| 137 |
Documentation |
| 138 |
------------- |
| 139 |
|
| 140 |
Source code documentation can be accessed over the usual methods, |
| 141 |
for example (replace "scanner" by the scanner name): |
| 142 |
|
| 143 |
$ python3 |
| 144 |
>>> import ospd_scanner.wrapper |
| 145 |
>>> help (ospd_scanner.wrapper) |
| 146 |
|
| 147 |
An equivalent to this is: |
| 148 |
|
| 149 |
pydoc3 ospd_scanner.wrapper |
| 150 |
|
| 151 |
To explore the code documentation in a web browser: |
| 152 |
|
| 153 |
$ pydoc3 -p 12345 |
| 154 |
pydoc server ready at http://localhost:12345/ |
| 155 |
|
| 156 |
For further options see the `man` page of `pydoc`. |
| 157 |
|
| 158 |
|
| 159 |
Creating a source archive |
| 160 |
------------------------- |
| 161 |
|
| 162 |
If you already have poetry-core installed you can run this command: |
| 163 |
|
| 164 |
python3 -m build --skip-dependency-check --no-isolation --sdist |
| 165 |
|
| 166 |
If you don't have or want to install poetry-core you can run this |
| 167 |
command: |
| 168 |
|
| 169 |
python3 -m build --sdist |
| 170 |
|
| 171 |
In both cases a source archive for the `ospd-scanner` module will be |
| 172 |
created in the subdirectory *dist*. |