Security Manager API
Project description
Python library for FireMon APIs
Developed using Python 3.8.0 and requests 2.20.1
Table of Contents
- About The Project
- Setup
- Dependencies
- Policy Planner Usage
- Security Manager Usage
- Policy Optimizer Usage
- Orchestration API Usage
- Project Structure
- Flow of Execution
- License
About The Project
This library/project is created to jumpstart your Orchestration API, Policy planner API, Security Manager API, or Policy Optimizer API projects.
Setup
Setup - PyPi Install:
- To install the library, run the following command from the terminal.
pip install security-manager-apis
Setup - PyPi Upgrade:
To upgrade the library, run the following command from the terminal.
pip install --upgrade security-manager-apis
pip install -e .
If you don't plan to make any modifications to the project but still want to use it across your different projects, then do a local install.
pip install .
This will install all the dependencies listed in the setup.py
file. Once done
you can use the library wherever you want.
Policy Planner Configuration
Required Fields - Make sure you pass these fields while creating instance of PolicyPlannerApis:
- host: Pointing to your firemon server.
- username: The username that would be used to create the API connection to firemon.
- password: The API password for the given user.
- domain_id: The Domain ID for the targeted workflow.
- workflow_name: The name of the targeted workflow.
- verify_ssl: Enabled by default. If you are running demo/test environment, good chance you'll need to set this one to
false
.
Optional Fields - These fields may be passed when creating an instance of PolicyPlannerApis, but will default if not:
- suppress_ssl_warning: Set to False by default. Will supress any SSL warnings when set to True.
Dependencies
Pre-requisite - Python 3.6 or greater version should be installed on your machine.
Upgrade pip on Mac:
- NOTE : This is important because, apparently, some Mac apps rely on Python 2 version, so if you attempt to upgrade the Python 2.x to Python 3.x on Mac OS, you will eventually break some apps, perhaps critical apps. With that in mind, you should not attempt to upgrade the current preinstalled Python release on the Mac; instead, you will just have the co-installation of Python 3 for full compatibility.
brew install python3
Upgrade pip on Windows:
python -m pip install --upgrade pip
Policy Planner Usage
Initializing a Policy Planner Class
from security_manager_apis import policy_planner
policyplan = policy_planner.PolicyPlannerApis(host: str, username: str, password: str, verify_ssl: bool, domain_id: str, workflow_name: str, suppress_ssl_warning: bool)
- host: Pointing to your firemon server.
- username: The username that would be used to create the API connection to firemon.
- password: The API password for the given user.
- domain_id: The Domain ID for the targeted workflow.
- workflow_name: The name of the targeted workflow.
- verify_ssl: Enabled by default. If you are running demo/test environment, good chance you'll need to set this one to
False
. - suppress_ssl_warning: Set to False by default. Will supress any SSL warnings when set to
True
.
Create a Policy Planner Ticket
policyplan.create_pp_ticket(request_body: dict)
- request_body: JSON of ticket to be created.
Request JSON Example:
{
"variables": {
"summary": "string",
"businessNeed": "string",
"priority": "string",
"dueDate": "YYYY-MM-DD HH:MM:SS",
"applicationName": "string",
"customer": "string",
"externalTicketId": "string",
"notes": "string",
"requesterName": "string",
"requesterEmail": "string",
"applicationOwner": "string",
"carbonCopy": [
"string",
"string"
]
},
"policyPlanRequirements": [
{
"sources": [
"string",
"string"
],
"destinations": [
"string",
"string"
],
"action": "string",
"services": [
"string",
"string"
],
"requirementType": "string",
"childKey": "string",
"variables": {}
}
]
}
Update a Policy Planner Ticket
policyplan.update_pp_ticket(ticket_id: str, request_body: dict)
- ticket_id: ID of ticket to be updated.
- request_body: JSON of updates to apply to the ticket.
Request JSON Example:
{
"variables": {
"summary": "string"
}
}
Retrieving a Policy Planner Ticket
policyplan.pull_pp_ticket(ticket_id: str)
- ticket_id: ID of ticket to be retrieved.
Assigning a Policy Planner Ticket
policyplan.assign_pp_ticket(ticket_id: str, user_id: str)
- ticket_id: ID of ticket to assign user to.
- user_id: ID of user to be assigned.
Adding a Requirement to a Policy Planner Ticket
policyplan.add_req_pp_ticket(ticket_id: str, req_json: dict)
- ticket_id: ID of ticket to add requirement to.
- req_json: JSON of requirement to be added.
Requirement JSON Example:
{
"requirements":[
{
"requirementType":"RULE",
"changes":[],
"childKey":"add_access",
"variables":{
"expiration":"2022-001-01T00:00:00+0000"
},
"destinations":[
"10.1.1.1/24"
],
"services":[
"tcp/22"
],
"sources":[
"10.0.0.0/24"
],
"action":"ACCEPT"
}
]
}
Completing a Policy Planner Ticket Task
policyplan.complete_task_pp_ticket(ticket_id: str, button_action: str)
- ticket_id: ID of ticket to add requirement to.
- button_action: Button value, options are: submit, complete, autoDesign, verify, approved
Running PCA for a Policy Planner Ticket
policyplan.run_pca(ticket_id: str, control_types: str, enable_risk_sa: str)
- ticket_id: ID of ticket to run PCA on.
- control_types: Control types as string array. Options: ALLOWED_SERVICES, CHANGE_WINDOW_VIOLATION, DEVICE_ACCESS_ANALYSIS, DEVICE_PROPERTY, DEVICE_STATUS, NETWORK_ACCESS_ANALYSIS, REGEX, REGEX_MULITPATTERN, RULE_SEARCH, RULE_USAGE, SERVICE_RISK_ANALYSIS, ZONE_MATRIX, ZONE_BASED_RULE_SEARCH
- enable_risk_sa: true or false
Retrieving PCA from a Policy Planner Ticket
policyplan.retrieve_pca(ticket_id: str)
- ticket_id: ID of ticket to retrieve PCA from.
Adding Attachment to a Policy Planner Ticket
policyplan.add_attachment(ticket_id: str, file_name: str, f, description: str):
- ticket_id: ID of ticket to add attachment to.
- filename: File name of attachment.
- f: Binary of file.
- description: Binary of file.
Adding Attachment Code Example:
file_name = "test_file.txt"
with open(file_name, 'rb') as f:
policyplan.add_attachment('38', file_name, f, 'test upload')
Retrieving Requirements from a Policy Planner Ticket
policyplan.get_reqs(ticket_id: str)
- ticket_id: ID of ticket to retrieve requirements from.
Deleting Requirements from a Policy Planner Ticket
policyplan.del_all_reqs(ticket_id: str)
- ticket_id: ID of ticket to delete requirements from.
Approving Requirement in a Policy Planner Ticket
policyplan.approve_req(ticket_id: str, req_id: str)
- ticket_id: ID of ticket that the requirement is tied to.
- req_id: ID of requiremnt to approve.
Add Comment to Policy Planner Ticket
policyplan.add_comment(ticket_id: str, comment: str)
- ticket_id: ID of ticket to add comment to.
- comment: Content of comment.
Retrieve All Policy Planner Ticket Comments
policyplan.get_comments(ticket_id: str)
- ticket_id: ID of ticket to retrieve comments from.
Delete Comment from Policy Planner Ticket
policyplan.del_comment(ticket_id: str, comment: str)
- ticket_id: ID of ticket to delete comment from.
- comment_id: ID of comment to delete.
Security Manager Usage
Initializing a Security Manager Class
from security_manager_apis import security_manager
securitymanager = security_manager.SecurityManagerApis(host: str, username: str, password: str, verify_ssl: bool, domain_id: str, suppress_ssl_warning: bool)
- host: Pointing to your firemon server.
- username: The username that would be used to create the API connection to firemon.
- password: The API password for the given user.
- verify_ssl: Enabled by default. If you are running demo/test environment, good chance you'll need to set this one to
False
. - domain_id: The Domain ID for the targeted workflow.
- suppress_ssl_warning: Set to False by default. Will supress any SSL warnings when set to
True
.
Get List of Devices in Security Manager
security_manager.get_devices()
Manual Device Retrieval
security_manager.manual_device_retrieval(device_id: str)
- device_id: ID of device to retrieve.
Policy Optimizer Usage
Initializing a Policy Optimizer Class
from security_manager_apis import policy_optimizer
policyoptimizer = policy_optimizer.PolicyOptimizerApis(host: str, username: str, password: str, verify_ssl: bool, domain_id: str, suppress_ssl_warning: bool)
- host: Pointing to your firemon server.
- username: The username that would be used to create the API connection to firemon.
- password: The API password for the given user.
- verify_ssl: Enabled by default. If you are running demo/test environment, good chance you'll need to set this one to
False
. - domain_id: The Domain ID for the targeted workflow.
- suppress_ssl_warning: Set to False by default. Will supress any SSL warnings when set to
True
.
Orchestration API Usage
Initializing an Orchestration API Class
from security_manager_apis import orchestration_apis
orchestration = orchestration_apis.OrchestrationApis(host: str, username: str, password: str, verify_ssl: bool, domain_id: str, suppress_ssl_warning=False)
- host: Pointing to your firemon server.
- username: The username that would be used to create the API connection to firemon.
- password: The API password for the given user.
- verify_ssl: Enabled by default. If you are running demo/test environment, good chance you'll need to set this one to
False
. - domain_id: The Domain ID for the targeted workflow.
- suppress_ssl_warning: Set to False by default. Will supress any SSL warnings when set to
True
.
Running Rule Recommendation
orchestration.rulerec_api(params: dict, req_json: dict)
- params: Parameters to use for recommendation.
- req_json: JSON of requirements to provide recommendation for.
Parameters Example
parameters = {'deviceGroupId': 1, 'addressMatchingStrategy': 'INTERSECTS', 'modifyBehavior': 'MODIFY', 'strategy': None}
Requirements Example
{
"requirements":[
{
"requirementType":"RULE",
"changes":[],
"childKey":"add_access",
"variables":{
"expiration":"2022-001-01T00:00:00+0000"
},
"destinations":[
"10.1.1.1/24"
],
"services":[
"tcp/22"
],
"sources":[
"10.0.0.0/24"
],
"action":"ACCEPT"
}
]
}
Running Pre-Change Assessment
orchestration.pca_api(device_id: str, req_json: dict)
- device_id: ID of device to use when running Pre-Change Assessment.
- req_json: JSON of requirements to provide recommendation for.
Requirements Example
{
"requirements":[
{
"requirementType":"RULE",
"changes":[],
"childKey":"add_access",
"variables":{
"expiration":"2022-001-01T00:00:00+0000"
},
"destinations":[
"10.1.1.1/24"
],
"services":[
"tcp/22"
],
"sources":[
"10.0.0.0/24"
],
"action":"ACCEPT"
}
]
}
Project Structure
application.properties
- All the required URLS are placed here.get_properties_data.py
- Read the properties file data and returns a parserpolicy_planner.py
- Class to use Policy Planner APIssecurity_manager.py
- Class to use Security Manager APIspolicy_optimizer.py
- Class to use Policy Optimizer APIsorchestration_apis.py
- Class to use Crchestration APIs
Flow of Execution
As soon as you execute the command to run this library, Authentication class will be called which will internally call get_auth_token() of authentication_api.py
from authenticate_user
module only once and
auth token will be set in the headers.
Then we pass headers to the HTTP requests so that user should get authenticated and can access the endpoints safely.
License
MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for security-manager-apis-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f552c1ba1bbda99498421acda053452cfce9c1bd7a16d757c362d7de94237afc |
|
MD5 | 0d23c17b7c98e3038f1e8794d9918db0 |
|
BLAKE2b-256 | a00c0bdf462928e7e20ffc1818046d833f30d12296b3425798f44c9831adc1a0 |
Hashes for security_manager_apis-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8740e9209ecf5bd65b1b5e23787b887761e224685d7153d967dc88afb67b1def |
|
MD5 | c189bbb5d96c009d4b89f01d45d8b069 |
|
BLAKE2b-256 | 40a86673bd852f35ab79c7bb1d7de5e8cf963f73f883ab15d2ccd00b0d93f2e1 |