From f7035381657f24d829ca437f4b5e8c56c17997ef Mon Sep 17 00:00:00 2001 From: devStorm <59678453+developStorm@users.noreply.github.com> Date: Mon, 20 May 2024 07:45:32 +0000 Subject: [PATCH] docs: fix path and instructions in integrated test documents --- README.md | 10 +++++++--- zgrab2_schemas/README.md | 10 +++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 049eb759..3f53a534 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ func init() { ### Output schema -To add a schema for the new module, add a module under schemas, and update [`schemas/__init__.py`](schemas/__init__.py) to ensure that it is loaded. +To add a schema for the new module, add a module under schemas, and update [`zgrab2_schemas/zgrab2/__init__.py`](zgrab2_schemas/zgrab2/__init__.py) to ensure that it is loaded. See [zgrab2_schemas/README.md](zgrab2_schemas/README.md) for details. @@ -158,11 +158,13 @@ The only hard requirement is that the `test.sh` script drops its output in `$ZGR #### How to Run Integration Tests -To run integration tests, you must have [Docker](https://www.docker.com/) installed. Then, you can follow the following steps to run integration tests: +To run integration tests, you must have [Docker](https://www.docker.com/) and **Python 2** on host installed. Then, you can follow the following steps to run integration tests: ```shell go get github.com/jmespath/jp && go build github.com/jmespath/jp -pip install --user zschema +# or, sudo wget https://github.com/jmespath/jp/releases/download/0.2.1/jp-linux-amd64 -O /usr/local/bin/jp && sudo chmod +x /usr/local/bin/jp +pip2 install --user zschema +pip2 install --user -r requirements.txt make integration-test ``` @@ -173,5 +175,7 @@ echo $? 0 ``` +Refer to our [Github Actions workflow](.github/workflows/integration-test.yml) for an example of how to prepare environment for integration tests. + ## License ZGrab2.0 is licensed under Apache 2.0 and ISC. For more information, see the LICENSE file. diff --git a/zgrab2_schemas/README.md b/zgrab2_schemas/README.md index ebb10c3d..e047b2fa 100644 --- a/zgrab2_schemas/README.md +++ b/zgrab2_schemas/README.md @@ -3,7 +3,7 @@ ZGrab 2.0 schemas for zschema ## Validating -[integration_tests.sh](../integration_tests.sh) automatically validates +[integration_tests](../integration_tests) automatically validates output from the integration tests; to manually validate a zgrab2 result, you can follow these steps: @@ -11,11 +11,11 @@ you can follow these steps: 1. Run the zschema validator: 1. Run the zschema module's main function 2. Pass it the `validate` command - 3. Give the path to the zgrab2 schema [`schemas/__init__.py:zgrab2`](schemas/__init.py__) + 3. Give the path to the zgrab2 schema [`zgrab2/__init__.py:zgrab2`](zgrab2/__init__.py) 4. Pass in the zgrab2 JSON file to validate * ``` echo 127.0.0.1 | ./cmd/zgrab2/zgrab2 mysql > output.json - PYTHONPATH=/path/to/zschema python -m zschema validate schemas/__init__.py:zgrab2 output.json + PYTHONPATH=/path/to/zschema python2 -m zschema validate zgrab2 output.json --path . --module zgrab2_schemas.zgrab2 ``` ## Adding new module schemas @@ -35,11 +35,11 @@ unfortunately, this means that multiple scans on a single host, or scans using custom identifiers, will not validate). Your module should include a `SubRecord` that extends from `zgrab2.base_scan_response`, -specifically, overridding the `result` field. See [schemas/mysql.py](schemas/mysql.py) +specifically, overridding the `result` field. See [zgrab2/mysql.py](zgrab2/mysql.py) for an example. ### Register the module -In [`schemas/__init__.py`](schemas/__init__.py), add an import for your +In [`zgrab2/__init__.py`](zgrab2/__init__.py), add an import for your module (e.g. `import my_protocol`). This will ensure that the module code is executed and that the response type is registered with the zgrab2 module.