-
Notifications
You must be signed in to change notification settings - Fork 34
/
PKG-INFO
357 lines (258 loc) · 13.6 KB
/
PKG-INFO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
Metadata-Version: 2.1
Name: pyFortiManagerAPI
Version: 0.1.1
Summary: A Python wrapper for the FortiManager REST API
Home-page: https://github.com/akshaymane920/pyFortiManagerAPI
Author: Akshay Mane
Author-email: [email protected]
License: UNKNOWN
Description: # pyFortiManagerAPI
A Python wrapper for the FortiManager REST API.
## Installation
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install pyFortiManagerAPI.
```shell script
pip install pyFortiManagerAPI
```
## Getting Started
1. Creating Instance of the Module
```python
import pyFortiManagerAPI
fortimngr = pyFortiManagerAPI.FortiManager(host="",
username="",
password="",
adom="")
```
- host: Management Ip address of your FortiManager
- username/password: Specify your credentials to log into the device.
- adom: Specify in which Adom you want to play.
# User Operations : Adoms
### 1) Get all adoms from the FortiManager.
```python
>>> fortimngr.get_adoms()
```
```python
>>> fortimngr.get_adoms(name="root")
```
- ## Parameters
* name: Can get specific adom using name as a filter.
# User Operations : Policy Package
### 2) Get all the policy packages configured on FortiManager.
```python
>>> fortimngr.get_policy_packages()
```
```python
>>> fortimngr.get_policy_packages(name="default")
```
- ## Parameters
* name: Can get specific package using name as a filter.
### 3) Add your own policy package in FortiManager.
```python
>>> fortimngr.add_policy_package(name="TestPackage")
```
- ## Parameters
* name: Specify the Package Name.
# User Operations : Address Objects
### 4) Get all address objects from FortiManager.
```python
>>> fortimngr.get_firewall_address_objects()
```
### 5) Get specific address object from FortiManager using "name" Filter.
```python
>>> fortimngr.get_firewall_address_objects(name="YourObjectName")
```
- ## Parameters
* name: Specify object name that you want to see.
### 6) Create an address object.
```python
>>> fortimngr.add_firewall_address_object(name="TestObject",
associated_interface="any",
subnet=["1.1.1.1", "255.255.255.255"]
)
```
- ## Parameters
* name: Specify object name that is to be created
* associated_interface: Provide interface to which this object belongs if any. {Default is kept any}
* subnet: Specify the subnet in a list format eg.["1.1.1.1", "255.255.255.255"]
### 7) Update address object.
```python
>>> fortimngr.update_firewall_address_object(name="TestObject",
associate_interface="port1",
comment="Updated using API",
subnet=["2.2.2.2","255.255.255.255"]
)
```
- ## Parameters
* name: Enter the name of the object that needs to be updated
* data: You can get the **kwargs parameters with "show_params_for_object_update()" method
### 8) Delete address object.
```python
>>> fortimngr.delete_firewall_address_object(object_name="TestObject")
```
- ## Parameters
* object_name: Specify the Object name you want to delete.
---
# User Operations : Address Groups
### 9) Get all address groups.
```python
>>> fortimngr.get_address_groups()
```
### 10) Get specific address group.
```python
>>> fortimngr.get_address_groups(name="TestGroup")
```
- ## Parameters
* name: Specify the name the address group.
### 11) Create your own address group.
```python
>>> fortimngr.add_address_group(name="Test_Group",
members=["TestObject1"])
```
- ## Parameters
* name: Enter the name of the address group. eg."Test_Group"
* members: pass your object names as members in a list eg. ["TestObject1", "TestObject2"]
> Note: An address group should consist atleast 1 member.
### 12) Update the address group.
```python
>>> fortimngr.update_address_group(name="Test_Group",
object_name="TestObject3",
do="add")
```
- ## Parameters
* name: Specify the name of the Address group you want to update
* object_name: Specify name of the object you wish to update(add/remove) in Members List
* do: Specify if you want to add or remove the object from the members list
do="add" will add the object in the address group
do="remove" will remove the object from address group
### 13) Delete the address group.
```python
>>> fortimngr.delete_address_group(name="Test_group")
```
- ## Parameters
* name: Specify the name of the address group you wish to delete
---
# User Operations : Policies
### 14) Get all the policies in your Policy Package.
```python
>>> fortimngr.get_firewall_policies(policy_package_name="YourPolicyPackageName")
```
- ## Parameters
* policy_package_name: Enter the policy package name.
### 15) Get specific policiy in your Policy Package using PolicyID filter.
```python
>>> fortimngr.get_firewall_policies(policy_package_name="YourPolicyPackageName", policyid=3)
```
- ## Parameters
* policy_package_name: Enter the policy package name.
* policyid: Can filter and get the policy you want using policyID
### 16) Create your own policy in your Policy Package.
```python
>>> fortimngr.add_firewall_policy(policy_package_name="YourPolicyPackageName",
name="YourPolicyName",
source_interface="port1",
source_address="all",
destination_interface="port2",
destination_address="all",
service="ALL_TCP",
logtraffic=2
)
```
- ## Parameters
* policy_package_name: Enter the name of the policy package eg. "default"
* name: Enter the policy name in a string format eg. "Test Policy"
* source_interface: Enter the source interface in a string format eg. "port1"
* source_address: Enter the src. address object name in string format eg. "LAN_10.1.1.0_24"
* destination_interface: Enter the source interface in a string format eg. "port2"
* destination_address: Enter the dst. address object name eg. "WAN_100.25.1.63_32"
* service: Enter the service you want to permit or deny in string eg. "ALL_UDP"
* schedule: Schedule time is kept 'always' as default.
* action: Permit(1) or Deny(0) the traffic. Default is set to Permit.
* logtraffic: Specify if you need to log all traffic or specific in int format.
* logtraffic=0 Means No Log
logtraffic=1 Means Log Security Events
logtraffic=2 Means Log All Sessions
### 17) Update the policy in your Policy Package.
```python
>>> fortimngr.update_firewall_policy(policy_package_name="YourPolicyPackageName",
policyid=10,
source_interface="port2",
action=1,
)
```
- ## Parameters
* policy_package_name: Enter the policy package name in which you policy belongs.
* policyid: Enter the Policy ID you want to edit
* data: You can get the **kwargs parameters with "show_params_for_policy_update()" method
### 18) Delete the policy in your Policy Package.
```python
>>> fortimngr.delete_firewall_policy(policy_package_name="YourPolicyPackageName",
policyid=10)
```
- ## Parameters
* policy_package_name: Enter the policy package name in which you policy belongs
* policyid: Enter the policy ID of the policy you want to delete
### 19) Move Firewall Policy.
```python
>>> fortimngr.move_firewall_policy(policy_package_name="LocalLab",
move_policyid=10,
option="after",
policyid=2)
```
- ## Parameters
* policy_package_name: Enter the policy package name in which you policy belongs.
* move_policyid: Enter the policy ID of the policy you want to move.
* option: Specify if you want to move the policy above("before") the target policy or below("after") {default: before}.
* policyid: Specify the target policy.
---
# User Operations : Installing the Policy Package.
### 20) Installing the Policy Package.
```python
>>> fortimngr.install_policy_package(package_name="Your Policy Package name")
```
- ## Parameters
* package_name: Enter the package name you wish to install
---
# Show Params for updation of Policies and Objects.
### 21) Parameters for updating Address Object.
```python
>>> fortimngr.show_params_for_object_update()
```
Parameters to create/update address object:
PARAMETERS FIREWALL OBJECT SETTINGS
allow_routing(int) : Static Route Configuration
associated_interface(str) : Interface
comment(str) : Comments
object_name(str) : Address Name
subnet[list] : IP/Netmask
object_type(int) : Type
### 22) Parameters for updating Policy.
```python
>>> fortimngr.show_params_for_policy_update()
```
Parameters to create/update Policy:
PARAMETERS FIREWALL POLICY SETTINGS
name(str) : Name
source_interface(str) : Incoming Interface
source_address(str) : Source Address
destination_interface(str) : Destination Interface
destination_address(str) : Destination Address
service(str) : Service
schedule(str) : Schedule
action(int) : Action
logtraffic(int) : Log Traffic
comment(str) : Comments
## Future Tasks
- This module is tested on Fortimanager v6.2.2 on "root" adom. It still doesn't support multiple Adoms. So I will try to get this working for Multiple adoms too.(This task is now achieved in version v0.1)
- To update any object or firewall policies we need to pass data in Dictonary and this seems to be slightly complicated. I will try to simplify this too. (This task is now achieved in version v0.0.44)
- To get, add, update and delete adoms, devices and interfaces.
## Contributing
- Being new to Python and this being my first publish, to get this module fully working for all of us, the Pull requests are welcome.
## License
[MIT](https://github.com/akshaymane920/pyFortiManagerAPI/blob/master/LICENSE.txt)
Keywords: Fortimanager,RestAPI,API,Fortigate,Fortinet,python,Fortimanager Rest API,Fortimanager Rest API Python,Python examples
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown