Skip to content

NetBox Executor

Category: Asset Inventory and Network Management Script: netbox.py Integration: REST API Faraday Plugin: Raw JSON Website: https://netbox.dev/

Description

Imports the device inventory (DCIM) and IP addresses (IPAM) of a NetBox instance into Faraday. Each device and each IP address becomes a host with one informational record, so you can cross-check other findings against what NetBox manages.

Prerequisites

  • A NetBox instance reachable from the agent
  • A NetBox API token with read access to devices (dcim) and IP addresses (ipam)

Configuration

Environment Variables (Setup)

Variable Required Description
NETBOX_PAGES No Maximum number of pages (100 items each) to read for devices and for IP addresses (default: 5, maximum: 50)
NETBOX_HOST Yes NetBox URL (e.g., https://netbox.example.com)
NETBOX_TOKEN Yes NetBox API token

These variables are also accepted as execution arguments, so a single run can override them.

Execution Arguments

Parameter Type Mandatory Description
NETBOX_SITE string No Only import devices and IP addresses of this NetBox site. Use the site slug (e.g., dc1-east), not its display name.
NETBOX_ROLE string No Only import devices with this device role. Use the role slug (e.g., access-switch). IP addresses are not filtered by role.

YAML Configuration Example

executors:
  netbox:
    repo_executor: netbox.py
    max_size: 65536
    varenvs:
      NETBOX_HOST: "https://netbox.example.com"
      NETBOX_TOKEN: "<netbox_token>"
    params:
      NETBOX_SITE:
        mandatory: false
        type: string
        base: string
      NETBOX_ROLE:
        mandatory: false
        type: string
        base: string

How It Works

  1. Authenticates with the API token (Authorization: Token ...)
  2. Reads devices from GET /api/dcim/devices/, filtered by site and role if set
  3. Reads IP addresses from GET /api/ipam/ip-addresses/, filtered by site if set
  4. Follows the next link of each response, up to NETBOX_PAGES pages
  5. Creates one host per device and one host per IP address. Each host has a single [NETWORK] vulnerability with info severity that holds the NetBox details (site, role, status, tenant, serial, tags, etc.).

Notes

  • A device host uses the device's primary IP (without the prefix length). If the device has none, the IP is 0.0.0.0. The OS field holds the platform or device type.
  • An IP host uses the address as its IP and the DNS name as its hostname.
  • The info vulnerabilities are inventory records, not security issues.
  • With the default NETBOX_PAGES, at most 500 devices and 500 IP addresses are imported. Increase NETBOX_PAGES for larger inventories.
  • If the token lacks permission for one of the endpoints, that part is skipped and the run continues. An invalid token (401) stops the run.
  • Setup variables can also be passed as execution arguments.
  • The shared agent parameters (AGENT_CONFIG_* tags and severity filters) are not applied by this executor.