Helper Functions are readily available queries in the Forward Library that you can use to streamline NQEs and save valuable coding time. These pre-built utilities empower users to accomplish intricate tasks without needing to reinvent the wheel.
What Are Helper Functions?
Helper functions simplify common networking queries. They reduce the need to manually generate code, enabling users to:
- Extract data with greater ease, including IP addresses and VLAN associations.
- Identify device types, configurations, or compliance based on standards.
- Handle complex calculations and data parsing.
- Combine multiple functions for advanced queries.
These functions are continuously maintained by the Forward Networks engineering team, ensuring compatibility with the latest standards and device updates.
Key Helper Functions
- STIG Device Identification:
Description: Identifies Cisco and Juniper switches and routers that match the Security Technical Implementation Guide (STIGs), saving time on pattern matching and simplifying compliance checks for ever-evolving STIGs.
Location:- Cisco: Forward Library > Security > STIGs > Cisco > util.nqe
- Juniper: Forward Library > Security > STIGs > Juniper > util.nqe
- Layer 2 and Layer 3 Utilities:
Description: L2 helper function fetches all VLANs associated with an interface. The Layer 3 Interfaces function retrieves IP addresses, VRF, and ACLs associated with an interface.
Location:- Forward Library > L2 > L2 Utilities
- Forward Library > L3 > Layer 3 Interfaces
- BGP Utilities:
Description: Provides foundational queries, saving time writing new code to gather BGP data.
Location: Forward Library > L3 > BGP > BGP Utilities
- IP Address Utilities:
Description: Offers tools for private subnet exports and identifies public IPs.
Location: Forward Library > L3 > IPAddressUtils
How to Implement Helper Functions
Each function in the Forward Library includes an import statement, making integration simple:
- Navigate to the relevant NQE (e.g., L3 > Layer 3 Interfaces).
- Copy the import statement provided.
- Paste the import statement into your NQE.( import "@fwd/L3/Layer 3 Interfaces"; )
It’s easy to incorporate the Layer 3 Interfaces helper function into your own NQE:
import "@fwd/L3/Interface Utilities";
foreach device in network.devices
foreach interface in getL3Interfaces(device)
let ip = (foreach address in interface.ipv4.addresses select address.ip)
select {
device: device.name,
intName: interface.name,
ip
}
Get Started Today
Explore the Forward Library to unlock the full potential of helper functions. Whether you need to streamline inventory management, enhance compliance checks, or simplify data retrieval, these utilities provide a powerful foundation for success.
Do you have a favorite helper function? Share it below!