安装 opam 以构建测试 API。
安装 cargo 以构建 Gaia。
安装 docker v26.0.1 和 docker compose v2.26.1 以使用 ELK Stack 构建 Gaia(如果不使用则为可选)。
要创建一个 opam 本地切换:
make opam-switch
make deps
make build
make build-test
make generate-swagger
make clean-swagger
make format
make clean-build-files
make clean
./_bin/gaia --help
gaia --configuration <configuration> --openapi-path <openapi-path> --workdir-path <workdir-path> --verbose <verbose>
workdir-path:工作目录,您可以在其中找到模糊测试工具的各种日志。
openapi-path:实际 API 的 OpenAPI 文件的路径。使用模糊测试或监控时为必需,统计时不需要
verbose:详细程度级别 {NOTHING, LOW, MID, HIGH, ALL}(默认值:NOTHING)
configuration:包含以下内容的 JSON 文件路径:
{
"configuration": {
// One of : fuzzing or monitoring
"fuzzing": {
//Required
"config_fuzzer": {
//Required
// In hours
"timeout": 1,
//Optional
// Disable fuzzers
"disable_fuzzers": [{
"Restler":{
// Bfs, BfsFast, BfsCheap or RandomWalk
"strategy" : "Bfs"
}
},
"Schemathesis",
{"Custom": {"id": "1"}}
],
//Optional
"custom_fuzzers": [
"<command line that can accept `--output_dir <PATH>`, `--openapi_path <PATH>` and `--timeout <FLOAT>` as arguments>"
],
//Optional
"generation_config": {
//optional (Required if you set a function to generate a value)
"lib_path": "Absolute path to the dynamic library (.so, .dll, or .rs).",
//Optional
"generate_string": {
//One of : Command, Value, File path or Function
"command": "<command line that returns a string array>",
//Or
"value": ["fuzzstring"],
//Or
"function": "<function() that returns a string array>",
//Or
"file": "The file path to the dictionary of values"
},
//Optional
"generate_datetime": {
//One of : Command, Value, File path or Function
"command": "<command line that returns a datetime array in a string format>",
//Or
"value": ["2019-06-26T20:20:39+00:00"],
//Or
"function": "<function() that returns a datetime array in a string format>",
//Or
"file": "The file path to the dictionary of values"
},
//Optional
"generate_date": {
//One of : Command, Value, File path or Function
"command": "<command line that returns a date array in a string format>",
//Or
"value": ["2019-06-26"],
//Or
"function": "<function() that returns a date array in a string format>",
//Or
"file": "The file path to the dictionary of values"
},
//Optional
"generate_int": {
//One of : Command, Value, File path or Function
"command": "<command line that returns an int array in a string format>",
//Or
"value": ["0"],
//Or
"function": "<function() that returns an int array in a string format>",
//Or
"file": "The file path to the dictionary of values"
},
//Optional
"generate_number": {
//One of : Command, Value, File path or Function
"command": "<command line that returns a float array in a string format>",
//Or
"value": ["1.5"],
//Or
"function": "<function() that returns a float array in a string format>",
//Or
"file": "The file path to the dictionary of values"
},
//Optional
"generate_object": {
//One of : Command, Value, File path or Function
"command": "<command line that returns a json object array in a string format>",
//Or
"value": ["{\"k\" : {\"v\" : \"value\" }}"],
//Or
"function": "<function() that returns a json object array in a string format>",
//Or
"file": "The file path to the dictionary of values"
},
//Optional
"generate_path_parameter": {
//One of : Command, Value, File path or Function
"command": "<command line that returns a key-value map with a string key referring to a path parameter and a string array of values>",
//Or
"value": {
"k": {
"v": ["value"]
}
},
//Or
"function": "<function() that returns a key-value map with a string key referring to a path parameter and a string array of values>",
//Or
"file": "The file path to the dictionary of values"
},
//Optional
"generate_query_parameter": {
//One of : Command, Value, File path or Function
"command": "<command line that returns a key-value map with a string key referring to a query parameter and a string array of values>",
//Or
"value": {
"k": {
"v": ["value"]
}
},
//Or
"function": "<function() that returns a key-value map with a string key referring to a query parameter and a string array of values>",
//Or
"file": "The file path to the dictionary of values"
}
}
},
//Required
"config_process_manager": {
//Optional
"config_reset": {
//Required
"reset_lib": "Absolute path to the dynamic library (.so, .dll, or .rs).",
//Required
"function": "Function name that takes two strings as arguments and returns a unit. The first string represents the log in JSON format, and the second represents the path to the real-time log file."
},
//Required
"config_proxy": {
//Optional
"headers_config": {
//Optional
"custom_headers": [
{
//Required
"title": "title",
//Required
"header_type": {
//One of : Command or Value
"Command": {
//Required
"cmd": "<Command that returns the value of the header>",
//Required
//Refresh value in milliseconds
"duration": 0
},
// or
"Value": { "value": "Header value" }
}
}
]
},
//Optional
"openapi_config": {
//Optional
"responses_to_string": true, // Change the type of the responses to string
//Optional
"requests_config": {
//One of : Exclude or Only
"only": {
//Required
"requests": [