Home
%3CLINGO-SUB%20id%3D%22lingo-sub-352191%22%20slang%3D%22en-US%22%3ETicketing%20system%20integration%20%E2%80%93%20Alert%20update%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-352191%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%2048px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F83411i676D9EBFED18F1AA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%26nbsp%3B5%20Minutes%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%2052px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F83412iF0578A9CAA1028F8%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3ELow%20complexity%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20our%20last%20API%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAnnouncements%2FWDATP-API-Hello-World-or-using-a-simple-PowerShell-script-to%2Fm-p%2F326813%23M50%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3Eblog%3C%2FA%3E%20we%20demonstrated%20how%20you%20can%20use%20Windows%20Defender%20ATP%20APIs%20to%20pull%20alerts%20using%20a%20simple%20PowerShell%20script.%20Typical%20use%20cases%20where%20pulling%20of%20alerts%20using%20APIs%20apply%20to%20%3CSTRONG%3Eticketing%20system%3C%2FSTRONG%3E%20and%20%3CSTRONG%3ESIEM%20%3C%2FSTRONG%3Eintegration%20scenarios.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20a%20follow%20up%20to%20that%20blog%2C%20we%E2%80%99re%20going%20to%20demonstrate%20how%20you%20can%20apply%20it%20in%20two%20common%20integration%20use%20cases%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ECreate%20tickets%20or%20alert%20objects%20in%20an%20external%20system%20(SIEM%2C%20ITSM)%20after%20pulling%20the%20alerts%2C%20and%3C%2FLI%3E%0A%3CLI%3EUpdate%20tickets%20or%20alert%20objects%20from%20an%20external%20system%20and%20have%20the%20changes%20reflected%20in%20Windows%20Defender%20ATP%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EIn%20this%20blog%20we%E2%80%99ll%20focus%20on%20updating%20the%20alert%20as%20part%20of%20a%20typical%20ticketing%2FSIEM%20integration.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1677888729%22%20id%3D%22toc-hId-1702081748%22%3E%3CFONT%20color%3D%22%23666699%22%3EIntegration%20flow%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3EThe%20integration%20flow%20generally%20occurs%20in%20two%20steps%3A%20ticket%20creation%20then%20ticket%20update.%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3ETicket%2Falert%20creation%3CUL%3E%0A%3CLI%3EWindows%20Defender%20ATP%20-%20Pull%20alerts%20from%20Windows%20Defender%20ATP%20as%20demonstrated%20in%20the%20%E2%80%9CHello%20World%E2%80%9D%20blog.%3C%2FLI%3E%0A%3CLI%3EExternal%20-%20Create%20ticket%2Falert%20object%20in%20the%20external%20system.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3ETicket%20update%3CUL%3E%0A%3CLI%3EExternal%20%E2%80%93%20User%20updates%20the%20ticket%2Falert%20object%20in%20the%20external%20system.%3C%2FLI%3E%0A%3CLI%3EWindows%20Defender%20ATP%20-%20Update%20the%20alert%20in%20Windows%20Defender%20ATP%20according%20to%20changes%20in%20the%20external%20system.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CH2%20id%3D%22toc-hId--874268232%22%20id%3D%22toc-hId--850075213%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-868542103%22%20id%3D%22toc-hId-892735122%22%3E%3CFONT%20color%3D%22%23666699%22%3EWhat%20are%20the%20differences%20from%20the%20%E2%80%9CHello%20World%E2%80%9D%20blog%3F%3C%2FFONT%3E%3C%2FH2%3E%0A%3COL%3E%0A%3CLI%3EThe%20app%20now%20needs%20the%20%3CSTRONG%3Ealert%20%3C%2FSTRONG%3E%3CSTRONG%3Ewrite%20permission%3C%2FSTRONG%3E%20(vs.%20the%20%3CSTRONG%3Ealert%20%3C%2FSTRONG%3E%3CSTRONG%3Eread%20permission%20%3C%2FSTRONG%3Ewe%20used)%3C%2FLI%3E%0A%3CLI%3EThe%20customer%20must%20create%20the%20ticket%20using%20the%20ticketing%20system%20API%3CUL%3E%0A%3CLI%3EWe%20recommend%20storing%20the%20Windows%20Defender%20ATP%20alert%20ID%20as%20part%20of%20the%20ticket%20to%20enable%20later%20update%20of%20the%20corresponding%20Windows%20Defender%20ATP%20alert.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EThe%20update%20command%20we%20demonstrate%20here%20should%20be%20called%20from%20the%20ticketing%2FSIEM%20system%20for%20every%20relevant%20change%20or%20a%20scheduled%20task%20should%20pull%20changes%20from%20the%20ticketing%2FSIEM%20system%20and%20update%20WDATP%20using%20the%20update%20command.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--1487101353%22%20id%3D%22toc-hId--1462908334%22%3E%3CFONT%20color%3D%22%23666699%22%3ELet%E2%80%99s%20get%20our%20hands%20dirty%3C%2FFONT%3E%3C%2FH1%3E%0A%3CP%3EIn%20this%20section%2C%20we%E2%80%99ll%20walk%20you%20through%20the%20following%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EStep%201%3A%20Add%20the%20required%20permission%20to%20your%20application%3C%2FLI%3E%0A%3CLI%3EStep%202%3A%20Create%20the%20ticket%2Falert%20from%20an%20external%20system%3C%2FLI%3E%0A%3CLI%3EStep%203%3A%20Update%20the%20Windows%20Defender%20ATP%20alert%20based%20on%20the%20change%20done%20on%20the%20external%20system%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH2%20id%3D%22toc-hId-59195477%22%20id%3D%22toc-hId-83388496%22%3E%3CFONT%20color%3D%22%23666699%22%3EStep%201%20-%20Add%20the%20required%20permission%20to%20the%20application%3A%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3EWith%20your%20Global%20administrator%20credentials%2C%20login%20to%20the%20%3CA%20href%3D%22https%3A%2F%2Fportal.azure.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20portal%3C%2FA%3E.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EAzure%20Active%20Directory%20%26gt%3B%20App%20registrations.%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EClick%20the%20drop-down%20button%20and%20select%20%E2%80%9CAll%20apps%E2%80%9D.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F83415i70FBB0368791B038%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EChoose%20the%20application%20you%20created%20in%20the%20%E2%80%9CHello%20World%E2%80%9D%20example.%20If%20you%20used%20the%20suggested%20name%2C%20it%20was%20%E2%80%9CContosoSIEMConnector%E2%80%9D.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F83419i2EC1A76A43B5D3E2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIn%20the%20application%20page%20choose%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3ESettings%20%26gt%3B%20Required%20permissions%20%26gt%3B%20WindowsDefenderATP%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F83420i6B6A0516695ADE36%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ECheck%20the%20checkbox%20near%20%E2%80%9CRead%20and%20write%20all%20alerts%E2%80%9D%20permission%2C%20then%20click%20Save.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F83421i69E77B9C9B1FB06E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIn%20the%20%E2%80%9CRequired%20permissions%E2%80%9D%20page%2C%20select%20the%20%E2%80%9CGrant%20permissions%E2%80%9D%20button%20and%20then%20click%20%E2%80%9CYes%E2%80%9D.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F83422iBAD624C788722D4D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EDone!%3C%2FSTRONG%3E%20You%20have%20successfully%20added%20the%20required%20permissions%20to%20the%20application.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1802005812%22%20id%3D%22toc-hId-1826198831%22%3E%3CFONT%20color%3D%22%23666699%22%3EStep%202%20%E2%80%93%20Create%20the%20ticket%2Falert%20in%20the%20external%20system%3A%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3EDepending%20on%20the%20external%20system%20API%20or%20integration%20tool%20that%20you%20use%2C%20this%20step%20might%20be%20applied%20in%20various%20methods.%20However%2C%20the%20general%20idea%20is%20to%20periodically%20pull%20new%20alerts%20from%20Windows%20Defender%20ATP%20as%20demonstrated%20in%20the%20%E2%80%9Chello%20world%E2%80%9D%20blog.%3C%2FP%3E%0A%3CP%3EFor%20each%20alert%20you%20should%20call%20the%20external%20system%20API%20to%20create%20a%20ticket.%20We%20recommend%20that%20you%20store%20the%20alert%20ID%20in%20the%20created%20object.%20It%20will%20be%20handy%20for%20Windows%20Defender%20ATP%20alert%20object%20update%20later.%3C%2FP%3E%0A%3CP%3EThe%20following%20example%20is%20an%20update%20of%20the%20%E2%80%9CHello%20World%E2%80%9D%20code.%20It%20demonstrates%20how%20to%20iterate%20over%20the%20alerts%20and%20shows%20how%20to%20get%20their%20alert%20ID.%3C%2FP%3E%0A%3CP%3ENOTE%3A%20Some%20SIEM%20platforms%20allow%20direct%20JSON%20file%20import.%20This%20is%20out%20of%20this%20blog%E2%80%99s%20scope.%3C%2FP%3E%0A%3CP%3ECopy%20this%20example%20to%20the%20same%20folder%20where%20you%20stored%20the%20%E2%80%9CHello%20World%E2%80%9D%20scripts.%20Name%20it%20%E2%80%9CGet-Alerts-And-Open-Ticket.ps1%E2%80%9D.%20%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%23%20Returns%20Alerts%20created%20in%20the%20past%204%20hours.%0A%23%20Setting%20a%20place%20holder%20for%20a%20code%20to%20open%20a%20ticket%20in%20external%20ticketing%20system.%0A%0A%24token%20%3D%20.%5CGet-Token.ps1%0A%0A%24dateTime%20%3D%20(Get-Date).ToUniversalTime().AddHours(-4).ToString(%22o%22)%0A%0A%0A%24url%20%3D%20%22https%3A%2F%2Fapi.securitycenter.windows.com%2Fapi%2Falerts%3F%60%24filter%3DalertCreationTime%20ge%20%24dateTime%22%0A%0A%24headers%20%3D%20%40%7B%20%0A%20%20%20%20'Content-Type'%20%3D%20'application%2Fjson'%0A%20%20%20%20Accept%20%3D%20'application%2Fjson'%0A%20%20%20%20Authorization%20%3D%20%22Bearer%20%24token%22%20%0A%7D%0A%0A%24response%20%3D%20Invoke-RestMethod%20-Method%20Get%20-Uri%20%24url%20-Headers%20%24headers%20-ErrorAction%20Stop%0A%0A%23foreach%20alert%2C%20get%20the%20alertId%20and%20the%20data%20that%20needed%20to%20open%20a%20ticket%20and%20call%20the%20ticketing%20system%20API%20to%20open%20the%20ticket%0Aforeach%20(%24alert%20in%20%24response.value)%7B%0A%24alertId%20%3D%20%24alert.id%0A%24alertTitle%20%3D%20%24alert.title%0A%23extract%20the%20rest%20of%20the%20data%20relevant%20to%20the%20ticket.%0A%0A%23%20replace%20the%20next%20line%20with%20your%20code%20to%20open%20the%20ticket%20using%20the%20ticketing%20system's%20API%0A%5BSystem.Windows.MessageBox%5D%3A%3AShow(%22Alert%20title%20-%20%24alertTitle.%20%5CnAlert%20ID%20-%20%24alertId%22)%0A%7D%20%3C%2FPRE%3E%0A%3CP%3EThe%20script%20will%20display%20a%20message%20box%20with%20the%20alert%20title%20and%20alert%20ID.%20Run%20the%20script.%3C%2FP%3E%0A%3CP%3EYou%E2%80%99re%20welcome%20to%20replace%20the%20message%20box%20code%20with%20your%20own%20ticketing%20system%20ticket%20creation%20code.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F83426iB21AA8D2A361C59F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--750151149%22%20id%3D%22toc-hId--725958130%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-992659186%22%20id%3D%22toc-hId-1016852205%22%3E%3CFONT%20color%3D%22%23666699%22%3EStep%203%20%E2%80%93%20Update%20the%20Windows%20Defender%20ATP%20alert%20according%20to%20the%20ticket%2Falert%20change%3A%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3ETo%20simplify%20the%20API%20usage%20we%20created%20the%20following%20script%20called%20%E2%80%9C%3CSTRONG%3EAlert-Update.ps1%3C%2FSTRONG%3E%E2%80%9D.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EStore%20it%20in%20the%20same%20folder%20with%20the%20other%20scripts%20(the%20%3CSTRONG%3E%3CU%3Esame%20folder%3C%2FU%3E%3C%2FSTRONG%3E%20we%20saved%20the%20Get-Token.ps1).%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F83427i6ED5AA23485B33EB%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1756011280%22%20id%3D%22toc-hId--1731818261%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId--13200945%22%20id%3D%22toc-hId-10992074%22%3E%3CFONT%20color%3D%22%23666699%22%3EAlert-Update.ps1%3C%2FFONT%3E%3C%2FH3%3E%0A%3CPRE%3Eparam%20(%20%20%20%0A%20%20%20%20%5BParameter(Mandatory%3D%24true)%5D%0A%20%20%20%20%5Bstring%5D%24alertId%2C%20%20%20%20%20%23an%20input%20parameter%20for%20the%20alert's%20ID%0A%20%0A%20%20%20%20%5BValidatePattern(%22%5E%5BA-Za-z0-9._%25%2B-%5D%2B%40%5BA-Za-z0-9.-%5D%2B%5C.%5BA-Za-z%5D%7B2%2C%7D%24%22)%5D%20%23only%20valid%20email%20address%20formats%20are%20allowed%0A%20%20%20%20%5Bstring%5D%24assignedTo%2C%20%20%23an%20input%20parameter%20for%20the%20email%20address%20we%20want%20to%20assign%20the%20alert%20to.%20%20%20%20%0A%0A%20%20%20%20%5BParameter()%5D%0A%20%20%20%20%5BValidateSet('New'%2C'InProgress'%2C'Resolved')%5D%20%20%23validate%20that%20the%20input%20contains%20valid%20status%20value%0A%20%20%20%20%5Bstring%5D%24status%2C%20%23an%20input%20parameter%20for%20alert's%20new%20status.%0A%0A%20%20%20%20%5BParameter()%5D%0A%20%20%20%20%5BValidateSet('Unknown'%2C'FalsePositive'%2C'TruePositive')%5D%20%20%23validate%20that%20the%20input%20contains%20valid%20classification%20value%0A%20%20%20%20%5Bstring%5D%24classification%2C%23an%20input%20parameter%20for%20alert's%20new%20status.%0A%0A%20%20%20%20%5BParameter()%5D%0A%20%20%20%20%5BValidateSet('NotAvailable'%2C'Apt'%2C'Malware'%2C'SecurityPersonnel'%2C%20'SecurityTesting'%2C%20'UnwantedSoftware'%2C%20'Other'%20)%5D%20%20%23validate%20that%20the%20input%20contains%20valid%20classification%20value%0A%20%20%20%20%5Bstring%5D%24determination%20%23an%20input%20parameter%20for%20alert's%20new%20status.%0A%0A%20)%0A%0A%24token%20%3D%20.%5CGet-Token.ps1%20%20%20%20%20%20%20%23Execute%20Get-Token.ps1%20script%20to%20get%20the%20authorization%20token%0A%0A%24url%20%3D%20%22https%3A%2F%2Fapi.securitycenter.windows.com%2Fapi%2Falerts%2F%24alertId%22%20%20%20%20%23Set%20the%20url%20with%20the%20current%20alert%20ID.%20%0A%0A%24body%20%3D%20%40%7B%7D%0Aif(%24assignedTo%20-ne%20%5Bstring%5D%3A%3AEmpty)%0A%7B%0A%20%20%20%20%24body.Add(%22assignedTo%22%2C%24assignedTo)%0A%7D%0A%0Aif(%24status%20-ne%20%5Bstring%5D%3A%3AEmpty)%0A%7B%0A%20%20%20%20%24body.Add(%22status%22%2C%24status)%0A%7D%0A%0Aif(%24classification%20-ne%20%5Bstring%5D%3A%3AEmpty)%0A%7B%0A%20%20%20%20%24body.Add(%22classification%22%2C%24classification)%0A%7D%0A%0Aif(%24determination%20-ne%20%5Bstring%5D%3A%3AEmpty)%0A%7B%0A%20%20%20%20%24body.Add(%22determination%22%2C%24determination)%0A%7D%0A%20%24headers%20%3D%20%40%7B%20%0A%20%20%20%20'Content-Type'%20%3D%20'application%2Fjson'%0A%20%20%20%20Accept%20%3D%20'application%2Fjson'%0A%20%20%20%20Authorization%20%3D%20%22Bearer%20%24token%22%0A%7D%0A%0A%24response%20%3D%20Invoke-WebRequest%20-Method%20Patch%20-Uri%20%24url%20-Body%20(%24body%20%7C%20ConvertTo-Json)%20-Headers%20%24headers%20-ErrorAction%20Stop%0A%0Aif(%24response.StatusCode%20-eq%20200)%20%20%20%23check%20the%20response%20status%20code%0A%7B%0A%20%20%20%20return%20%24true%20%20%20%20%20%20%20%20%23update%20ended%20successfully%0A%7D%0Aelse%0A%7B%0A%20%20%20%20return%20%24false%20%20%20%20%20%20%20%23update%20failed%0A%7D%20%3C%2FPRE%3E%0A%3CH3%20id%3D%22toc-hId-1014448101%22%20id%3D%22toc-hId-1038641120%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId--1537708860%22%20id%3D%22toc-hId--1513515841%22%3E%3CFONT%20color%3D%22%23666699%22%3EOption%201%3A%20Push%20update%3C%2FFONT%3E%3C%2FH3%3E%0A%3CP%3ETicketing%20systems%20as%20well%20as%20SIEM%20systems%20expose%20extensibility%20interfaces%20to%20enrich%20the%20experience%20with%20custom%20flows.%20You%20can%20use%20the%20following%20calls%20to%20update%20the%20Windows%20Defender%20ATP%20alert%20according%20to%20the%20ticket%20changes.%3C%2FP%3E%0A%3CP%3EFor%20example%2C%20if%20an%20analyst%20decides%20to%20close%20the%20ticket%20as%20a%20false%20positive.%20The%20automation%20code%20should%20call%20the%20following%20command%3A%3C%2FP%3E%0A%3CTABLE%20style%3D%22height%3A%2030px%3B%20width%3A%20630px%3B%22%3E%0A%3CTBODY%3E%0A%3CTR%20style%3D%22height%3A%2030px%3B%22%3E%0A%3CTD%20style%3D%22width%3A%20674px%3B%20height%3A%2030px%3B%22%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E.%5CAlert-Update.ps1%20-alertId%26nbsp%3B636845233049028347_-906875643%20-classification%20FalsePositive%26nbsp%3B%20-status%20Resolved%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20cases%20of%20alert%20classification%20and%20assignment%20change%20use%20the%20following%20command%3A%3C%2FP%3E%0A%3CTABLE%20style%3D%22height%3A%2057px%3B%20width%3A%20630px%3B%22%3E%0A%3CTBODY%3E%0A%3CTR%20style%3D%22height%3A%2057px%3B%22%3E%0A%3CTD%20style%3D%22height%3A%2057px%3B%20width%3A%20623px%3B%22%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E.%5CAlert-Update.ps1%20-alertId%3C%2FFONT%3E%3CFONT%20size%3D%222%22%3E%26nbsp%3B636845233049028347_-906875643%20-classification%20FalsePositive%20-assignedTo%20haim%40cotoso.com%3C%2FFONT%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CH3%20id%3D%22toc-hId-205101475%22%20id%3D%22toc-hId-229294494%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId-1947911810%22%20id%3D%22toc-hId-1972104829%22%3E%3CFONT%20color%3D%22%23666699%22%3EOption%202%3A%20Pull%20update%3C%2FFONT%3E%3C%2FH3%3E%0A%3CP%3EInstead%20of%20integrating%20the%20API%20call%20into%20the%20SIEM%20or%20ticketing%20system%2C%20you%20can%20schedule%20a%20periodical%20call%20to%20collect%20ticket%20changes%20and%20update%20the%20Windows%20Defender%20ATP%20alert.%20Same%20is%20true%20for%20webhooks%20as%20a%20callback%20mechanism.%20For%20both%20you%20can%20use%20the%20same%20API%20calls.%3C%2FP%3E%0A%3CP%3E%3CEM%3E%3CFONT%20color%3D%22%23666699%22%3ETip%20for%20PowerShell%20newbies%3C%2FFONT%3E%3C%2FEM%3E%20%E2%80%93%20use%20the%20PowerShell%20console%20Intellisense%20to%20browse%20for%20different%20command%20options.%20Type%20the%20script%20name%20and%20a%20hyphen%20to%20get%20auto-completion%20options%20(see%20below).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20414px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F83423iE2A079091E017E9F%2Fimage-dimensions%2F414x106%3Fv%3D1.0%22%20width%3D%22414%22%20height%3D%22106%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1192706208%22%20id%3D%22toc-hId-1216899227%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId--1359450753%22%20id%3D%22toc-hId--1335257734%22%3E%3CFONT%20color%3D%22%23666699%22%3EConclusion%3A%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3EWindows%20Defender%20ATP%20open%20API%20exposes%20the%20building%20blocks%20for%20simple%20scenarios%20as%20well%20as%20complex%20multi-stage%20integrations.%20In%20this%20example%20we%20demonstrated%20the%20typical%20use%20cases%20where%20you%20can%20apply%20the%20use%20of%20APIs%20to%20create%20and%20update%20tickets%20in%20the%20context%20of%20external%20tools.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EIn%20the%20future%20we%E2%80%99ll%20share%20specific%20product%20integration%20examples.%20You%E2%80%99re%20more%20than%20welcome%20to%20share%20your%20experience%20or%20integration%20examples.%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EIf%20you%20are%20interested%20in%20specific%20product%20integration%20examples%2C%20let%20us%20know.%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EIn%20the%20next%20blog%2C%20we%E2%80%99ll%20walk%20you%20through%20using%20Windows%20Defender%20ATP%3C%2FSTRONG%3E%20%3CSTRONG%3EAPIs%3C%2FSTRONG%3E%20%3CSTRONG%3Eto%20isolate%20machine%20from%20the%20network%20which%20can%20be%20very%20handy%20as%20a%20quick%20response%20to%20a%20high-risk%20security%20alert.%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EThanks!%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F138020%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3E%40Haim%20Goldshtein%3C%2FA%3E%2C%20security%20software%20engineer%2C%20Windows%20Defender%20ATP%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F183190%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3E%40Dan%20Michelson%3C%2FA%3E%2C%20program%20manager%2C%20Windows%20Defender%20ATP%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-352191%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Edanmich%40microsoft.com%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EHaim.Goldshtein%40microsoft.com%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-360128%22%20slang%3D%22en-US%22%3ERe%3A%20Ticketing%20system%20integration%20%E2%80%93%20Alert%20update%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-360128%22%20slang%3D%22en-US%22%3E%3CP%3EAnyone%20who%20tried%20this%20blog%20and%20want%20to%20share%20experience%20is%20more%20than%20welcome.%3C%2FP%3E%0A%3CP%3EWe%20would%20like%20to%20hear%20your%20feedback.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

image.png 5 Minutes

image.pngLow complexity

 

In our last API blog we demonstrated how you can use Windows Defender ATP APIs to pull alerts using a simple PowerShell script. Typical use cases where pulling of alerts using APIs apply to ticketing system and SIEM integration scenarios.

 

As a follow up to that blog, we’re going to demonstrate how you can apply it in two common integration use cases:

  • Create tickets or alert objects in an external system (SIEM, ITSM) after pulling the alerts, and
  • Update tickets or alert objects from an external system and have the changes reflected in Windows Defender ATP

In this blog we’ll focus on updating the alert as part of a typical ticketing/SIEM integration.

 

Integration flow

The integration flow generally occurs in two steps: ticket creation then ticket update.

  1. Ticket/alert creation
    • Windows Defender ATP - Pull alerts from Windows Defender ATP as demonstrated in the “Hello World” blog.
    • External - Create ticket/alert object in the external system.
  2. Ticket update
    • External – User updates the ticket/alert object in the external system.
    • Windows Defender ATP - Update the alert in Windows Defender ATP according to changes in the external system.

 

What are the differences from the “Hello World” blog?

  1. The app now needs the alert write permission (vs. the alert read permission we used)
  2. The customer must create the ticket using the ticketing system API
    • We recommend storing the Windows Defender ATP alert ID as part of the ticket to enable later update of the corresponding Windows Defender ATP alert.

The update command we demonstrate here should be called from the ticketing/SIEM system for every relevant change or a scheduled task should pull changes from the ticketing/SIEM system and update WDATP using the update command.

 

Let’s get our hands dirty

In this section, we’ll walk you through the following:

  • Step 1: Add the required permission to your application
  • Step 2: Create the ticket/alert from an external system
  • Step 3: Update the Windows Defender ATP alert based on the change done on the external system

Step 1 - Add the required permission to the application:

With your Global administrator credentials, login to the Azure portal.

  • Azure Active Directory > App registrations.

Click the drop-down button and select “All apps”.

image.png

Choose the application you created in the “Hello World” example. If you used the suggested name, it was “ContosoSIEMConnector”.

image.png

In the application page choose:

  • Settings > Required permissions > WindowsDefenderATP

image.png

Check the checkbox near “Read and write all alerts” permission, then click Save.

image.png

In the “Required permissions” page, select the “Grant permissions” button and then click “Yes”.

image.png

Done! You have successfully added the required permissions to the application.

 

Step 2 – Create the ticket/alert in the external system:

Depending on the external system API or integration tool that you use, this step might be applied in various methods. However, the general idea is to periodically pull new alerts from Windows Defender ATP as demonstrated in the “hello world” blog.

For each alert you should call the external system API to create a ticket. We recommend that you store the alert ID in the created object. It will be handy for Windows Defender ATP alert object update later.

The following example is an update of the “Hello World” code. It demonstrates how to iterate over the alerts and shows how to get their alert ID.

NOTE: Some SIEM platforms allow direct JSON file import. This is out of this blog’s scope.

Copy this example to the same folder where you stored the “Hello World” scripts. Name it “Get-Alerts-And-Open-Ticket.ps1”.  

# Returns Alerts created in the past 4 hours.
# Setting a place holder for a code to open a ticket in external ticketing system.

$token = .\Get-Token.ps1

$dateTime = (Get-Date).ToUniversalTime().AddHours(-4).ToString("o")


$url = "https://api.securitycenter.windows.com/api/alerts?`$filter=alertCreationTime ge $dateTime"

$headers = @{ 
    'Content-Type' = 'application/json'
    Accept = 'application/json'
    Authorization = "Bearer $token" 
}

$response = Invoke-RestMethod -Method Get -Uri $url -Headers $headers -ErrorAction Stop

#foreach alert, get the alertId and the data that needed to open a ticket and call the ticketing system API to open the ticket
foreach ($alert in $response.value){
$alertId = $alert.id
$alertTitle = $alert.title
#extract the rest of the data relevant to the ticket.

# replace the next line with your code to open the ticket using the ticketing system's API
[System.Windows.MessageBox]::Show("Alert title - $alertTitle. \nAlert ID - $alertId")
} 

The script will display a message box with the alert title and alert ID. Run the script.

You’re welcome to replace the message box code with your own ticketing system ticket creation code.

image.png

 

Step 3 – Update the Windows Defender ATP alert according to the ticket/alert change:

To simplify the API usage we created the following script called “Alert-Update.ps1”. 

Store it in the same folder with the other scripts (the same folder we saved the Get-Token.ps1).

image.png

 

Alert-Update.ps1

param (   
    [Parameter(Mandatory=$true)]
    [string]$alertId,     #an input parameter for the alert's ID
	
    [ValidatePattern("^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$")] #only valid email address formats are allowed
    [string]$assignedTo,  #an input parameter for the email address we want to assign the alert to.    

    [Parameter()]
    [ValidateSet('New','InProgress','Resolved')]  #validate that the input contains valid status value
    [string]$status, #an input parameter for alert's new status.

    [Parameter()]
    [ValidateSet('Unknown','FalsePositive','TruePositive')]  #validate that the input contains valid classification value
    [string]$classification,#an input parameter for alert's new status.

    [Parameter()]
    [ValidateSet('NotAvailable','Apt','Malware','SecurityPersonnel', 'SecurityTesting', 'UnwantedSoftware', 'Other' )]  #validate that the input contains valid classification value
    [string]$determination #an input parameter for alert's new status.

 )

$token = .\Get-Token.ps1       #Execute Get-Token.ps1 script to get the authorization token

$url = "https://api.securitycenter.windows.com/api/alerts/$alertId"    #Set the url with the current alert ID. 

$body = @{}
if($assignedTo -ne [string]::Empty)
{
    $body.Add("assignedTo",$assignedTo)
}

if($status -ne [string]::Empty)
{
    $body.Add("status",$status)
}

if($classification -ne [string]::Empty)
{
    $body.Add("classification",$classification)
}

if($determination -ne [string]::Empty)
{
    $body.Add("determination",$determination)
}
 $headers = @{ 
    'Content-Type' = 'application/json'
    Accept = 'application/json'
    Authorization = "Bearer $token"
}

$response = Invoke-WebRequest -Method Patch -Uri $url -Body ($body | ConvertTo-Json) -Headers $headers -ErrorAction Stop

if($response.StatusCode -eq 200)   #check the response status code
{
    return $true        #update ended successfully
}
else
{
    return $false       #update failed
} 

 

Option 1: Push update

Ticketing systems as well as SIEM systems expose extensibility interfaces to enrich the experience with custom flows. You can use the following calls to update the Windows Defender ATP alert according to the ticket changes.

For example, if an analyst decides to close the ticket as a false positive. The automation code should call the following command:

.\Alert-Update.ps1 -alertId 636845233049028347_-906875643 -classification FalsePositive  -status Resolved

 

For cases of alert classification and assignment change use the following command:

.\Alert-Update.ps1 -alertId 636845233049028347_-906875643 -classification FalsePositive -assignedTo haim@cotoso.com

 

Option 2: Pull update

Instead of integrating the API call into the SIEM or ticketing system, you can schedule a periodical call to collect ticket changes and update the Windows Defender ATP alert. Same is true for webhooks as a callback mechanism. For both you can use the same API calls.

Tip for PowerShell newbies – use the PowerShell console Intellisense to browse for different command options. Type the script name and a hyphen to get auto-completion options (see below).

 

image.png

 

Conclusion:

Windows Defender ATP open API exposes the building blocks for simple scenarios as well as complex multi-stage integrations. In this example we demonstrated the typical use cases where you can apply the use of APIs to create and update tickets in the context of external tools.

In the future we’ll share specific product integration examples. You’re more than welcome to share your experience or integration examples.

If you are interested in specific product integration examples, let us know.

 

In the next blog, we’ll walk you through using Windows Defender ATP APIs to isolate machine from the network which can be very handy as a quick response to a high-risk security alert.

 

Thanks!

@Haim Goldshtein, security software engineer, Windows Defender ATP

@Dan Michelson, program manager, Windows Defender ATP

 

1 Comment
Microsoft

Anyone who tried this blog and want to share experience is more than welcome.

We would like to hear your feedback.