---
name: "Net::Nessus::REST"
section: "3pm"
platform: "linux"
package: "libnet-nessus-rest-perl"
version: "0.7.0-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Net::Nessus::REST"
---

# Net::Nessus::REST(3pm)

REST interface for Nessus 6.0

## NAME

Net::Nessus::REST - REST interface for Nessus 6.0

## DESCRIPTION

This module provides a Perl interface for communication with Nessus scanner using REST interface.

## SYNOPSIS

```
    use Net::Nessus::REST;
    my $nessus = Net::Nessus::REST->new(
        url => 'https://my.nessus:8834'
    ):
    $nessus->create_session(
        username => 'user',
        password => 's3cr3t',
    );
    my $policy_template_id = $nessus->get_template_id(
        name => 'basic',
        type => 'policy'
    );
    my $scan = $nessus->create_scan(
        uuid     => $policy_template_id,
        settings => {
            text_targets => '127.0.0.1',
            name         => 'localhost scan'
        }
    );
    $nessus->launch_scan(scan_id => $scan->{id});
    while ($nessus->get_scan_status(scan_id => $scan->{id}) ne 'completed') {
        sleep 10;
    }
    my $file_id = $nessus->export_scan(
        scan_id => $scan->{id},
        format  => 'pdf'
    );
    while ($nessus->get_scan_export_status(
        scan_id => $scan->{id},
        file_id => $file_id
    ) ne 'ready') {
        sleep 1;
    }
    $nessus->download_scan(
        scan_id  => $scan->{id},
        file_id  => $file_id,
        filename => 'localhost.pdf'
    );
```

## CLASS METHODS

### Net::Nessus::REST-\>new(url =\> $url, \[ssl\_opts =\> $opts, timeout =\> $timeout\])

Creates a new Net::Nessus::Rest instance.

## INSTANCE METHODS

### $nessus-\>create\_session(username =\> $username, password =\> $password)

Creates a new session token for the given user.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/session/create\> for details.

### $nessus-\>destroy\_session()

Logs the current user out and destroys the session.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/session/destroy\> for details.

### $nessus-\>list\_policies()

Returns the policy list.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/policies/list\> for details.

### $nessus-\>get\_policy\_id(name =\> $name)

Returns the identifier for the policy with given name.

### $nessus-\>get\_policy\_details(id =\> $policy\_id)

Returns a reference to a hash with all settings and parameters for a given scan policy.

See \<https://your.nessus.server:8834/api#/resources/policies/details\> for details.

### $nessus-\>import\_policy(file =\> $file\_id)

Returns reference to hash with name and identifier of the policy imported. NB `$file_id` must be a valid identifier to a file uploaded to the Nessus server, e.g. with method **file\_upload()**

Example: `$result` = `$nessus`-\>import\_policy(file =\> `$fileuploaded`); print "Policy imported: " . `$result`-\>{'name'} . "\\n";

See \<https://your.nessus.server:8834/api#/resources/policies/import\> for details.

### $nessus-\>delete\_policy(id =\> $policy\_id)

Deletes a given scan policy off the Nessus server

See \<https://your.nessus.server:8834/api#/resources/policies/delete\> for details.

### $nessus-\>configure\_policy(id =\> $policy\_id, uuid =\> $uuid, settings =\> $settings)

See \<https://your.nessus.server:8834/api#/resources/policies/configure\> for details.

### $nessus-\>create\_policy(uuid =\> $uuid, settings =\> $settings)

See \<https://your.nessus.server:8834/api#/resources/policies/create\> for details.

### $nessus-\>list\_scanners()

Returns the scanner list.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/scanners/list\> for details.

### $nessus-\>list\_folders()

Returns the current user's scan folders.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/folders/list\> for details.

### $nessus-\>get\_folder\_id(name =\> $name)

Returns the identifier for the folder with given name.

### $nessus-\>create\_scan(uuid =\> $uuid, settings =\> $settings)

Creates a scan

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/scans/create\> for details.

### $nessus-\>configure\_scan(scan\_id =\> $scan\_id, uuid =\> $uuid, settings =\> $settings)

Changes the schedule or policy parameters of a scan.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/scans/configure\> for details.

### $nessus-\>delete\_scan(scan\_id =\> $scan\_id)

Deletes a scan.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/scans/delete\> for details.

### $nessus-\>delete\_scan\_history(scan\_id =\> $scan\_id, history\_id =\> $history\_id)

Deletes historical results from a scan.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/scans/delete-history\> for details.

### $nessus-\>download\_scan(scan\_id =\> $scan\_id, file\_id =\> $file\_id, filename =\> $filename)

Download an exported scan. Without filename parameter it will return the content of the file.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/scans/download\> for details.

### $nessus-\>export\_scan(scan\_id =\> $scan\_id, format =\> $format)

Export the given scan.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/scans/export\> for details.

### $nessus-\>launch\_scan(scan\_id =\> $scan\_id)

Launches a scan.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/scans/launch\> for details.

### $nessus-\>list\_scans(\[folder\_id =\> $id, last\_modification\_date =\> $date\])

Returns the scan list.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/scans/list\> for details.

### $nessus-\>set\_scan\_read\_status(scan\_id =\> $scan\_id, status =\> $status)

Changes the status of a scan.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/scans/read-status\> for details.

### $nessus-\>get\_scan\_details(scan\_id =\> $scan\_id, \[history\_id =\> $history\_id\])

Returns details for the given scan.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/scans/details\> for details.

### $nessus-\>get\_scan\_host\_details(scan\_id =\> $scan\_id, host\_id =\> $host\_id, \[history\_id =\> $history\_id\])

Returns details for the given host.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/scans/host-details\> for details.

### $nessus-\>get\_scan\_export\_status(scan\_id =\> $scan\_id, file\_id =\> $file\_id)

Check the file status of an exported scan.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/scans/export-status\> for details.

### $nessus-\>get\_scan\_plugin\_output(scan\_id =\> $scan\_id, host\_id =\> $host\_id, plugin\_id =\> $plugin\_id, \[history\_id =\> $history\_id\])

Returns the output for a given plugin.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/scans/plugin-output\> for details.

### $nessus-\>get\_scan\_id(name =\> $name)

Returns the identifier for the scan with given name.

### $nessus-\>get\_scan\_status(scan\_id =\> $scan\_id)

Returns the status for given scan.

### $nessus-\>get\_scan\_history\_id(scan\_id =\> $scan\_id, scan\_uuid =\> $scan\_uuid)

Returns the identifier for the historical results for given scan and run.

### $nessus-\>list\_templates(type =\> $type)

Returns the template list.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/editor/list\> for details.

### $nessus-\>get\_template\_id(type =\> $type, name =\> $name)

Returns the identifier for template with given name.

### $nessus-\>get\_plugin\_details( id =\> $plugin\_id )

returns the details of a plugin

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/plugins/plugin-details\> for details.

### $nessus-\>list\_plugin\_families( )

returns a list of plugin families

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/plugins/families\> for details.

### $nessus-\>get\_plugin\_family\_details( id =\> $family\_id )

returns the details about a plugin family

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/plugins/family-details\> for details.

### $nessus-\>get\_scanner\_id( name =\> $name )

returns the identifier for the scanner with given name.

### $nessus-\>file\_upload(file =\> $file)

Uploads a file to the Nessus server. Returns a reference to hash with identifier to the uploaded file.

Example: my `$result` = `$nessus`-\>file\_upload(file =\> `$file`); my `$fileuploaded` = `$result`-\>{'fileuploaded'};

See \<https://your.nessus.server:8834/api#/resources/file/upload\> for details.

### $nessus-\>stop\_scan(scan\_id =\> $scan\_id )

Returns details for the given scan.

See \<https://your.nessus.server:8834/nessus6-api.html#/resources/scans/stop\> for details.

## LICENSE

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program.  If not, see \<http://www.gnu.org/licenses/\>.
