Skip to content

Commit

Permalink
re-factored bitdefender and snipeit views again, started right-click …
Browse files Browse the repository at this point in the history
…integration
  • Loading branch information
subzdev committed Dec 28, 2021
1 parent a66b2bf commit 58d3000
Show file tree
Hide file tree
Showing 14 changed files with 812 additions and 372 deletions.
1 change: 1 addition & 0 deletions api/tacticalrmm/integrations/bitdefender/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
path('endpoints/<int:page_number>/', views.GetEndpointList.as_view()),
# path('endpoint/<str:endpoint_id>/', views.GetEndpoint.as_view())
path('endpoint/quickscan/', views.GetQuickScan.as_view()),
path('endpoint/fullscan/', views.GetFullScan.as_view()),
path('quarantine/', views.GetQuarantine.as_view()),
path('tasks/', views.GetTasks.as_view())
]
149 changes: 88 additions & 61 deletions api/tacticalrmm/integrations/bitdefender/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,104 +6,131 @@
from ..models import Integration
import base64

integration = Integration.objects.get(name="Bitdefender GravityZone")
API_KEY = integration.config['api_key']
BASE_URL = integration.config['api_url']
COMPANY_ID = integration.config['company_id']

class GetEndpointList(APIView):

permission_classes = [IsAuthenticated]

def get(self, request, page_number, format=None):
auth = base64.b64encode((API_KEY + ":").encode("UTF-8")).decode("UTF-8")
authorizationHeader = "Basic " + auth
json = {
"params": {
"perPage": 50,
"page": page_number,
"filters": {
"type": {
"computers": True,
"virtualMachines": True
},
"security": {
"management": {"managedWithBest": True
}},
"depth": {
"allItemsRecursively": True
},
},
integration = Integration.objects.get(name="Bitdefender GravityZone")

json = {
"params": {
"perPage": 50,
"page": page_number,
"filters": {
"type": {"computers": True, "virtualMachines": True},
"security": {"management": {"managedWithBest": True}},
"depth": {"allItemsRecursively": True},
},
"jsonrpc": "2.0",
"method": "getNetworkInventoryItems",
"id": COMPANY_ID
}
result = requests.post(BASE_URL + "v1.0/jsonrpc/network",
json=json,
verify=False,
headers = {
"Content-Type": "application/json",
"Authorization": authorizationHeader
}).json()
},
"jsonrpc": "2.0",
"method": "getNetworkInventoryItems",
"id": integration.company_id,
}
result = requests.post(
integration.base_url + "v1.0/jsonrpc/network",
json=json,
verify=False,
headers={
"Content-Type": "application/json",
"Authorization": integration.auth_header,
},
).json()

return Response(result)


class GetQuickScan(APIView):

class GetQuickScan(APIView):
permission_classes = [IsAuthenticated]

def post(self, request, format=None):
auth = base64.b64encode((API_KEY + ":").encode("UTF-8")).decode("UTF-8")
authorizationHeader = "Basic " + auth
integration = Integration.objects.get(name="Bitdefender GravityZone")

endpoint_array = []
print(request.data['endpoint'])

for endpoint in request.data['quickscan']:
for endpoint in request.data['endpoint']:
endpoint_array.append(endpoint['id'])

json = {
"params": {
"targetIds": endpoint_array,
"type": 1,
"name": "Tactical RMM initiated scan",
"name": "Tactical RMM initiated quick scan",
},
"jsonrpc": "2.0",
"method": "createScanTask",
"id": COMPANY_ID
}
"id": integration.company_id,
}

result = requests.post(
integration.base_url + "v1.0/jsonrpc/network",
json=json,
verify=False,
headers={
"Content-Type": "application/json",
"Authorization": integration.auth_header,
},
).json()

result = requests.post(BASE_URL + "v1.0/jsonrpc/network",
json=json,
verify=False,
headers = {
"Content-Type": "application/json",
"Authorization": authorizationHeader
})
return Response(result)

class GetFullScan(APIView):

permission_classes = [IsAuthenticated]

def post(self, request, format=None):
integration = Integration.objects.get(name="Bitdefender GravityZone")
endpoint_array = []
print(request.data['endpoint'])

for endpoint in request.data['endpoint']:
endpoint_array.append(endpoint['id'])

json = {
"params": {
"targetIds": endpoint_array,
"type": 2,
"name": "Tactical RMM initiated quick scan",
},
"jsonrpc": "2.0",
"method": "createScanTask",
"id": integration.company_id,
}

result = requests.post(
integration.base_url + "v1.0/jsonrpc/network",
json=json,
verify=False,
headers={
"Content-Type": "application/json",
"Authorization": integration.auth_header,
},
).json()

return Response(result)


class GetQuarantine(APIView):

permission_classes = [IsAuthenticated]

def get(self, request, format=None):
auth = base64.b64encode((API_KEY + ":").encode("UTF-8")).decode("UTF-8")
authorizationHeader = "Basic " + auth

integration = Integration.objects.get(name="Bitdefender GravityZone")
json = {

"jsonrpc": "2.0",
"method": "getQuarantineItemsList",
"id": COMPANY_ID
"id": integration.company_id
}
result = requests.post(BASE_URL + "v1.0/jsonrpc/quarantine/computers",

result = requests.post(
integration.base_url + "v1.0/jsonrpc/quarantine/computers",
json=json,
verify=False,
headers = {
"Content-Type": "application/json",
"Authorization": authorizationHeader
"Authorization": integration.auth_header
}).json()

return Response(result)
Expand All @@ -114,23 +141,23 @@ class GetTasks(APIView):
permission_classes = [IsAuthenticated]

def get(self, request, format=None):
auth = base64.b64encode((API_KEY + ":").encode("UTF-8")).decode("UTF-8")
authorizationHeader = "Basic " + auth

integration = Integration.objects.get(name="Bitdefender GravityZone")
json = {
"params": {
"perPage": 100
},
"jsonrpc": "2.0",
"method": "getScanTasksList",
"id": COMPANY_ID
"id": integration.company_id
}
result = requests.post(BASE_URL + "v1.0/jsonrpc/network",

result = requests.post(
integration.base_url + "v1.0/jsonrpc/network",
json=json,
verify=False,
headers = {
"Content-Type": "application/json",
"Authorization": authorizationHeader
"Authorization": integration.auth_header
}).json()

return Response(result)
16 changes: 8 additions & 8 deletions api/tacticalrmm/integrations/meraki/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from . import views

urlpatterns = [
path('organizations/', views.GetOrganizations.as_view()),
path('<str:pk>/networks/', views.GetNetworks.as_view()),
path('<str:pk>/devices_summary/<str:timespan>/', views.GetDevicesSummary.as_view()),
path('<str:pk>/networks/uplinks/', views.GetNetworkUplinks.as_view()),
path('<str:pk>/top_clients/<str:timespan>/', views.GetTopClients.as_view()),
path('<str:network_id>/applications/traffic/<str:timespan>/', views.GetNetworkApplicationTraffic.as_view()),
path('<str:network_id>/clients/traffic/<str:timespan>/', views.GetNetworkClientTraffic.as_view()),
path('<str:network_id>/events/<str:timespan>/', views.GetNetworkEvents.as_view())
# path('organizations/', views.GetOrganizations.as_view()),
# path('<str:pk>/networks/', views.GetNetworks.as_view()),
# path('<str:pk>/devices_summary/<str:timespan>/', views.GetDevicesSummary.as_view()),
# path('<str:pk>/networks/uplinks/', views.GetNetworkUplinks.as_view()),
# path('<str:pk>/top_clients/<str:timespan>/', views.GetTopClients.as_view()),
# path('<str:network_id>/applications/traffic/<str:timespan>/', views.GetNetworkApplicationTraffic.as_view()),
# path('<str:network_id>/clients/traffic/<str:timespan>/', views.GetNetworkClientTraffic.as_view()),
# path('<str:network_id>/events/<str:timespan>/', views.GetNetworkEvents.as_view())
]
Loading

0 comments on commit 58d3000

Please sign in to comment.