Skip to content

Commit

Permalink
Add: documentation for NASL host-functions (#1264)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kraemii committed Dec 15, 2022
1 parent 32ca0d9 commit 934f70d
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# TARGET_IS_IPV6

## NAME

**TARGET_IS_IPV6** -

## SYNOPSIS

*bool* **TARGET_IS_IPV6**();

**TARGET_IS_IPV6** takes no arguments

## DESCRIPTION

Check if the currently scanned target is an IPv6 address.

## RETURN VALUE

*TRUE* if the current target is an IPv6 address, else *FALSE*. In case of an error, *NULL* is returned.


## ERROR

No IP address for the current target is set.
27 changes: 27 additions & 0 deletions doc/manual/nasl/built-in-functions/host-functions/add_host_name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# add_host_name

## NAME

**add_host_name** - add a host name to the vhost list

## SYNOPSIS

*void* **add_host_name**(hostname: *string*, source: *string*);

**add_host_name** takes up to 2 named arguments

## DESCRIPTION

Expands the with the given hostname.

The mandatory parameter *hostname* is of type *string*. It contains the hostname which should be added to the list of VHosts

Additionally a source, how the hostname was detected can be added with the named argument *source* as a *string*. If it is not given, the value *NASL* is set as default.

## RETURN VALUE

None

## ERRORS

The named argument *hostname* is missing.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# get_host_name_source

## NAME

**get_host_name_source** - get the hostname source

## SYNOPSIS

*string* **get_host_name_source**(hostname: *string*);

**get_host_name_source** takes one named argument

## DESCRIPTION

This function returns the source of detection of a given hostname.

The named parameter *hostname* is a *string* containing the hostname.

When no hostname is given, the current scanned host is taken.

If no virtual hosts are found yet this function always returns *IP-address*.

## RETURN VALUE

Source of detection of a given hostname as *string* or *NULL* if hostname unknown

## SEE ALSO

**[add_host_name(3)](add_host_name.md)**
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# get_host_name

## NAME

**get_host_names** - get a list with found hostnames

## SYNOPSIS

*array* **get_host_names**();

**get_host_names** takes no arguments

## DESCRIPTION

Get a list of found hostnames or a IP of the current target in case no hostnames were found yet.

## RETURN VALUE

An *array* containing all found hostnames as *string*. The return type is always a NASL array.

## SEE ALSO

**[add_host_name(3)](add_host_name.md)**
7 changes: 7 additions & 0 deletions doc/manual/nasl/built-in-functions/host-functions/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# HostFunctions

## GENERAL

Host functions are used to get, resolve, compare and add hosts to the vhosts list

## TABLE OF CONTENT
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# resolve_host_name

## NAME

**resolve_host_name** - get an IP address corresponding to the host name

## SYNOPSIS

*string* **resolve_host_name**(hostname: *string*);

**resolve_host_name** takes one named argument

## DESCRIPTION

Tries to resolve the IP of a given hostname as IPv6.

The named parameter *hostname* is a *string* containing the hostname to resolve.

## RETURN VALUE

The resolve IPv6 as *string* or *NULL*, when the hostname could not be resolved or on an error

## ERRORS

The named parameter *hostname* is missing
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# resolve_hostname_to_multiple_ips

## NAME

**resolve_hostname_to_multiple_ips** - resolve a hostname to all found addresses

## SYNOPSIS

*array* **resolve_hostname_to_multiple_ips**(hostname: *string*);

**resolve_hostname_to_multiple_ips** takes one named argument

## DESCRIPTION

This function creates a list of addresses a given host resolves to.

The named argument *hostname* is a *string* containing the hostname to resolve.

## RETURN VALUE

A *array* containing all found addresses or *NULL* on error.

## ERROR

The named parameter *hostname* is missing

## NOTE

Even if no address could be found, an empty NASL array is returned. A NASL array is always resolved to TRUE value even though it is empty.
29 changes: 29 additions & 0 deletions doc/manual/nasl/built-in-functions/host-functions/same_host.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# same_host

## NAME

**same_host** - compare two hosts

## SYNOPSIS

*bool* **same_host**(0: *string*, 1: *string*, cmp_hostname: *bool*);

**same_host** takes two unnamed arguments and one named argument

## DESCRIPTION

Compare if two hosts are the same.

The first two unnamed arguments are *string* containing the host to compare

If the named argument *cmp_hostname* is set to *TRUE*, the given hosts are resolved into their hostnames

## RETURN VALUE

TRUE if both hosts are the same, else FALSE. In case of an error a *NULL* is returned instead

## ERRORS

One of the two positional arguments are missing

One of the hostnames is too long, max length: 255

0 comments on commit 934f70d

Please sign in to comment.