Bitglass: first commit
This commit is contained in:
Родитель
77c03bb010
Коммит
6081c5e595
|
@ -0,0 +1,301 @@
|
|||
{
|
||||
"Name":"Bitglass_CL",
|
||||
"Properties":[
|
||||
{
|
||||
"Name":"docextension_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"doctype_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"docsha256_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"docsha1_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"policyid_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"threatindicator_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"docmd5_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"keyword_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"responsecode_d",
|
||||
"Type":"Double"
|
||||
},
|
||||
{
|
||||
"Name":"responsecode_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"deviceguid_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"owner_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"status_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"folder_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"fileid_g",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"patterns_s ",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"filelink_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"sharedwith_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"fileid_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"user_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"device_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"application_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"location_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"activity_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"request_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"transactionid_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"emailfrom_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"emailto_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"emailsubject_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"emailcc_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"emailbcc_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"emailsenttime_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"filename_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"dlppattern_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"pagetitle_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"url_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"details_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"syslogheader_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"protocol_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"customlocation_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"requestmethod_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"usergroup_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"bgcategories_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"size_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"city_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"deviceguid_g",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"destinationip_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"IPAddress",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"webreputation_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"long_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"requestdomain_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"setransactionid_g",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"arguments_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"indexedtime_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"email_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"bgcloudscore_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"firstname_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"lastname_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"devicehostname_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"regioncode_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"lat_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"uploadedbytes_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"webcategories_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"countrycode_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"referrer_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"country_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"region_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"uri_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"customcategories_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"time_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"action_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"useragent_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"webcategoryclass_s",
|
||||
"Type":"String"
|
||||
},
|
||||
{
|
||||
"Name":"log_type_s",
|
||||
"Type":"String"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,215 @@
|
|||
[
|
||||
{
|
||||
"action":"",
|
||||
"application":"Google Apps",
|
||||
"fileid":"1WdkjMqjaVefVSwx-NXaD5_W2ZPJrtpTk",
|
||||
"filelink":"https://drive.google.com/a/acme-gadget.com/file/d/1WdkjMqjaVefVSwx-NXaD5_W2ZPJrtpTk/view?usp=drivesdk",
|
||||
"filename":"1-MB-Test.docx",
|
||||
"folder":"/My Drive/Test Encryption",
|
||||
"owner":"sanitized@sanitized.com",
|
||||
"patterns":"",
|
||||
"sharedwith":"",
|
||||
"size":"",
|
||||
"status":"Private",
|
||||
"syslogheader":"<110>1 2019-11-15T10:30:34Z api.bitglass.com NILVALUE NILVALUE cloudaudit",
|
||||
"time":"20 Sep 2021 12:22:51",
|
||||
"log_type": "cloudaudit"
|
||||
},
|
||||
{
|
||||
"action":"Alert, Blocked, DLP, Notify",
|
||||
"activity":"Cloudstorage, Downloaded, Web",
|
||||
"application":"Google Drive",
|
||||
"details":"",
|
||||
"device":"Mac OS X 10.13.6",
|
||||
"dlppattern":"SecretProjects [Security Overview (Secret).docx (hawk)]",
|
||||
"email":"sanitized@sanitized.com",
|
||||
"emailbcc":"",
|
||||
"emailcc":"",
|
||||
"emailfrom":"",
|
||||
"emailsenttime":"",
|
||||
"emailsubject":"",
|
||||
"emailto":"",
|
||||
"filename":"Security Overview (Secret).docx",
|
||||
"ipaddress":"106.180.8.231",
|
||||
"location":"Yokohama||Kanagawa||14||JP",
|
||||
"pagetitle":"",
|
||||
"request":"",
|
||||
"syslogheader":"<114>1 2019-12-03T08:09:31.975000Z api.bitglass.com NILVALUE NILVALUE access",
|
||||
"time":"20 Sep 2021 12:22:51",
|
||||
"transactionid":"XeYYOwpaFUoAAL4EdmcAAABj [2019-12-03 08:09:31]",
|
||||
"url":"docs.google.com/document/u/0",
|
||||
"user":"Demo O365SF",
|
||||
"useragent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36 OPR/65.0.3467.48",
|
||||
"log_type": "access"
|
||||
},
|
||||
{
|
||||
"action":"",
|
||||
"activity":"",
|
||||
"application":"Bitglass",
|
||||
"details":"Admin changed saml_issuer_id in the SSO config for Oracle Cloud",
|
||||
"device":"Mac OS X 10.15.3",
|
||||
"dlppattern":"",
|
||||
"email":"sanitized@sanitized.com",
|
||||
"emailbcc":"",
|
||||
"emailcc":"",
|
||||
"emailfrom":"",
|
||||
"emailsenttime":"",
|
||||
"emailsubject":"",
|
||||
"emailto":"",
|
||||
"filename":"",
|
||||
"ipaddress":"50.226.196.118",
|
||||
"location":"Campbell||California||CA||US",
|
||||
"pagetitle":"",
|
||||
"request":"",
|
||||
"syslogheader":"<110>1 2020-02-27T21:58:46.359000Z api.bitglass.com NILVALUE NILVALUE access",
|
||||
"time":"27 Feb 2020 21:58:46",
|
||||
"transactionid":"aaa9b64f411f61b959a6d27d2f51b9b42c2ed116 [27 Feb 2020 21:58:46]",
|
||||
"url":"/admin/applications/edit/80839/custom-app-saml/cf23e347-c1d4-44ac-9ddb-d7a43633f0a2/",
|
||||
"user":"Amit Singh",
|
||||
"useragent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
|
||||
"log_type": "admin"
|
||||
},
|
||||
{
|
||||
"syslogheader":"<110>1 2021-04-01T05:17:21.000000Z api.bitglass.com NILVALUE NILVALUE swgweb",
|
||||
"protocol":"http",
|
||||
"customlocation":"[]",
|
||||
"requestmethod":"GET",
|
||||
"usergroup":"['67521', 'All Users']",
|
||||
"bgcategories":"[\"BG:Uncategorized\"]",
|
||||
"size":"0",
|
||||
"city":"San Jose",
|
||||
"deviceguid":"DA10D6D4-0868-4523-8A1C-210F1845EE3B",
|
||||
"destinationip":"",
|
||||
"ipaddress":"24.4.172.200",
|
||||
"webreputation":"80.00",
|
||||
"long":"-121.83600000",
|
||||
"requestdomain":"pokerstars.bet",
|
||||
"setransactionid":"E1500463-850B-4CC9-8A31-F990AA6CEF1E",
|
||||
"arguments":"",
|
||||
"indexedtime":"2021-04-01 05:30:04",
|
||||
"email":"sanitized@sanitized.com",
|
||||
"bgcloudscore":"0.00",
|
||||
"firstname":"Amit",
|
||||
"lastname":"Singh",
|
||||
"devicehostname":"amdas-vm-win10",
|
||||
"regioncode":"CA",
|
||||
"lat":"37.25070000",
|
||||
"uploadedbytes":"0",
|
||||
"webcategories":"[\"WR:Gambling\"]",
|
||||
"countrycode":"US",
|
||||
"referrer":"",
|
||||
"country":"United States",
|
||||
"region":"California",
|
||||
"uri":"/",
|
||||
"customcategories":"[]",
|
||||
"time":"20 Sep 2021 12:22:51",
|
||||
"action":"block",
|
||||
"useragent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36",
|
||||
"webcategoryclass":"[\"Questionable/Legal\"]",
|
||||
"log_type": "swgweb"
|
||||
},
|
||||
{
|
||||
"syslogheader":"<110>1 2021-02-05T23:34:19.000000Z api.bitglass.com NILVALUE NILVALUE swgwebdlp",
|
||||
"docextension":"docx",
|
||||
"protocol":"https",
|
||||
"customlocation":"[]",
|
||||
"doctype":"docx",
|
||||
"requestmethod":"POST",
|
||||
"usergroup":"['67521', 'All Users']",
|
||||
"bgcategories":"[\"BG:Others\"]",
|
||||
"docsha256":"7c31b3b98dca839186621aee692d7613d0c282ad485c770475c9f18eb5211d23",
|
||||
"size":"864",
|
||||
"city":"Fremont",
|
||||
"deviceguid":"D792BF82-1BC5-4836-A80C-3A7102EFA669",
|
||||
"destinationip":"",
|
||||
"ipaddress":"76.244.42.214",
|
||||
"webreputation":"92.00",
|
||||
"long":"-121.97320000",
|
||||
"requestdomain":"filebin.net",
|
||||
"setransactionid":"1D7B4BAF-7BAC-4ADD-AC0B-0CAF40F9AB66",
|
||||
"arguments":"",
|
||||
"dlppattern":"[\"Purple\"]",
|
||||
"indexedtime":"2021-02-06 00:59:01",
|
||||
"email":"sanitized@sanitized.com",
|
||||
"bgcloudscore":"5.00",
|
||||
"firstname":"Amit",
|
||||
"lastname":"Singh",
|
||||
"devicehostname":"desktop-625d92e",
|
||||
"regioncode":"CA",
|
||||
"docsha1":"",
|
||||
"policyid":"251773",
|
||||
"lat":"37.52810000",
|
||||
"transactionid":"YB3WKjINin8t@9uV@w@3KwAABAU",
|
||||
"threatindicator":"[]",
|
||||
"uploadedbytes":"31466",
|
||||
"webcategories":"[\"WR:Personal Storage\"]",
|
||||
"docmd5":"",
|
||||
"countrycode":"US",
|
||||
"keyword":"[\"purple\"]",
|
||||
"referrer":"https://filebin.net/9e3hnzwui1zx4zbu",
|
||||
"country":"United States",
|
||||
"region":"California",
|
||||
"uri":"/",
|
||||
"customcategories":"[]",
|
||||
"time":"20 Sep 2021 12:22:51",
|
||||
"action":"tobitglass",
|
||||
"useragent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36",
|
||||
"webcategoryclass":"[\"Business/Government/Services\"]",
|
||||
"log_type": "swgwebdlp"
|
||||
},
|
||||
{
|
||||
"syslogheader":"<110>1 2021-07-16T12:10:17.022428Z api.bitglass.com NILVALUE NILVALUE access",
|
||||
"time":"20 Sep 2021 12:22:51",
|
||||
"user":"Demo O365SF",
|
||||
"email":"sanitized@sanitized.com",
|
||||
"usergroup":"Academic, Demo Gizmo Only, Demo Only, GizmoUsers, Risky Users, RiskyUsers",
|
||||
"device":"Windows nil",
|
||||
"application":"Office 365",
|
||||
"activity":"Server4xx",
|
||||
"url":"https://login.microsoftonline.com/ccf88654-4631-4307-a76d-49972ac91498/oauth2/token",
|
||||
"responsecode":400,
|
||||
"transactionid":"YPF3KSeG9sCgVaEESA0zxgAAAMY [16 Jul 2021 12:10:17]",
|
||||
"deviceguid":"D3B0C5A5-F677-4658-9111-0360E3B5F038",
|
||||
"ipaddress":"24.92.139.31",
|
||||
"location":"Columbus||Ohio||OH||US",
|
||||
"requestmethod":"",
|
||||
"useragent":"Windows-AzureAD-Authentication-Provider/1.0",
|
||||
"log_type": "healthproxy"
|
||||
},
|
||||
{
|
||||
"syslogheader":"<110>1 2021-07-28T21:13:31.730349Z api.bitglass.com NILVALUE NILVALUE access",
|
||||
"time":"20 Sep 2021 12:22:51",
|
||||
"user":"Demo Google",
|
||||
"email":"sanitized@sanitized.com",
|
||||
"usergroup":"DemoUsers, RiskyUsers",
|
||||
"device":"",
|
||||
"application":"Google Apps",
|
||||
"activity":"Server4xx",
|
||||
"url":"/My Drive/Demo/Engineering (Block)",
|
||||
"responsecode":null,
|
||||
"transactionid":"00681f60-ef51-4ec8-af23-6baa3538609b [28 Jul 2021 21:13:31]",
|
||||
"filename":"Security Overview (Secret)",
|
||||
"fileid":"117VHdwNpGrbMZpp7UPSCe3j_TW-9laS4wdTnZVGP7aM",
|
||||
"status":"Internal, Shared, DLP",
|
||||
"log_type": "healthapi"
|
||||
},
|
||||
{
|
||||
"syslogheader":"<110>1 2021-07-16T09:05:45.801018Z api.bitglass.com NILVALUE NILVALUE access",
|
||||
"time":"20 Sep 2021 12:22:51",
|
||||
"user":"Amit Singh",
|
||||
"email":"sanitized@sanitized.com",
|
||||
"usergroup":"All TME, Amit-Gadget, Bitglass Admins, EDMGroup, OCI_NetworkAdmins, Overview Report, RiskyUsers, SNOW-Encrypt, SNOW_Notification, System Administrator, admin-acme-gadget.com, oracle",
|
||||
"device":"",
|
||||
"application":"Bitglass",
|
||||
"activity":"Bitglass4xx, RestAPI",
|
||||
"url":"",
|
||||
"responsecode":429,
|
||||
"transactionid":"6c1f4086-58c3-43bd-aa33-04fe262572ef [16 Jul 2021 09:05:45]",
|
||||
"deviceguid":"",
|
||||
"ipaddress":"3.140.207.46",
|
||||
"location":"Columbus||Ohio||OH||US",
|
||||
"requestmethod":"",
|
||||
"useragent":"",
|
||||
"log_type": "healthsystem"
|
||||
}
|
||||
]
|
Двоичный файл не отображается.
|
@ -0,0 +1,210 @@
|
|||
import logging
|
||||
import azure.functions as func
|
||||
import requests
|
||||
import itertools
|
||||
import datetime
|
||||
from requests.packages.urllib3.util.retry import Retry
|
||||
import os
|
||||
import base64
|
||||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
import re
|
||||
import time
|
||||
from .state_manager import StateManager
|
||||
|
||||
bitglass_token = os.environ['BitglassToken']
|
||||
bitglass_serviceURL = os.environ['BitglassServiceURL']
|
||||
customer_id = os.environ['WorkspaceID']
|
||||
shared_key = os.environ['WorkspaceKey']
|
||||
connection_string = os.environ['AzureWebJobsStorage']
|
||||
logAnalyticsUri = os.environ.get('logAnalyticsUri')
|
||||
table_name = "BitglassLogs"
|
||||
chunksize = 10000
|
||||
|
||||
if ((logAnalyticsUri in (None, '') or str(logAnalyticsUri).isspace())):
|
||||
logAnalyticsUri = 'https://' + customer_id + '.ods.opinsights.azure.com'
|
||||
|
||||
pattern = r'https:\/\/([\w\-]+)\.ods\.opinsights\.azure.([a-zA-Z\.]+)$'
|
||||
match = re.match(pattern,str(logAnalyticsUri))
|
||||
if(not match):
|
||||
raise Exception("Bitglass: Invalid Log Analytics Uri.")
|
||||
|
||||
class BG_CASB():
|
||||
|
||||
def __init__(self, type):
|
||||
self.event_type = type
|
||||
filepath=f'{self.event_type}_funcstatemarkerfile'
|
||||
self.token = bitglass_token
|
||||
self.url = f'{bitglass_serviceURL}/api/bitglassapi/logs/v1/'
|
||||
|
||||
self.headers = {
|
||||
'Authorization': 'Bearer {}'.format(self.token),
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
self.state = StateManager(connection_string=connection_string, share_name='funcstatemarkershare', file_path=filepath)
|
||||
self.from_time = self.generate_date()
|
||||
|
||||
def get_query(self, url, token):
|
||||
retries = Retry(
|
||||
total=3,
|
||||
status_forcelist={429, 500, 503},
|
||||
backoff_factor=3,
|
||||
respect_retry_after_header=True
|
||||
)
|
||||
adapter = requests.adapters.HTTPAdapter(max_retries=retries)
|
||||
session = requests.Session()
|
||||
session.mount('https://', adapter)
|
||||
if token is None:
|
||||
self.params = {
|
||||
"startdate": self.from_time,
|
||||
"cv": "1.0.1",
|
||||
"type": self.event_type,
|
||||
"responseformat": "json"
|
||||
}
|
||||
else:
|
||||
self.params = {
|
||||
"nextpagetoken": token,
|
||||
"cv": "1.0.1",
|
||||
"type": self.event_type,
|
||||
"responseformat": "json"
|
||||
}
|
||||
try:
|
||||
r = session.get(url=url,
|
||||
headers=self.headers,
|
||||
params=self.params
|
||||
)
|
||||
if r.status_code == 200:
|
||||
return r.json()
|
||||
elif r.status_code == 401:
|
||||
logging.error("The authentication credentials are incorrect or missing. Error code: {}".format(r.status_code))
|
||||
else:
|
||||
logging.error("Something wrong. Error: {}".format(r.text))
|
||||
except Exception as err:
|
||||
logging.error("Something wrong. Exception error text: {}".format(err))
|
||||
|
||||
def get_result(self):
|
||||
result_array = []
|
||||
r = self.get_query(self.url, None)
|
||||
if r is not None:
|
||||
if r.get("status") == "Request was successful":
|
||||
result = (r.get("response")).get("data")
|
||||
result_array += result
|
||||
nextpagetoken = r.get("nextpagetoken")
|
||||
while len(result) != 0:
|
||||
r = self.get_query(self.url, nextpagetoken)
|
||||
if r is not None:
|
||||
if r.get("status") == "Request was successful":
|
||||
nextpagetoken = r.get("nextpagetoken")
|
||||
result = (r.get("response")).get("data")
|
||||
result_array += result
|
||||
time_array = []
|
||||
for event in result_array:
|
||||
event.update({'log_type': self.event_type})
|
||||
time = event["time"]
|
||||
time_array.append(time)
|
||||
if len(time_array) > 0:
|
||||
sortedArray = sorted(time_array, key=lambda x: datetime.datetime.strptime(x, '%d %b %Y %H:%M:%S'), reverse=True)
|
||||
last_time = sortedArray[0]
|
||||
last_time = datetime.datetime.strptime(last_time, '%d %b %Y %H:%M:%S').strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
self.state.post(last_time)
|
||||
return result_array
|
||||
|
||||
def generate_date(self):
|
||||
current_time = datetime.datetime.utcnow()
|
||||
past_time = self.state.get()
|
||||
if past_time is not None:
|
||||
logging.info("The last time point for \"{}\" log type is: {}".format(self.event_type,past_time))
|
||||
else:
|
||||
logging.info("There is no last time point for \"{}\" log type , trying to get logs for last 24 hour.".format(self.event_type))
|
||||
past_time = (current_time - datetime.timedelta(hours=24)).strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
return (past_time)
|
||||
|
||||
class Sentinel:
|
||||
|
||||
def __init__(self):
|
||||
self.logAnalyticsUri = logAnalyticsUri
|
||||
self.success_processed = 0
|
||||
self.fail_processed = 0
|
||||
self.table_name = table_name
|
||||
self.chunksize = chunksize
|
||||
|
||||
def gen_chunks_to_object(self, data, chunksize=100):
|
||||
chunk = []
|
||||
for index, line in enumerate(data):
|
||||
if (index % chunksize == 0 and index > 0):
|
||||
yield chunk
|
||||
del chunk[:]
|
||||
chunk.append(line)
|
||||
yield chunk
|
||||
|
||||
def gen_chunks(self, data):
|
||||
for chunk in self.gen_chunks_to_object(data, chunksize=self.chunksize):
|
||||
obj_array = []
|
||||
for row in chunk:
|
||||
if row != None and row != '':
|
||||
obj_array.append(row)
|
||||
body = json.dumps(obj_array)
|
||||
self.post_data(body, len(obj_array))
|
||||
|
||||
def build_signature(self, date, content_length, method, content_type, resource):
|
||||
x_headers = 'x-ms-date:' + date
|
||||
string_to_hash = method + "\n" + str(content_length) + "\n" + content_type + "\n" + x_headers + "\n" + resource
|
||||
bytes_to_hash = bytes(string_to_hash, encoding="utf-8")
|
||||
decoded_key = base64.b64decode(shared_key)
|
||||
encoded_hash = base64.b64encode(
|
||||
hmac.new(decoded_key, bytes_to_hash, digestmod=hashlib.sha256).digest()).decode()
|
||||
authorization = "SharedKey {}:{}".format(customer_id, encoded_hash)
|
||||
return authorization
|
||||
|
||||
def post_data(self, body, chunk_count):
|
||||
method = 'POST'
|
||||
content_type = 'application/json'
|
||||
resource = '/api/logs'
|
||||
rfc1123date = datetime.datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')
|
||||
content_length = len(body)
|
||||
signature = self.build_signature(rfc1123date, content_length, method, content_type,
|
||||
resource)
|
||||
uri = self.logAnalyticsUri + resource + '?api-version=2016-04-01'
|
||||
headers = {
|
||||
'content-type': content_type,
|
||||
'Authorization': signature,
|
||||
'Log-Type': self.table_name,
|
||||
'x-ms-date': rfc1123date
|
||||
}
|
||||
response = requests.post(uri, data=body, headers=headers)
|
||||
if (response.status_code >= 200 and response.status_code <= 299):
|
||||
logging.info("Chunk was processed({} events)".format(chunk_count))
|
||||
self.success_processed = self.success_processed + chunk_count
|
||||
else:
|
||||
logging.info("Error during sending events to Azure Sentinel. Response code:{}".format(response.status_code))
|
||||
self.fail_processed = self.fail_processed + chunk_count
|
||||
|
||||
def main(mytimer: func.TimerRequest) -> None:
|
||||
utc_timestamp = datetime.datetime.utcnow().replace(
|
||||
tzinfo=datetime.timezone.utc).isoformat()
|
||||
if mytimer.past_due:
|
||||
logging.info("The timer is past due!")
|
||||
logging.info("Python timer trigger function ran at %s", utc_timestamp)
|
||||
logging.info("Starting program")
|
||||
logs_type_array = [
|
||||
"cloudaudit", "access",
|
||||
"admin", "swgweb",
|
||||
"swgwebdlp", "healthproxy",
|
||||
"healthapi"
|
||||
]
|
||||
map_iterator = map(lambda x: BG_CASB(x),logs_type_array)
|
||||
for elem in map_iterator:
|
||||
results_array = elem.get_result()
|
||||
sentinel = Sentinel()
|
||||
if len(results_array) > 0:
|
||||
sentinel.gen_chunks(results_array)
|
||||
sentinel_class_vars = vars(sentinel)
|
||||
success_processed, fail_processed = sentinel_class_vars["success_processed"], \
|
||||
sentinel_class_vars["fail_processed"]
|
||||
logging.info('Logs type: {}. Total events processed successfully: {}, failed: {}. Period from : {}'
|
||||
.format(elem.event_type, success_processed, fail_processed, elem.from_time))
|
||||
else:
|
||||
logging.info('Logs type: {}. There are no events for processing. Period from: {}'
|
||||
.format(elem.event_type, elem.from_time))
|
||||
time.sleep(3)
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"scriptFile": "__init__.py",
|
||||
"bindings": [
|
||||
{
|
||||
"name": "mytimer",
|
||||
"type": "timerTrigger",
|
||||
"direction": "in",
|
||||
"schedule": "0 */10 * * * *"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
from azure.storage.fileshare import ShareClient
|
||||
from azure.storage.fileshare import ShareFileClient
|
||||
from azure.core.exceptions import ResourceNotFoundError
|
||||
|
||||
|
||||
class StateManager:
|
||||
def __init__(self, connection_string, share_name, file_path):
|
||||
self.share_cli = ShareClient.from_connection_string(conn_str=connection_string, share_name=share_name)
|
||||
self.file_cli = ShareFileClient.from_connection_string(conn_str=connection_string, share_name=share_name, file_path=file_path)
|
||||
|
||||
def post(self, marker_text: str):
|
||||
try:
|
||||
self.file_cli.upload_file(marker_text)
|
||||
except ResourceNotFoundError:
|
||||
self.share_cli.create_share()
|
||||
self.file_cli.upload_file(marker_text)
|
||||
|
||||
def get(self):
|
||||
try:
|
||||
return self.file_cli.download_file().readall().decode()
|
||||
except ResourceNotFoundError:
|
||||
return None
|
|
@ -0,0 +1,121 @@
|
|||
{
|
||||
"id": "Bitglass",
|
||||
"title": "Bitglass",
|
||||
"publisher": "Bitglass",
|
||||
"descriptionMarkdown": "The [Bitglass](https://www.bitglass.com/) data connector provides the capability to retrieve security event logs of the Bitglass services and more events into Azure Sentinel through the REST API. The connector provides ability to get events which helps to examine potential security risks, analyze your team's use of collaboration, diagnose configuration problems and more.",
|
||||
"additionalRequirementBanner": ">This data connector depends on a parser based on a Kusto Function to work as expected [**Bitglass**](https://aka.ms/sentinel-Bitglass-parser) which is deployed with the Azure Sentinel Solution.",
|
||||
"graphQueries": [{
|
||||
"metricName": "Total data received",
|
||||
"legend": "BitglassLogs_CL",
|
||||
"baseQuery": "BitglassLogs_CL"
|
||||
}
|
||||
],
|
||||
"sampleQueries": [{
|
||||
"description": "Bitglass Events - All Activities.",
|
||||
"query": "Bitglass\n | sort by TimeGenerated desc"
|
||||
}
|
||||
],
|
||||
"dataTypes": [{
|
||||
"name": "BitglassLogs_CL",
|
||||
"lastDataReceivedQuery": "BitglassLogs_CL\n | summarize Time = max(TimeGenerated)\n | where isnotempty(Time)"
|
||||
}
|
||||
],
|
||||
"connectivityCriterias": [{
|
||||
"type": "IsConnectedQuery",
|
||||
"value": [
|
||||
"BitglassLogs_CL\n | summarize LastLogReceived = max(TimeGenerated)\n | project IsConnected = LastLogReceived > ago(30d)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"availability": {
|
||||
"status": 1,
|
||||
"isPreview": true
|
||||
},
|
||||
"permissions": {
|
||||
"resourceProvider": [{
|
||||
"provider": "Microsoft.OperationalInsights/workspaces",
|
||||
"permissionsDisplayText": "read and write permissions on the workspace are required.",
|
||||
"providerDisplayName": "Workspace",
|
||||
"scope": "Workspace",
|
||||
"requiredPermissions": {
|
||||
"write": true,
|
||||
"read": true,
|
||||
"delete": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"provider": "Microsoft.OperationalInsights/workspaces/sharedKeys",
|
||||
"permissionsDisplayText": "read permissions to shared keys for the workspace are required. [See the documentation to learn more about workspace keys](https://docs.microsoft.com/azure/azure-monitor/platform/agent-windows#obtain-workspace-id-and-key).",
|
||||
"providerDisplayName": "Keys",
|
||||
"scope": "Workspace",
|
||||
"requiredPermissions": {
|
||||
"action": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"customs": [{
|
||||
"name": "Microsoft.Web/sites permissions",
|
||||
"description": "Read and write permissions to Azure Functions to create a Function App is required. [See the documentation to learn more about Azure Functions](https://docs.microsoft.com/azure/azure-functions/)."
|
||||
},
|
||||
{
|
||||
"name": "REST API Credentials/permissions",
|
||||
"description": "**BitglassToken** and **BitglassServiceURL** are required for making API calls."
|
||||
}
|
||||
]
|
||||
},
|
||||
"instructionSteps": [{
|
||||
"title": "",
|
||||
"description": ">**NOTE:** This connector uses Azure Functions to connect to the Azure Blob Storage API to pull logs into Azure Sentinel. This might result in additional costs for data ingestion and for storing data in Azure Blob Storage costs. Check the [Azure Functions pricing page](https://azure.microsoft.com/pricing/details/functions/) and [Azure Blob Storage pricing page](https://azure.microsoft.com/pricing/details/storage/blobs/) for details."
|
||||
},
|
||||
{
|
||||
"title": "",
|
||||
"description": ">**(Optional Step)** Securely store workspace and API authorization key(s) or token(s) in Azure Key Vault. Azure Key Vault provides a secure mechanism to store and retrieve key values. [Follow these instructions](https://docs.microsoft.com/azure/app-service/app-service-key-vault-references) to use Azure Key Vault with an Azure Function App."
|
||||
},
|
||||
{
|
||||
"description": ">**NOTE:** This data connector depends on a parser based on a Kusto Function to work as expected [**Bitglass**](https://aka.ms/sentinel-Bitglass-parser) which is deployed with the Azure Sentinel Solution."
|
||||
},
|
||||
{
|
||||
"title": "",
|
||||
"description": "**STEP 1 - Configuration steps for the Bitglass Log Retrieval API**\n\n Follow the instructions to obtain the credentials.\n\n1. Obtain the **BitglassToken** and **BitglassServiceURL** using the [documentation]().\n2. Save credentials for using in the data connector."
|
||||
},
|
||||
{
|
||||
"title": "",
|
||||
"description": "**STEP 2 - Choose ONE from the following two deployment options to deploy the connector and the associated Azure Function**\n\n>**IMPORTANT:** Before deploying the Bitglass data connector, have the Workspace ID and Workspace Primary Key (can be copied from the following).",
|
||||
"instructions": [{
|
||||
"parameters": {
|
||||
"fillWith": [
|
||||
"WorkspaceId"
|
||||
],
|
||||
"label": "Workspace ID"
|
||||
},
|
||||
"type": "CopyableLabel"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"fillWith": [
|
||||
"PrimaryKey"
|
||||
],
|
||||
"label": "Primary Key"
|
||||
},
|
||||
"type": "CopyableLabel"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Option 1 - Azure Resource Manager (ARM) Template",
|
||||
"description": "Use this method for automated deployment of the Bitglass data connector using an ARM Tempate.\n\n1. Click the **Deploy to Azure** button below. \n\n\t[![Deploy To Azure](https://aka.ms/deploytoazurebutton)](https://aka.ms/sentinel-BitglassAPI-azuredeploy)\n2. Select the preferred **Subscription**, **Resource Group** and **Location**. \n> **NOTE:** Within the same resource group, you can't mix Windows and Linux apps in the same region. Select existing resource group without Windows apps in it or create new resource group.\n3. Enter the **BitglassToken**, **BitglassServiceURL** and deploy. \n4. Mark the checkbox labeled **I agree to the terms and conditions stated above**. \n5. Click **Purchase** to deploy."
|
||||
},
|
||||
{
|
||||
"title": "Option 2 - Manual Deployment of Azure Functions",
|
||||
"description": "Use the following step-by-step instructions to deploy the Bitglass data connector manually with Azure Functions (Deployment via Visual Studio Code)."
|
||||
},
|
||||
{
|
||||
"title": "",
|
||||
"description": "**1. Deploy a Function App**\n\n> **NOTE:** You will need to [prepare VS code](https://docs.microsoft.com/azure/azure-functions/functions-create-first-function-python#prerequisites) for Azure function development.\n\n1. Download the [Azure Function App](https://aka.ms/sentinel-BitglassAPI-functionapp) file. Extract archive to your local development computer.\n2. Start VS Code. Choose File in the main menu and select Open Folder.\n3. Select the top level folder from extracted files.\n4. Choose the Azure icon in the Activity bar, then in the **Azure: Functions** area, choose the **Deploy to function app** button.\nIf you aren't already signed in, choose the Azure icon in the Activity bar, then in the **Azure: Functions** area, choose **Sign in to Azure**\nIf you're already signed in, go to the next step.\n5. Provide the following information at the prompts:\n\n\ta. **Select folder:** Choose a folder from your workspace or browse to one that contains your function app.\n\n\tb. **Select Subscription:** Choose the subscription to use.\n\n\tc. Select **Create new Function App in Azure** (Don't choose the Advanced option)\n\n\td. **Enter a globally unique name for the function app:** Type a name that is valid in a URL path. The name you type is validated to make sure that it's unique in Azure Functions. (e.g. BitglassXXXXX).\n\n\te. **Select a runtime:** Choose Python 3.8.\n\n\tf. Select a location for new resources. For better performance and lower costs choose the same [region](https://azure.microsoft.com/regions/) where Azure Sentinel is located.\n\n6. Deployment will begin. A notification is displayed after your function app is created and the deployment package is applied.\n7. Go to Azure Portal for the Function App configuration."
|
||||
},
|
||||
{
|
||||
"title": "",
|
||||
"description": "**2. Configure the Function App**\n\n1. In the Function App, select the Function App Name and select **Configuration**.\n2. In the **Application settings** tab, select ** New application setting**.\n3. Add each of the following application settings individually, with their respective string values (case-sensitive): \n\t\tBitglassToken\n\t\tBitglassServiceURL\n\t\tWorkspaceID\n\t\tWorkspaceKey\n\t\tlogAnalyticsUri (optional)\n> - Use logAnalyticsUri to override the log analytics API endpoint for dedicated cloud. For example, for public cloud, leave the value empty; for Azure GovUS cloud environment, specify the value in the following format: `https://<CustomerId>.ods.opinsights.azure.us`.\n4. Once all application settings have been entered, click **Save**."
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"FunctionName": {
|
||||
"defaultValue": "Bitglass",
|
||||
"minLength": 1,
|
||||
"maxLength": 11,
|
||||
"type": "string"
|
||||
},
|
||||
"WorkspaceID": {
|
||||
"type": "string",
|
||||
"defaultValue": "<workspaceID>"
|
||||
},
|
||||
"WorkspaceKey": {
|
||||
"type": "securestring",
|
||||
"defaultValue": "<workspaceKey>"
|
||||
},
|
||||
"BitglassToken": {
|
||||
"type": "securestring",
|
||||
"defaultValue": "<BitglassToken>"
|
||||
},
|
||||
"BitglassServiceURL": {
|
||||
"type": "string",
|
||||
"defaultValue": "https://portal.us.bitglass.net"
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"FunctionName": "[concat(toLower(parameters('FunctionName')), uniqueString(resourceGroup().id))]",
|
||||
"StorageSuffix": "[environment().suffixes.storage]",
|
||||
"LogAnaltyicsUri": "[replace(environment().portal, 'https://portal', concat('https://', toLower(parameters('WorkspaceID')), '.ods.opinsights'))]"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Insights/components",
|
||||
"apiVersion": "2015-05-01",
|
||||
"name": "[variables('FunctionName')]",
|
||||
"location": "[resourceGroup().location]",
|
||||
"kind": "web",
|
||||
"properties": {
|
||||
"Application_Type": "web",
|
||||
"ApplicationId": "[variables('FunctionName')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Storage/storageAccounts",
|
||||
"apiVersion": "2019-06-01",
|
||||
"name": "[tolower(variables('FunctionName'))]",
|
||||
"location": "[resourceGroup().location]",
|
||||
"sku": {
|
||||
"name": "Standard_LRS",
|
||||
"tier": "Standard"
|
||||
},
|
||||
"kind": "StorageV2",
|
||||
"properties": {
|
||||
"networkAcls": {
|
||||
"bypass": "AzureServices",
|
||||
"virtualNetworkRules": [],
|
||||
"ipRules": [],
|
||||
"defaultAction": "Allow"
|
||||
},
|
||||
"supportsHttpsTrafficOnly": true,
|
||||
"encryption": {
|
||||
"services": {
|
||||
"file": {
|
||||
"keyType": "Account",
|
||||
"enabled": true
|
||||
},
|
||||
"blob": {
|
||||
"keyType": "Account",
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
"keySource": "Microsoft.Storage"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Storage/storageAccounts/blobServices",
|
||||
"apiVersion": "2019-06-01",
|
||||
"name": "[concat(variables('FunctionName'), '/default')]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.Storage/storageAccounts', tolower(variables('FunctionName')))]"
|
||||
],
|
||||
"sku": {
|
||||
"name": "Standard_LRS",
|
||||
"tier": "Standard"
|
||||
},
|
||||
"properties": {
|
||||
"cors": {
|
||||
"corsRules": []
|
||||
},
|
||||
"deleteRetentionPolicy": {
|
||||
"enabled": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Storage/storageAccounts/fileServices",
|
||||
"apiVersion": "2019-06-01",
|
||||
"name": "[concat(variables('FunctionName'), '/default')]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.Storage/storageAccounts', tolower(variables('FunctionName')))]"
|
||||
],
|
||||
"sku": {
|
||||
"name": "Standard_LRS",
|
||||
"tier": "Standard"
|
||||
},
|
||||
"properties": {
|
||||
"cors": {
|
||||
"corsRules": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Web/sites",
|
||||
"apiVersion": "2018-11-01",
|
||||
"name": "[variables('FunctionName')]",
|
||||
"location": "[resourceGroup().location]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.Storage/storageAccounts', tolower(variables('FunctionName')))]",
|
||||
"[resourceId('Microsoft.Insights/components', variables('FunctionName'))]"
|
||||
],
|
||||
"kind": "functionapp,linux",
|
||||
"identity": {
|
||||
"type": "SystemAssigned"
|
||||
},
|
||||
"properties": {
|
||||
"name": "[variables('FunctionName')]",
|
||||
"httpsOnly": true,
|
||||
"clientAffinityEnabled": true,
|
||||
"alwaysOn": true,
|
||||
"reserved": true,
|
||||
"siteConfig": {
|
||||
"linuxFxVersion": "python|3.8"
|
||||
}
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"apiVersion": "2018-11-01",
|
||||
"type": "config",
|
||||
"name": "appsettings",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Web/sites/', variables('FunctionName'))]"
|
||||
],
|
||||
"properties": {
|
||||
"FUNCTIONS_EXTENSION_VERSION": "~3",
|
||||
"FUNCTIONS_WORKER_RUNTIME": "python",
|
||||
"APPINSIGHTS_INSTRUMENTATIONKEY": "[reference(resourceId('Microsoft.insights/components', variables('FunctionName')), '2015-05-01').InstrumentationKey]",
|
||||
"APPLICATIONINSIGHTS_CONNECTION_STRING": "[reference(resourceId('microsoft.insights/components', variables('FunctionName')), '2015-05-01').ConnectionString]",
|
||||
"AzureWebJobsStorage": "[concat('DefaultEndpointsProtocol=https;AccountName=', toLower(variables('FunctionName')),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', toLower(variables('FunctionName'))), '2019-06-01').keys[0].value, ';EndpointSuffix=',toLower(variables('StorageSuffix')))]",
|
||||
"logAnalyticsUri": "[variables('LogAnaltyicsUri')]",
|
||||
"WorkspaceID": "[parameters('WorkspaceID')]",
|
||||
"WorkspaceKey": "[parameters('WorkspaceKey')]",
|
||||
"BitglassToken": "[parameters('BitglassToken')]",
|
||||
"BitglassServiceURL": "[parameters('BitglassServiceURL')]",
|
||||
"WEBSITE_RUN_FROM_PACKAGE": "https://github.com/averbn/azure_sentinel_data_connectors/raw/main/bitglass-azure-sentinel-data-connector/BitglassAPISentinelConn.zip?raw=true"
|
||||
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
|
||||
"apiVersion": "2019-06-01",
|
||||
"name": "[concat(variables('FunctionName'), '/default/azure-webjobs-hosts')]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.Storage/storageAccounts/blobServices', variables('FunctionName'), 'default')]",
|
||||
"[resourceId('Microsoft.Storage/storageAccounts', variables('FunctionName'))]"
|
||||
],
|
||||
"properties": {
|
||||
"publicAccess": "None"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
|
||||
"apiVersion": "2019-06-01",
|
||||
"name": "[concat(variables('FunctionName'), '/default/azure-webjobs-secrets')]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.Storage/storageAccounts/blobServices', variables('FunctionName'), 'default')]",
|
||||
"[resourceId('Microsoft.Storage/storageAccounts', variables('FunctionName'))]"
|
||||
],
|
||||
"properties": {
|
||||
"publicAccess": "None"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Storage/storageAccounts/fileServices/shares",
|
||||
"apiVersion": "2019-06-01",
|
||||
"name": "[concat(variables('FunctionName'), '/default/', tolower(variables('FunctionName')))]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.Storage/storageAccounts/fileServices', variables('FunctionName'), 'default')]",
|
||||
"[resourceId('Microsoft.Storage/storageAccounts', variables('FunctionName'))]"
|
||||
],
|
||||
"properties": {
|
||||
"shareQuota": 5120
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"version": "2.0",
|
||||
"logging": {
|
||||
"applicationInsights": {
|
||||
"samplingSettings": {
|
||||
"isEnabled": true,
|
||||
"excludedTypes": "Request"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extensionBundle": {
|
||||
"id": "Microsoft.Azure.Functions.ExtensionBundle",
|
||||
"version": "[1.*, 2.0.0)"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "http://json.schemastore.org/proxies",
|
||||
"proxies": {}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
# DO NOT include azure-functions-worker in this file
|
||||
# The Python Worker is managed by Azure Functions platform
|
||||
# Manually managing azure-functions-worker may cause unexpected issues
|
||||
|
||||
azure-storage-file-share==12.3.0
|
||||
azure-functions
|
||||
requests
|
|
@ -0,0 +1,158 @@
|
|||
// Usage Instruction :
|
||||
// Paste below query in log analytics, click on Save button and select as Function from drop down by specifying function name and alias (e.g. Bitglass).
|
||||
// Function usually takes 10-15 minutes to activate. You can then use function alias from any other queries (e.g. Bitglass | take 10).
|
||||
// References :
|
||||
// Using functions in Azure monitor log queries : https://docs.microsoft.com/azure/azure-monitor/log-query/functions
|
||||
// Tech Community Blog on KQL Functions : https://techcommunity.microsoft.com/t5/Azure-Sentinel/Using-KQL-functions-to-speed-up-analysis-in-Azure-Sentinel/ba-p/712381
|
||||
//
|
||||
let Bitglass_view = view () {
|
||||
BitglassLogs_CL
|
||||
| extend
|
||||
EventVendor="Bitglass",
|
||||
SrcFileExtension=column_ifexists('docextension_s', ''),
|
||||
DocType=column_ifexists('doctype_s', ''),
|
||||
SrcFileSHA256=column_ifexists('docsha256_s', ''),
|
||||
SrcFileSHA1=column_ifexists('docsha1_s', ''),
|
||||
PolicyId=column_ifexists('policyid_s', ''),
|
||||
ThreatId=column_ifexists('threatindicator_s', ''),
|
||||
SrcFileMD5=column_ifexists('docmd5_s', ''),
|
||||
Keyword=column_ifexists('keyword_s', ''),
|
||||
HttpStatusCode=column_ifexists('responsecode_d', ''),
|
||||
DvcId=column_ifexists('deviceguid_s', ''),
|
||||
Owner=column_ifexists('owner_s', ''),
|
||||
EventResult=column_ifexists('status_s', ''),
|
||||
SrcFilePath=column_ifexists('folder_s', ''),
|
||||
FileId=iif(isnotempty(fileid_g),fileid_g, iif(isnotempty(fileid_s),fileid_s,'')),
|
||||
FileLink=column_ifexists('filelink_s', ''),
|
||||
SharedWith=column_ifexists('sharedwith_s', ''),
|
||||
User=column_ifexists('user_s', ''),
|
||||
Dvc=column_ifexists('device_s', ''),
|
||||
Application=column_ifexists('application_s', ''),
|
||||
SrcGeoLocation=column_ifexists('location_s', ''),
|
||||
EventMessage=column_ifexists('activity_s', ''),
|
||||
HttpRequest=column_ifexists('request_s', ''),
|
||||
TransactionId=column_ifexists('transactionid_s', ''),
|
||||
EmailFrom=column_ifexists('emailfrom_s', ''),
|
||||
EmailTo=column_ifexists('emailto_s', ''),
|
||||
EmailSubject=column_ifexists('emailsubject_s', ''),
|
||||
EmailCc=column_ifexists('emailcc_s', ''),
|
||||
EmailBcc=column_ifexists('emailbcc_s', ''),
|
||||
EmailSentTime=column_ifexists('emailsenttime_s', todatetime(emailsenttime_s)),
|
||||
SrcFileName=column_ifexists('filename_s', ''),
|
||||
DlpPattern=column_ifexists('dlppattern_s', ''),
|
||||
PageTitle=column_ifexists('pagetitle_s', ''),
|
||||
Url=column_ifexists('url_s', ''),
|
||||
EventResultDetails=column_ifexists('details_s', ''),
|
||||
SyslogHeader=column_ifexists('syslogheader_s', ''),
|
||||
NetworkProtocol=column_ifexists('protocol_s', ''),
|
||||
CustomLocation=column_ifexists('customlocation_s', ''),
|
||||
HttpRequestMethod=column_ifexists('requestmethod_s', ''),
|
||||
UserGroup=column_ifexists('usergroup_s', ''),
|
||||
BgCategories=column_ifexists('bgcategories_s', ''),
|
||||
NetworkBytes=column_ifexists('size_s', ''),
|
||||
City=column_ifexists('city_s', ''),
|
||||
DvcGuid=column_ifexists('deviceguid_g', ''),
|
||||
DstIpAddr=column_ifexists('destinationip_s', ''),
|
||||
SrcIpAddr=column_ifexists('IPAddress', ''),
|
||||
Webreputation=column_ifexists('webreputation_s', ''),
|
||||
SrcGeoLongitude=column_ifexists('long_s', ''),
|
||||
DstDomain=column_ifexists('requestdomain_s', ''),
|
||||
SeTransactionid=column_ifexists('setransactionid_g', ''),
|
||||
Arguments=column_ifexists('arguments_s', ''),
|
||||
IndexedTime=todatetime(indexedtime_s),
|
||||
Email=column_ifexists('email_s', ''),
|
||||
BgCloudScore=column_ifexists('bgcloudscore_s', ''),
|
||||
FirstName=column_ifexists('firstname_s', ''),
|
||||
LastName=column_ifexists('lastname_s', ''),
|
||||
DvcHostname=column_ifexists('devicehostname_s', ''),
|
||||
SrcGeoRegionCode=column_ifexists('regioncode_s', ''),
|
||||
SrcGeoLatitude=column_ifexists('lat_s', ''),
|
||||
SrcBytes=column_ifexists('uploadedbytes_s', ''),
|
||||
WebCategories=column_ifexists('webcategories_s', ''),
|
||||
SrcGeoCountryCode=column_ifexists('countrycode_s', ''),
|
||||
HttpReferrer=column_ifexists('referrer_s', ''),
|
||||
SrcGeoCountry=column_ifexists('country_s', ''),
|
||||
SrcGeoRegion=column_ifexists('region_s', ''),
|
||||
Uri=column_ifexists('uri_s', ''),
|
||||
CustomCategories=column_ifexists('customcategories_s', ''),
|
||||
EventEndTime=todatetime(time_s),
|
||||
Action=column_ifexists('action_s', ''),
|
||||
HttpUserAgent=column_ifexists('useragent_s', ''),
|
||||
WebCategoryClass=column_ifexists('webcategoryclass_s', ''),
|
||||
EventType=column_ifexists('log_type_s', '')
|
||||
| project
|
||||
TimeGenerated,
|
||||
EventVendor,
|
||||
SrcFileExtension,
|
||||
DocType,
|
||||
SrcFileSHA256,
|
||||
SrcFileSHA1,
|
||||
PolicyId,
|
||||
ThreatId,
|
||||
SrcFileMD5,
|
||||
Keyword,
|
||||
HttpStatusCode,
|
||||
DvcId,
|
||||
Owner,
|
||||
EventResult,
|
||||
SrcFilePath,
|
||||
FileId,
|
||||
FileLink,
|
||||
SharedWith,
|
||||
User,
|
||||
Dvc,
|
||||
Application,
|
||||
SrcGeoLocation,
|
||||
EventMessage,
|
||||
HttpRequest,
|
||||
TransactionId,
|
||||
EmailFrom,
|
||||
EmailTo,
|
||||
EmailSubject,
|
||||
EmailCc,
|
||||
EmailBcc,
|
||||
EmailSentTime,
|
||||
SrcFileName,
|
||||
DlpPattern,
|
||||
PageTitle,
|
||||
Url,
|
||||
EventResultDetails,
|
||||
SyslogHeader,
|
||||
NetworkProtocol,
|
||||
CustomLocation,
|
||||
HttpRequestMethod,
|
||||
UserGroup,
|
||||
BgCategories,
|
||||
NetworkBytes,
|
||||
City,
|
||||
DvcGuid,
|
||||
DstIpAddr,
|
||||
SrcIpAddr,
|
||||
Webreputation,
|
||||
SrcGeoLongitude,
|
||||
DstDomain,
|
||||
SeTransactionid,
|
||||
Arguments,
|
||||
IndexedTime,
|
||||
Email,
|
||||
BgCloudScore,
|
||||
FirstName,
|
||||
LastName,
|
||||
DvcHostname,
|
||||
SrcGeoRegionCode,
|
||||
SrcGeoLatitude,
|
||||
SrcBytes,
|
||||
WebCategories,
|
||||
SrcGeoCountryCode,
|
||||
HttpReferrer,
|
||||
SrcGeoCountry,
|
||||
SrcGeoRegion,
|
||||
Uri,
|
||||
CustomCategories,
|
||||
EventEndTime,
|
||||
Action,
|
||||
HttpUserAgent,
|
||||
WebCategoryClass,
|
||||
EventType
|
||||
};
|
||||
Bitglass_view
|
Загрузка…
Ссылка в новой задаче