-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from coopsdev/FortiGate
Begin adding basic firewall policy control
- Loading branch information
Showing
10 changed files
with
413 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
class Pkg(ConanFile): | ||
name = "forti_api" | ||
version = "0.1.6" | ||
version = "0.1.7" | ||
author = "Cooper Larson | [email protected]" | ||
url = "" | ||
description = "FortiGate API interface" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// Created by Cooper Larson on 8/31/24. | ||
// | ||
|
||
#ifndef FORTI_API_FIREWALL_HPP | ||
#define FORTI_API_FIREWALL_HPP | ||
|
||
#include "api.hpp" | ||
#include "include/forti_api/types/policy.h" | ||
|
||
namespace FortiGate { | ||
|
||
class Policy { | ||
inline static std::string endpoint = "/cmdb/firewall/policy"; | ||
|
||
public: | ||
static std::vector<FirewallPolicy> get() { return FortiAPI::get<FirewallPoliciesResponse>(endpoint).results; } | ||
|
||
static FirewallPolicy get(const std::string& name) { | ||
auto policies = get(); | ||
for (const auto& policy : policies) if (policy.name == name) return policy; | ||
throw std::runtime_error("Unable to locate firewall policy: " + name); | ||
} | ||
|
||
static void update(const FirewallPolicy& policy) { | ||
FortiAPI::put(std::format("{}/{}", endpoint, policy.policyid), policy); | ||
} | ||
}; | ||
|
||
} | ||
|
||
|
||
#endif //FORTI_API_FIREWALL_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
|
||
#include "api.hpp" | ||
#include <string> | ||
#include <nlohmann/json.hpp> | ||
|
||
|
||
struct SystemResponse { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters