-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add: support for HTTP/2 See NASL manual documentation. Jira: SC-1038 `openvas-nasl -X -t example.com http2.nasl` ``` h = http2_handle(); display(h); r = http2_get(handle:h, port:443, item:"/", schema:"https"); display("response: ", r); rc = http2_get_response_code(handle:h); display("return code: ", rc); http2_close_handle(h); h = http2_handle(); display(h); r = http2_get(handle:h, port:3000, item:"/vts", schema:"http"); display("response: ", r); rc = http2_get_response_code(handle:h); display("return code: ", rc); http2_close_handle(h); ``` * nasl/nasl_http2.c * small fix reported by clippy non related to this PR's topic * fix typos
- Loading branch information
Showing
17 changed files
with
943 additions
and
3 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
doc/manual/nasl/built-in-functions/http2-functions/http2_close_handle.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# http2_close_handle | ||
|
||
## NAME | ||
|
||
**http2_close_handle** - Close a handle for http requests previously initialized. | ||
|
||
## SYNOPSIS | ||
|
||
*void* **http_close_handle**(handle: *int*); | ||
|
||
**http_close_handle** takes one argument. | ||
|
||
## DESCRIPTION | ||
Close a handle for http requests previously initialized. | ||
|
||
## RETURN VALUE | ||
It returns an integer or NULL on error. | ||
|
||
## EXAMPLES | ||
|
||
**1** Close the handle identifier | ||
```cpp | ||
h = http2_handle(); | ||
display(h); | ||
http2_close_handle(h); | ||
``` | ||
## SEE ALSO | ||
**[http2_delete(3)](http2_delete.md)**, **[http2_get(3)](http2_get.md)**, **[http2_close_handle(3)](http2_close_handle.md)**, **[http2_head(3)](http2_head.md)**, **[http2_handle(3)](http2_handle.md)**, **[http2_post(3)](http2_post.md)**, **[http2_put(3)](http2_put.md)**, **[http2_get_response_code(3)](http2_get_response_code.md)**, **[http2_set_custom_header(3)](http2_set_custom_header.md)** |
37 changes: 37 additions & 0 deletions
37
doc/manual/nasl/built-in-functions/http2-functions/http2_delete.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# http2_delete | ||
|
||
## NAME | ||
|
||
**http2_delete** - performs an HTTP2 DELETE request for the server on the port. | ||
|
||
## SYNOPSIS | ||
|
||
*void* **http_delete**(handle: *int*, port: *int*, schema: *string*, item: *string*, data: *string*); | ||
|
||
**http_delete** takes five named arguments. | ||
|
||
## DESCRIPTION | ||
Performs an HTTP2 DELETE request for the server on the port. It tries to force the version HTTP2 if `https` (default) is passed as schema uses ALPN to negotiate the protocol to use. | ||
|
||
If `http` is passed as schema, the function includes an upgrade header in the initial request to the host to allow upgrading to HTTP/2. | ||
The arguments are port and item (the path, query, etc), schema (optional, defualt `https`) and `data` (optional). | ||
|
||
## RETURN VALUE | ||
It returns a string (the http response). Null on error | ||
|
||
## EXAMPLES | ||
|
||
**1** Delete and display the formatted delete request: | ||
```cpp | ||
h = http2_handle(); | ||
display(h); | ||
|
||
r = http2_delete(handle:h, port:3000, item:"/vts", schema:"http"); | ||
display("response: ", r); | ||
rc = http2_get_response_code(handle:h); | ||
display("return code: ", rc); | ||
``` | ||
## SEE ALSO | ||
**[http2_delete(3)](http2_delete.md)**, **[http2_get(3)](http2_get.md)**, **[http2_close_handle(3)](http2_close_handle.md)**, **[http2_head(3)](http2_head.md)**, **[http2_handle(3)](http2_handle.md)**, **[http2_post(3)](http2_post.md)**, **[http2_put(3)](http2_put.md)**, **[http2_get_response_code(3)](http2_get_response_code.md)**, **[http2_set_custom_header(3)](http2_set_custom_header.md)** |
37 changes: 37 additions & 0 deletions
37
doc/manual/nasl/built-in-functions/http2-functions/http2_get.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# http2_get | ||
|
||
## NAME | ||
|
||
**http2_get** - performs an HTTP2 GET request for the server on the port. | ||
|
||
## SYNOPSIS | ||
|
||
*void* **http_get**(handle: *int*, port: *int*, schema: *string*, item: *string*, data: *string*); | ||
|
||
**http_get** takes five named arguments. | ||
|
||
## DESCRIPTION | ||
Performs an HTTP2 GET request for the server on the port. It tries to force the version HTTP2 if `https` (default) is passed as schema uses ALPN to negotiate the protocol to use. | ||
|
||
If `http` is passed as schema, the function includes an upgrade header in the initial request to the host to allow upgrading to HTTP/2. | ||
The arguments are port and item (the path, query, etc), schema (optional, defualt `https`) and `data` (optional). | ||
|
||
## RETURN VALUE | ||
It returns a string (the http response). Null on error | ||
|
||
## EXAMPLES | ||
|
||
**1** Get and display the formatted get request: | ||
```cpp | ||
h = http2_handle(); | ||
display(h); | ||
|
||
r = http2_get(handle:h, port:3000, item:"/vts", schema:"http"); | ||
display("response: ", r); | ||
rc = http2_get_response_code(handle:h); | ||
display("return code: ", rc); | ||
``` | ||
## SEE ALSO | ||
**[http2_delete(3)](http2_delete.md)**, **[http2_get(3)](http2_get.md)**, **[http2_close_handle(3)](http2_close_handle.md)**, **[http2_head(3)](http2_head.md)**, **[http2_handle(3)](http2_handle.md)**, **[http2_post(3)](http2_post.md)**, **[http2_put(3)](http2_put.md)**, **[http2_get_response_code(3)](http2_get_response_code.md)**, **[http2_set_custom_header(3)](http2_set_custom_header.md)** |
34 changes: 34 additions & 0 deletions
34
doc/manual/nasl/built-in-functions/http2-functions/http2_get_response_code.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# http2_get_response_code | ||
|
||
## NAME | ||
|
||
**http2_get_response_code** - Gets the response code | ||
|
||
## SYNOPSIS | ||
|
||
*void* **http2_get_response_code**(handle: *int*); | ||
|
||
**http_get** takes one argument. | ||
|
||
## DESCRIPTION | ||
After performing a request, is possible to get the response code calling this function and giving the handle identifier. | ||
|
||
## RETURN VALUE | ||
It returns an intenger with the response code. Null on error | ||
|
||
## EXAMPLES | ||
|
||
**1** Get and display the response code: | ||
```cpp | ||
h = http2_handle(); | ||
display(h); | ||
|
||
r = http2_get(handle:h, port:3000, item:"/vts", schema:"http"); | ||
display("response: ", r); | ||
rc = http2_get_response_code(handle:h); | ||
display("return code: ", rc); | ||
``` | ||
## SEE ALSO | ||
**[http2_delete(3)](http2_delete.md)**, **[http2_get(3)](http2_get.md)**, **[http2_close_handle(3)](http2_close_handle.md)**, **[http2_head(3)](http2_head.md)**, **[http2_handle(3)](http2_handle.md)**, **[http2_post(3)](http2_post.md)**, **[http2_put(3)](http2_put.md)**, **[http2_get_response_code(3)](http2_get_response_code.md)**, **[http2_set_custom_header(3)](http2_set_custom_header.md)** |
29 changes: 29 additions & 0 deletions
29
doc/manual/nasl/built-in-functions/http2-functions/http2_handle.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# http2_handle | ||
|
||
## NAME | ||
|
||
**http2_handle** - Creates a handle for http requests. | ||
|
||
## SYNOPSIS | ||
|
||
*void* **http_handle**(); | ||
|
||
**http_handle** takes no argument. | ||
|
||
## DESCRIPTION | ||
Initialize a handle for performing http requests. | ||
|
||
## RETURN VALUE | ||
It returns an integer or NULL on error. | ||
|
||
## EXAMPLES | ||
|
||
**1** Get the handle identifier | ||
```cpp | ||
h = http2_handle(); | ||
display(h); | ||
``` | ||
## SEE ALSO | ||
**[http2_delete(3)](http2_delete.md)**, **[http2_get(3)](http2_get.md)**, **[http2_close_handle(3)](http2_close_handle.md)**, **[http2_head(3)](http2_head.md)**, **[http2_handle(3)](http2_handle.md)**, **[http2_post(3)](http2_post.md)**, **[http2_put(3)](http2_put.md)**, **[http2_get_response_code(3)](http2_get_response_code.md)**, **[http2_set_custom_header(3)](http2_set_custom_header.md)** |
37 changes: 37 additions & 0 deletions
37
doc/manual/nasl/built-in-functions/http2-functions/http2_head.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# http2_head | ||
|
||
## NAME | ||
|
||
**http2_head** - performs an HTTP2 HEAD request for the server on the port. | ||
|
||
## SYNOPSIS | ||
|
||
*void* **http_head**(handle: *int*, port: *int*, schema: *string*, item: *string*, data: *string*); | ||
|
||
**http_head** takes five named arguments. | ||
|
||
## DESCRIPTION | ||
Performs an HTTP2 HEAD request for the server on the port. It tries to force the version HTTP2 if `https` (default) is passed as schema uses ALPN to negotiate the protocol to use. | ||
|
||
If `http` is passed as schema, the function includes an upgrade header in the initial request to the host to allow upgrading to HTTP/2. | ||
The arguments are port and item (the path, query, etc), schema (optional, defualt `https`) and `data` (optional). | ||
|
||
## RETURN VALUE | ||
It returns a string (the http response). Null on error | ||
|
||
## EXAMPLES | ||
|
||
**1** Get and display the formatted head request: | ||
```cpp | ||
h = http2_handle(); | ||
display(h); | ||
|
||
r = http2_head(handle:h, port:3000, item:"/", schema:"http"); | ||
display("response: ", r); | ||
rc = http2_get_response_code(handle:h); | ||
display("return code: ", rc); | ||
``` | ||
## SEE ALSO | ||
**[http2_delete(3)](http2_delete.md)**, **[http2_get(3)](http2_get.md)**, **[http2_close_handle(3)](http2_close_handle.md)**, **[http2_head(3)](http2_head.md)**, **[http2_handle(3)](http2_handle.md)**, **[http2_post(3)](http2_post.md)**, **[http2_put(3)](http2_put.md)**, **[http2_get_response_code(3)](http2_get_response_code.md)**, **[http2_set_custom_header(3)](http2_set_custom_header.md)** |
37 changes: 37 additions & 0 deletions
37
doc/manual/nasl/built-in-functions/http2-functions/http2_post.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# http2_post | ||
|
||
## NAME | ||
|
||
**http2_post** - performs an HTTP2 POST request for the server on the port. | ||
|
||
## SYNOPSIS | ||
|
||
*void* **http_post**(handle: *int*, port: *int*, schema: *string*, item: *string*, data: *string*); | ||
|
||
**http_post** takes five named arguments. | ||
|
||
## DESCRIPTION | ||
Performs an HTTP2 POST request for the server on the port. It tries to force the version HTTP2 if `https` (default) is passed as schema uses ALPN to negotiate the protocol to use. | ||
|
||
If `http` is passed as schema, the function includes an upgrade header in the initial request to the host to allow upgrading to HTTP/2. | ||
The arguments are port and item (the path, query, etc), schema (optional, defualt `https`) and `data` (optional). | ||
|
||
## RETURN VALUE | ||
It returns a string (the http response). Null on error | ||
|
||
## EXAMPLES | ||
|
||
**1** Get and display the formatted post request: | ||
```cpp | ||
h = http2_handle(); | ||
display(h); | ||
|
||
r = http2_post(handle:h, port:3000, item:"/scan", schema:"http", data:"bad scan config format"); | ||
display("response: ", r); | ||
rc = http2_get_response_code(handle:h); | ||
display("return code: ", rc); | ||
``` | ||
## SEE ALSO | ||
**[http2_delete(3)](http2_delete.md)**, **[http2_get(3)](http2_get.md)**, **[http2_close_handle(3)](http2_close_handle.md)**, **[http2_head(3)](http2_head.md)**, **[http2_handle(3)](http2_handle.md)**, **[http2_post(3)](http2_post.md)**, **[http2_put(3)](http2_put.md)**, **[http2_get_response_code(3)](http2_get_response_code.md)**, **[http2_set_custom_header(3)](http2_set_custom_header.md)** |
37 changes: 37 additions & 0 deletions
37
doc/manual/nasl/built-in-functions/http2-functions/http2_put.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# http2_put | ||
|
||
## NAME | ||
|
||
**http2_put** - performs an HTTP2 PUT request for the server on the port. | ||
|
||
## SYNOPSIS | ||
|
||
*void* **http_put**(handle: *int*, port: *int*, schema: *string*, item: *string*, data: *string*); | ||
|
||
**http_put** takes five named arguments. | ||
|
||
## DESCRIPTION | ||
Performs an HTTP2 PUT request for the server on the port. It tries to force the version HTTP2 if `https` (default) is passed as schema uses ALPN to negotiate the protocol to use. | ||
|
||
If `http` is passed as schema, the function includes an upgrade header in the initial request to the host to allow upgrading to HTTP/2. | ||
The arguments are port and item (the path, query, etc), schema (optional, defualt `https`) and `data` (optional). | ||
|
||
## RETURN VALUE | ||
It returns a string (the http response). Null on error | ||
|
||
## EXAMPLES | ||
|
||
**1** Get and display the formatted put request: | ||
```cpp | ||
h = http2_handle(); | ||
display(h); | ||
|
||
r = http2_put(handle:h, port:3000, item:"/scan", schema:"http", data:"bad scan config format"); | ||
display("response: ", r); | ||
rc = http2_get_response_code(handle:h); | ||
display("return code: ", rc); | ||
``` | ||
## SEE ALSO | ||
**[http2_delete(3)](http2_delete.md)**, **[http2_get(3)](http2_get.md)**, **[http2_close_handle(3)](http2_close_handle.md)**, **[http2_head(3)](http2_head.md)**, **[http2_handle(3)](http2_handle.md)**, **[http2_post(3)](http2_post.md)**, **[http2_put(3)](http2_put.md)**, **[http2_get_response_code(3)](http2_get_response_code.md)**, **[http2_set_custom_header(3)](http2_set_custom_header.md)** |
30 changes: 30 additions & 0 deletions
30
doc/manual/nasl/built-in-functions/http2-functions/http2_set_custom_header.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# http2_set_custom_header | ||
|
||
## NAME | ||
|
||
**http2_set_custom_header** - Set a custom header element in the header | ||
|
||
## SYNOPSIS | ||
|
||
*void* **http_set_custom_header**(handle: *int*, header_item: *string*); | ||
|
||
**http_set_custom_header** takes two arguments. | ||
|
||
## DESCRIPTION | ||
Adds a new element to initialized handle header. | ||
|
||
## RETURN VALUE | ||
It returns an integer or NULL on error. | ||
|
||
## EXAMPLES | ||
|
||
**1** Set a new element in the header | ||
```cpp | ||
h = http2_handle(); | ||
display(h); | ||
http2_set_custom_header(handle: h, handle_item: "Content-Type: application/json"); | ||
``` | ||
## SEE ALSO | ||
**[http2_delete(3)](http2_delete.md)**, **[http2_get(3)](http2_get.md)**, **[http2_close_handle(3)](http2_close_handle.md)**, **[http2_head(3)](http2_head.md)**, **[http2_handle(3)](http2_handle.md)**, **[http2_post(3)](http2_post.md)**, **[http2_put(3)](http2_put.md)**, **[http2_get_response_code(3)](http2_get_response_code.md)**, **[http2_set_custom_header(3)](http2_set_custom_header.md)** |
16 changes: 16 additions & 0 deletions
16
doc/manual/nasl/built-in-functions/http2-functions/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# HTTP2 Functions | ||
|
||
## GENERAL | ||
|
||
These functions are mainly used for performing HTTP2 request. | ||
|
||
## TABLE OF CONTENT | ||
- **[http2_handle](http2_handle.md)** - Creates a handle for http requests. | ||
- **[http2_close_handle](http2_close_handle.md)** - Close a handle for http requests previously initialized. | ||
- **[http2_get_response_code](http2_get_response_code.md)** - Get the http response code after performing a HTTP request. | ||
- **[http2_set_custom_header](http2_set_custom_header.md)** - Set a custom header element in the header. | ||
- **[http2_delete](http2_delete.md)** - performs an HTTP2 DELETE request for the server on the port. | ||
- **[http2_get](http2_get.md)** - performs an HTTP2 DELETE request for the server on the port. | ||
- **[http2_head](http2_head.md)** - performs an HTTP2 HEAD request for the server on the port. | ||
- **[http2_post](http2_post.md)** - performs an HTTP2 POST request for the server on the port. | ||
- **[http2_put](http2_put.md)** - performs an HTTP2 PUT request for the server on the port. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.