Skip to content

Commit

Permalink
docs: fix path and instructions in integrated test documents
Browse files Browse the repository at this point in the history
  • Loading branch information
developStorm committed May 20, 2024
1 parent 5d3008c commit f703538
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
```

Expand All @@ -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.
10 changes: 5 additions & 5 deletions zgrab2_schemas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ 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:

0. Get [zschema](https://github.com/zmap/zschema) (e.g. `git clone https://github.com/zmap/zschema`)
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
Expand All @@ -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.

0 comments on commit f703538

Please sign in to comment.