Skip to content

Releases

v1.3.0 — Threat feed status and paging without downloading the feed

Choose a tag to compare

@github-actions github-actions released this 18 Oct 15:29

feed_status: a feed's counters in one request

fortiapi::system::feed_status(feed) returns a FeedStatus (loaded, error, file_status,
accepted, valid, invalid, limit, overflow, last_update) from a single
monitor/system/external-resource/entry-list request that transfers no entries, so checking a
feed of a million entries costs the same as one of five. Use it to wait for a new feed to load
(loaded, with error "Connect pending" until then), to confirm that a push was applied
(last_update, in Unix seconds, advances a few seconds after the push) and to watch capacity:
limit is the device-wide entry cap all feeds share (1000000 on a FortiGate-60F), and overflow
is FortiOS's flag that a feed is over it. Numbers sent as text are read too; missing values stay 0.

FortiOS counts valid_count and invalid_count only up to the end of the requested window
(asked for the first entry, it reports one valid entry however large the feed), so feed_status
asks for one entry at a start no feed reaches and gets the counts of the whole feed.

feed_entries: one page of entries

fortiapi::system::feed_entries(feed, start, count) returns entries [start, start + count) in
FortiOS order, paged by FortiOS (one request), for verifying a sample of a large feed. Past the end
or before the feed is loaded the page is short or empty; count 0 returns nothing without a
request, since FortiOS would read it as "every entry".

feed_state still returns every entry. Validated live on FortiOS 7.4.8: a push of four domains, an
exact duplicate and one invalid entry reports 4 accepted, 4 valid, 1 invalid, and the pages
reassemble the full list. See the threat feeds guide.

Live suite

FORTI_API_LIVE_NO_PURGE=1 skips the suite's leftover purge, for a run beside forti-api-test-*
objects another run or an operator still uses; each test still removes what it created.

v1.2.0 — Child tables: change one DHCP reservation, not the whole list

Choose a tag to compare

@github-actions github-actions released this 17 Oct 19:06

One entry of a table attribute at a time

fortiapi::ChildTable<Spec, &Type::attribute> (also Table<Spec>::child<&Type::attribute>) reads
and writes single entries of a table attribute on FortiOS's child paths,
cmdb/<path>/<parent key>/<attribute>[/<entry key>]: list, find, get, contains, add,
update and del. Until now the only way to change one DHCP reservation, one address in a
policy's srcaddr or one access-list rule was Table::update with the whole list, so a bug in that
list could drop or change the other entries. Now each write touches one entry:

using Reservations = fortiapi::system::dhcp::Servers::child<&fortiapi::system::dhcp::Server::reserved_address>;
fortiapi::system::dhcp::Server::ReservedAddressEntry entry;
entry.id = 0u;                         // the device assigns the next id
entry.ip = "192.0.2.50";
entry.mac = "00:00:5e:00:53:32";
Reservations::add(1, entry);           // POST cmdb/system.dhcp/server/1/reserved-address
Reservations::del(1, 7);               // DELETE cmdb/system.dhcp/server/1/reserved-address/7
  • update sends only the entry's modified and cleared attributes, to the entry's own path.
  • Keys are encoded like table keys (one path segment each; . and .. are sent as %2E and
    %2E%2E), entries decode with the usual from_json, writes are never re-sent, and a missing
    entry or parent is an ApiError with not_found() (find returns std::nullopt).
  • It works for every table attribute of a generated table: every generated ...Entry struct now
    names its key member (static constexpr auto mkey = &Entry::id;, from the schema's mkey), and so
    does fortiapi::Ref (name).
  • Adding an entry whose key exists fails (HTTP 500, FortiOS error -5) and changes nothing; a PUT
    never creates a missing entry.
  • Reply gains child_path and child_mkey, and for every write http_method, old_revision and
    revision_changed. On child paths mkey names a different key per method: the new entry on POST,
    the parent on PUT, the entry on DELETE (PUT and DELETE also report the entry as child_mkey).
    ChildTable::add stores a device-assigned key from child_mkey, or from mkey of a child POST
    reply, and never overwrites a key the caller set.

Validated live on FortiOS 7.4.8 (address-group members and access-list rules), including concurrent
writers: adds and entry updates from separate clients never lose each other's changes, while a PUT of
the parent that includes the table still replaces it silently. A GET's revision compared with a
write's old_revision shows that something else wrote to the table in between. See the child tables
guide.

Child tables in the runtime schema

fortiapi::schema gains the same child tables for attributes chosen at run time, so a program that
handles any endpoint (forti's command engine) needs no typed model for them. child_table(endpoint, attribute) finds a table attribute with keyed entries. child_path(endpoint, attribute, parent, &entry) builds exactly ChildTable::path. created_entry_key(attribute, reply) returns the key of
the entry a POST created, by the rule ChildTable::add uses, which now has one shared definition.

v1.1.1 — Builds on macOS 15, faster-starting consumers, APT key updates

Choose a tag to compare

@github-actions github-actions released this 16 Oct 22:21

Builds on macOS 15 and Intel Macs again

forti-api 1.1's runtime schema parsed decimal numbers with floating-point std::from_chars, which
Apple's libc++ provides only from Xcode 26: every consumer failed to compile on macOS 15 (Xcode 16),
including Homebrew source builds there and on Intel Macs. Decimal numbers that FortiOS sends as text
are now parsed through the JSON number grammar (locale-independent, whole text only, as before);
integers still use from_chars. FortiOS 7.4.8 has no decimal attributes, so typical reads never take
that path.

Faster process start for SDK consumers

The runtime schema's tables (forti_api/gen/schema.hpp) now have hidden visibility. With default
visibility each was a weak exported symbol, and an executable using the schema spent about 20 ms at
every start resolving thousands of them (forti-cli: 13,600 load-time binds, 25 ms to start; now 600 and
5 ms), with no flag needed in the consumer.

APT signing key updates arrive through upgrades

libforti-api-dev now recommends valkyrianlabs-archive-keyring, the package that carries the Valkyrian Labs
APT repository's signing key. Installing libforti-api-dev from the repository installs it (APT installs recommended packages by default), and from then on any change
to the key (such as the removal of its expiry date) reaches the machine through normal upgrades
instead of a manual re-download.

  • The package owns /usr/share/keyrings/valkyrianlabs.gpg. An unmodified copy of the key at
    /etc/apt/keyrings/valkyrianlabs.gpg (the path the installation docs used) is replaced by a link to
    it, so existing signed-by= source lines keep working unchanged; a modified file is left alone.
  • It is a recommendation, not a hard dependency, so the standalone .deb from a GitHub release still
    installs on a system without the repository configured. On machines that already have the package,
    install the keyring once with sudo apt install valkyrianlabs-archive-keyring.

v1.1.0 — Trust on first use, and a lighter schema for consumers

Choose a tag to compare

@github-actions github-actions released this 16 Oct 17:13

See a device's certificate before trusting it

fortiapi::probe_tls(config) (forti_api/tls.hpp) connects to the FortiGate, completes the TLS
handshake and stops: no HTTP request, no API key, no client certificate. It reports whether the
certificate verified, and the chain as presented, so a person can inspect a self-signed or factory
certificate and pin it as the ca_bundle. The device's own certificate works as a trust anchor, and
the host name is still verified. It also reports the local address of the connection, which is what
the FortiGate sees (before any NAT), for example for an API user's trusted host. TLS verification of
requests is unchanged: it cannot be turned off.

Every endpoint as data: the runtime schema

forti_api/schema.hpp describes every generated endpoint as data, with plain functions that decode,
validate and build request bodies for any of them. It is for programs that pick
the endpoint at run time (a CLI, an MCP server, a validator), which until now had to compile the typed
model of every endpoint to get the SDK's behavior: several GB of compiler memory and minutes of build
time. A translation unit that includes the runtime schema compiles in about 2.5 seconds and 360 MB
(Apple clang, -O0) and includes no typed model. The typed API is unchanged.

namespace schema = fortiapi::schema;
const schema::Endpoint* ep = schema::find("cmdb/firewall/address");
nlohmann::json post = schema::create_body(*ep->type, {{"name", "web"}, {"subnet", "192.0.2.10/32"}});
fortiapi::default_client().post(ep->path, post);
  • Tables (gen/schema.hpp, generated with the typed headers): for every endpoint its path, kind
    (table, singleton, monitor), object type and table key; for every attribute its key, C++ type,
    reset value and read-only flag in visit() order, nested types, and the FortiOS schema metadata
    that was only in comments so far: options, integer ranges, string sizes, references (datasources),
    required, help. fortiapi::gen::fortios_version names the FortiOS version (7.4.8).
  • Functions: decode (exactly from_json<T>: results and error messages), writable,
    create_body and update_body (the bodies Table::add and Table::update send), diff, key_of
    and object_path (the object's key and API path), and the advisory check_values (options, ranges,
    sizes). Invalid bodies throw schema::ValidationError with a reason and the attributes involved.
  • Checked against the typed models: a unit test compares both on generated inputs (descriptions,
    decoded values, request bodies, keys, paths and every error message) for a sample of endpoints that
    covers every attribute kind; the weekly exhaustive build compares all 534 endpoints (about 72,000
    inputs).

Faster CI

  • CI builds once per job and runs the tests on that build: the network-free unit suite at -O0 without
    debug info, under AddressSanitizer and UndefinedBehaviorSanitizer on Linux, on every core the memory
    allows. It no longer builds the live suite, whose coverage test needed about 6 GB of compiler memory
    in one translation unit. The live suite and the full schema comparison build in a separate workflow,
    on demand and weekly, in 10 shards each.
  • Releases test an -O3 build of the unit suite before publishing.
  • The standalone header check compiles the hand-written headers (11) instead of every generated
    header (582); fortios.py check already proves the generated ones.

v1.0.2 — Documentation in Payload Markdown

Choose a tag to compare

@github-actions github-actions released this 16 Oct 02:20

The forti-api documentation is now authored with Payload Markdown directives, so the docs site
renders it as structured pages instead of plain Markdown. The content is the same, checked against
the headers; new tables summarize it. The SDK headers and the packages are unchanged.

  • Installation puts APT, Homebrew, vendoring and the source build side by side in tabs, with a
    table of where each method puts the headers and forti-api.pc.
  • Quick start and Testing are numbered steps, and the quick start gains a table of the
    Table and Singleton operations.
  • Warnings are callouts: authentication lockout, writes whose outcome is unknown, partial
    creates, tables sent whole, dot-segment keys, helpers that write to every matching DNS filter
    profile, configuration backups as credentials, and the live FortiGate test rules.
  • The overview links every section through cards, with release, CI and license badges.
  • Reference and guides: the configuration reference separates environment variables from
    code-only fields, the retry policy is a table, and the download calls and filter expressions
    are summarized in tables.

v1.0.1 — Raw downloads, configuration backups and write safety

Choose a tag to compare

@github-actions github-actions released this 15 Oct 14:07

forti-api can now fetch endpoints that answer with a file instead of JSON, most importantly the
FortiOS configuration backup, so tools can take a backup before a critical change.

auto backup = fortiapi::Monitor::download("system/config/backup",
                                          fortiapi::Query().set("scope", "global"));
// backup.body starts with "#config-version=", backup.content_type, backup.content_disposition
  • Client::download(api_path, query, options) (and an overload taking a method and JSON body)
    returns the reply as raw bytes, text or binary, with the HTTP status, Content-Type and
    Content-Disposition. It uses the same connection, authentication, TLS verification, timeouts
    and retry policy as every other call. HTTP errors still raise ApiError, with the FortiOS error
    code and CLI messages when the error body is JSON.
  • Memory is bounded: DownloadOptions::max_bytes (64 MiB by default) aborts a larger reply with
    SizeLimitError and discards what arrived. DownloadOptions::sink streams the body in chunks,
    for example straight into a file, instead of holding it in memory.
  • Config::on_exchange never receives the body of a successful download.
  • Custom Transport implementations keep compiling unchanged. To bound memory and stream, they can
    honor the new HttpRequest::max_body and on_body fields and fill HttpResponse::headers
    (see the downloads guide).

Configuration backups contain password hashes, keys and the network layout: store them with
owner-only permissions, never log them, and never put them in shared temporary directories.

Validated against FortiOS 7.4.8: GET monitor/system/config/backup?scope=global returns the
configuration as application/octet-stream.

Writes are never sent twice

libcurl re-sends a request on its own when a reused keep-alive connection turns out to be dead.
For a write that had already reached the FortiGate, that meant running it twice: a second firewall
policy with a new id, a delete reported as "not found", a monitor action executed twice. forti-api
now gives every write (POST, PUT, DELETE) its own new connection, which libcurl never re-sends on,
and closes it afterwards. When the connection drops before the reply, the call throws
TransportError with before_send() == false: the write may or may not have happened, and it is
never repeated. Each write pays one TCP and TLS handshake (a few milliseconds on a LAN); reads keep
sharing one kept-alive connection.

Safer object keys and replies

  • A key that is exactly . or .. is sent as %2E / %2E%2E, and paths go out exactly as built.
    Before, libcurl removed such dot segments, so Addresses::del("..") addressed a different path
    than the object named.
  • JSON replies nested deeper than Config::max_reply_depth (256 by default) are refused with a
    DecodeError, so a hostile or broken peer cannot make later copies or dumps of the reply
    overflow the stack.

Meson subprojects

Used as a Meson subproject, forti-api no longer builds its example and tests and no longer installs
its headers and forti-api.pc alongside your project. dependency('forti-api') and
forti_api_dep work as before.

v1.0.0 — The complete FortiOS SDK

Choose a tag to compare

@github-actions github-actions released this 14 Oct 21:40

forti-api is rebuilt around the FortiGate's own schema: every configuration endpoint FortiOS 7.4.8
reports is generated, writes change exactly what you changed, and the transport is careful about
what it sends and repeats. This release breaks the previous API on purpose (migration table below).

Every endpoint, generated

  • All 487 configuration (cmdb) endpoints a FortiGate-60F reports on FortiOS 7.4.8: firewall,
    system, router, VPN, user, log, security profiles, switch and wireless controllers and more,
    each as a struct with every attribute documented, plus a Table (list, find, get,
    contains, add, update, del, schema) or Singleton (get, update). Every one decodes
    every object on a live device (35,000+ objects verified).
  • Typed read-only monitor endpoints for what the web GUI reads (fortiapi::monitor::system::Time::get()),
    generated from recorded response shapes; every other monitor call goes through fortiapi::Monitor.
  • Option constants live in their type: firewall::Policy::Action::deny.
#include <forti_api/firewall.hpp>
using namespace fortiapi;

auto address = firewall::Addresses::get("LAN 10.0.0.0/24");   // keys are URL-encoded for you
address.comment = "managed";
firewall::Addresses::update(address);                         // sends {"comment": "managed"} only

Writes change exactly what you changed

Every attribute is a Field<T> that knows whether it is absent, read from the device, modified or
cleared. An update sends only modified and cleared attributes (clear() resets one to its FortiOS
default); reads never mark anything changed; read-only attributes are never sent. A create sends
only what you set and FortiOS fills in its own defaults.

A careful transport: fortiapi::Client

  • Connect and request timeouts, one kept-alive connection per client, TLS verified against the
    system trust store (or a configured CA), optional client certificate, FORTIGATE_RESOLVE_IP to
    pin the address while verifying the hostname.
  • Object names are percent-encoded; a Query builder covers vdom, filter, format,
    start/count, datasource, with_meta, skip and action.
  • Errors are exceptions: ApiError (HTTP status, FortiOS error code, CLI messages), TransportError,
    DecodeError (naming the attribute that did not match). Nothing is printed.
  • Reads retry on throttling and gateway errors; configuration changes are never retried once they
    may have reached the device.

Helpers

DNS filter categories (block_category, allow_category_everywhere, ...), push threat feeds
(push_entries reports rejected commands, feed_state, delete_threat_feed frees the category
first), schedule days, service port ranges, API-user trusted hosts (IPv4/IPv6, CIDR) and live
interface addresses.

Install

  • Debian/Ubuntu: sudo apt install libforti-api-dev from the ValkyrianLabs APT repository.
  • Homebrew (macOS and Linux): brew install valkyrianlabs/tap/forti-api.
  • Or vendor include/ and third_party/nlohmann/include/; libcurl is the only system dependency.
  • Documentation is published with the release (docs set forti-api).

Migrating from 0.x

Before Now
FortiAuth::set_vars_from_env() automatic (Config::from_env()), or set_default_client(...)
FortiGate::Policies::get() firewall::Policies::list()
DNSFilter::add(name) / del(name) dnsfilter::Profiles::add(profile) / del(name)
DNSProfile::block_category(c) dnsfilter::block_category(profile, c) + Profiles::update(profile)
DNSFilter::global_allow_category(c) dnsfilter::allow_category_everywhere(c)
ThreatFeed::add(name, category) system::ExternalResources::add(system::push_threat_feed(name, category))
ThreatFeed::update_feed(commands) system::push_entries(feed, entries, FeedCommand::snapshot)
ThreatFeed::get_entry_list(feed) system::feed_state(feed).entries
ThreatFeed::del(name) system::delete_threat_feed(name)
System::Interface::get_wan_ip() system::interface_addresses("wan1")
APIUser::trust(subnet) system::trust(user, subnet) + ApiUsers::update(user)
FirewallSchedule::set_days(...) schedule.day = firewall::days({...})
FirewallService::set_port_range(...) service.tcp_portrange = firewall::port_ranges({...})

Fixed along the way: DNS filter profiles no longer reference a missing domain filter table (which
made creation fail with HTTP 500 after half-creating the profile), category sweeps only write
profiles that use the category, schedule days use FortiOS names, IPv6 trusted hosts get the IPv6
type, and rejected threat-feed pushes raise an error instead of passing silently.

v0.3.0 — Native packages, no Conan

Choose a tag to compare

@github-actions github-actions released this 14 Oct 17:43

forti-api no longer uses Conan. It builds with Meson and ships as a Debian package from the
ValkyrianLabs APT repository.

  • Debian/Ubuntu: sudo apt install libforti-api-dev (after adding
    https://apt.valkyrianlabs.com, see the README). It installs the headers to
    /usr/include/forti_api and forti-api.pc; build with
    pkg-config --cflags --libs forti-api.
  • Vendoring or from source (Linux or macOS): copy include/ and
    third_party/nlohmann/include/, or meson setup build && meson install -C build. libcurl is the
    only system dependency; nlohmann/json 3.12.0 ships with forti-api under
    forti_api/third_party, so it never conflicts with a system nlohmann-json.
  • The headers include their siblings by relative path, so installed headers work from any include
    root, and compile cleanly with -Wall -Wextra -Wpedantic -Werror on GCC 13/14 and Apple Clang.
  • New firewall VIP types (types/firewall/vip.h).