{"id":411,"date":"2020-07-28T17:00:00","date_gmt":"2020-07-29T00:00:00","guid":{"rendered":"http:\/\/andrew.the-espositos.net\/blog\/?p=411"},"modified":"2020-07-30T06:15:13","modified_gmt":"2020-07-30T13:15:13","slug":"imperva-data-risk-analytics","status":"publish","type":"post","link":"https:\/\/andrew.the-espositos.net\/blog\/2020\/07\/imperva-data-risk-analytics\/","title":{"rendered":"Imperva Data Risk Analytics"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Managing Whitelist Rules for Departments<\/h3>\n\n\n\n<p style=\"background-color:#ffe0e0\" class=\"has-background\">This article was updated. See sections in pink below for new information.<\/p>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\">I&#8217;ve run into a scenario where I feel like I&#8217;m chasing my tail; I can&#8217;t get on top of the Issues and Incidents created in DRA.  It seems like my whitelist rules are growing exponentially. Managing these rules are a constant challenge. I had been trying to create rules by users and event types; however, I have come to the realization that this is just not sustainable.<\/p>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\">We need a better way.<\/p>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\">It would be fantastic if Imperva allowed you to make a rule for a user&#8217;s department. I&#8217;ve put the suggesting into the User Voice Feature Request system; jump over there and up-vote it please, so they fix it faster. However, before they program a new feature, I have just come up with a work around to allow the easy creation of DRA Whitelist rules for whole Departments and not just for individuals.  <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Use Case<\/h4>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\">I have many department of people that are power users, not DBAs, but statistical data scientists. They go into our data warehouse and pull billions of records out for statistical analysis. Although they may hit the same databases over and over again, they are always creating new, complex queries to answer the business question of the day. Today, I may find user-A touching database-1; so, I search for existing rules, none-found, make a rule user-A\/database-1. Tomorrow I see user-A touching database-2; so, I search for existing rules, found one, modify it, add database-2.  Then, user-B comes along, and touches both database-1 and database-2; so, I search for an existing rule, none-found, make a rule for user-B\/database1,database2. <\/p>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\">With a limited group of users and databases, this wouldn&#8217;t be an issue.  I work at a corporation with many of these departments, hundreds of databases, and thousands of database users.  It&#8217;s a real issue.  I&#8217;m battling to keep on top of hundreds of new Issues created daily.  I think this has been the source of my migraines recently.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Apology and Prerequisites<\/h4>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\">Let me take the time here to apologize. I am sorry for two things: 1) I cannot share screen shots of my environment for illustration purposes <em>(security and confidentiality)<\/em> and 2) this workaround requires PowerShell and the Active Directory Module for PowerShell <em>(Mac &gt; Windows, but my job wouldn&#8217;t give me a MacBook)<\/em>.  I am aware there is a cross platform PowerShell available at <a href=\"https:\/\/aka.ms\/pscore6\">https:\/\/aka.ms\/pscore6<\/a>, however I do not know if this will work.  Good Luck if you decide to try it.  Let me know if it works.<\/p>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\">See <a href=\"https:\/\/adamtheautomator.com\/install-powershell-active-directory-module\/\">https:\/\/adamtheautomator.com\/install-powershell-active-directory-module\/<\/a> for instructions on getting the PowerShell module installed. Without it, the scripts below will just produce errors.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">PowerShell Script Workaround<\/h4>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\">This script uses the known &#8220;Department&#8221; from the User Information screen in DRA as input.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># code to getDept.ps1\n# Get all AD users in a Department\n$Dept = Read-Host -Prompt 'Department Name'\n$Raw = Get-ADUser -filter {Department -eq $Dept} | select SamAccountName -ExpandProperty SamAccountName\n$Out = ($Raw -join \",\")\n$Out<\/pre>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\">A very straightforward script.  You put in the Department that is displayed in DRA, and you get a coma delimited list of usernames to put back into DRA.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">PS C:\\Users\\Andrew\\Scripts&gt; .\\getDept.ps1\nDepartment Name: Data Scientists\ntombillings,marthaking,debbieshort,jimbarker,markrustle,heathersands<\/pre>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\">The next script uses the known username from DRA and outputs the user&#8217;s department.  Then the department can be used in the script above.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># code to getUsersDept.ps1\n# Display a User's Department from AD\n$User = Read-Host -Prompt 'User Name'\n$Out = Get-ADUser -Properties *  -Idendity $User | select Department -ExpandProperty Department\n$Out<\/pre>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\">User gets Department, Department gets list of members.  Copy\/Paste the list of members into DRA, and you have a rule for a Department.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">PS C:\\Users\\Andrew\\Scripts&gt; .\\getUsersDept.ps1\nUser Name: debbieshort\nData Scientists<\/pre>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\">These are my first PowerShell scripts. I&#8217;m surprised at how concise and powerful PowerShell scripting is. I&#8217;m very impressed.  I think I&#8217;ll be doing a lot more PowerShell scripting in the future.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Updated:<\/h2>\n\n\n\n<p style=\"background-color:#ffe0e0\" class=\"has-background\">In testing and quality assurance, it was brought to my attention that &#8220;Department&#8221; was sometimes too broad a category.  For example: when I used my corporate CN, I got everyone on my team, everyone on the Oracle DBA team, everyone on the MSSQL DBA team, and all the other DBA teams.  I shouldn&#8217;t have the same rights and privileges as a DBA nor should DRA rules apply to me the same as they do to the DBAs; however, we are in the same Department. So, I needed a way to limit the user list to just people who had an identical job role.<\/p>\n\n\n\n<p style=\"background-color:#ffe0e0\" class=\"has-background\">The Manager is the answer.  A field that the DRA tool and all user records have in common is the user&#8217;s manager. I created a separate script to grab all users with a specific user&#8217;s manager to get a &#8220;Team&#8221;.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># Code to getTeam.ps1\n# Search AD for all the users under a manager\n$User = Read-Host -Prompt 'Users CN (username)'\n$Manager = Get-ADUser -Properties * -Identity $User | select Manager -ExpandProperty Manager\n$raw = Get-ADUser -filter {Manager -eq $Manager} | select SamAccountName -ExpandProperty SamAccountName\n# Format the output\n$out = ($raw -join \",\")\n# Display the output\n$out<\/pre>\n\n\n\n<p style=\"background-color:#ffe0e0\" class=\"has-background\">Of course, if your AD isn&#8217;t populated with accurate information this won&#8217;t work well, but then again, neither will DRA for that matter. Good Luck!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Managing Whitelist Rules for Departments This article was updated. See sections in pink below for new information. I&#8217;ve run into a scenario where I feel like I&#8217;m chasing my tail; I can&#8217;t get on top of the Issues and Incidents created in DRA. It seems like my whitelist rules are growing exponentially. Managing these rules &#8230; <span class=\"more\"><a class=\"more-link\" href=\"https:\/\/andrew.the-espositos.net\/blog\/2020\/07\/imperva-data-risk-analytics\/\">[Read more&#8230;]<\/a><\/span><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,20],"tags":[44,43,42,46,45],"class_list":{"0":"entry","1":"post","2":"publish","3":"author-siteuser","4":"post-411","6":"format-standard","7":"category-professional","8":"category-technical","9":"post_tag-counterbreach","10":"post_tag-dra","11":"post_tag-imperva","12":"post_tag-rules","13":"post_tag-whitelist"},"_links":{"self":[{"href":"https:\/\/andrew.the-espositos.net\/blog\/wp-json\/wp\/v2\/posts\/411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/andrew.the-espositos.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andrew.the-espositos.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andrew.the-espositos.net\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/andrew.the-espositos.net\/blog\/wp-json\/wp\/v2\/comments?post=411"}],"version-history":[{"count":8,"href":"https:\/\/andrew.the-espositos.net\/blog\/wp-json\/wp\/v2\/posts\/411\/revisions"}],"predecessor-version":[{"id":420,"href":"https:\/\/andrew.the-espositos.net\/blog\/wp-json\/wp\/v2\/posts\/411\/revisions\/420"}],"wp:attachment":[{"href":"https:\/\/andrew.the-espositos.net\/blog\/wp-json\/wp\/v2\/media?parent=411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andrew.the-espositos.net\/blog\/wp-json\/wp\/v2\/categories?post=411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andrew.the-espositos.net\/blog\/wp-json\/wp\/v2\/tags?post=411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}