<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Conditional execution of search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Conditional-execution-of-search/m-p/570724#M198890</link>
    <description>&lt;P&gt;Sorry, Principal.AWS needs to be in single quotes&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where Principal="*" OR 'Principal.AWS'="*"&lt;/LI-CODE&gt;&lt;P&gt;Does this give you what you want, i.e. are you looking for literal * or are you looking any value in Principal or Principal.AWS?&lt;/P&gt;</description>
    <pubDate>Wed, 13 Oct 2021 09:02:54 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2021-10-13T09:02:54Z</dc:date>
    <item>
      <title>Conditional execution of search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-execution-of-search/m-p/570709#M198885</link>
      <description>&lt;P&gt;Hello All,&amp;nbsp; Can someone help me to build a search query for the below use case ?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;My use case is to detect if any S3 buckets have been set for Public access via PutBucketPolicy event.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I need this query to show results only if&amp;nbsp; the fields&amp;nbsp; &lt;STRONG&gt;Effect&lt;/STRONG&gt; and &lt;STRONG&gt;Principal&lt;/STRONG&gt; both have values&amp;nbsp; "Allow"&amp;nbsp; and "&lt;STRONG&gt;&amp;nbsp;*&lt;/STRONG&gt;&amp;nbsp; or &lt;STRONG&gt;{AWS:*} "&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;respectively&amp;nbsp;for the same SID.&amp;nbsp; &amp;nbsp;Basically the following 2 conditions must be met for a particular SID.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Effect&lt;/STRONG&gt;: Allow&lt;BR /&gt;&lt;STRONG&gt;Principal&lt;/STRONG&gt;:&amp;nbsp;&lt;STRONG&gt;&amp;nbsp;*&lt;/STRONG&gt;&amp;nbsp; OR&amp;nbsp;{AWS:*}&lt;BR /&gt;-----------------------&lt;BR /&gt;&lt;BR /&gt;The Raw event data however has 2 SIDs&amp;nbsp; ( MustBeEncryptedInTransit and&amp;nbsp;Cloudfront Access)&amp;nbsp; as shown below and each one has conflicting values of &lt;STRONG&gt;Effect&lt;/STRONG&gt; &amp;amp; &lt;STRONG&gt;Principal&lt;/STRONG&gt;.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;eventName": "PutBucketPolicy"
 "awsRegion": "us-east-1"
 "sourceIPAddress": "x.x.x.x"
 "userAgent": "[&amp;lt;some agent&amp;gt;]"
 "requestParameters": {"bucketPolicy": {"Version": "2012-10-17"
 "Statement": [{"Sid": "MustBeEncryptedInTransit"
 "Effect": "Deny"
 "Action": "s3:*"
 "Resource": ["arn:aws:s3:::&amp;lt;Bucket_Name&amp;gt;/*"
 "arn:aws:s3:::&amp;lt;Bucket_Name&amp;gt;"]
 "Principal": "*"
 "Condition": {"Bool": {"aws:SecureTransport": ["false"]}}}
 {"Sid": "Cloudfront Access"
 "Effect": "Allow"
 "Action": "s3:*"
 "Resource": "arn:aws:s3::&amp;lt;Bucket_Name&amp;gt;/*"
 "Principal": {"AWS": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity XXXXXX"}}]}
 "bucketName": "&amp;lt;Bucket_Name&amp;gt;"
 "Host": "&amp;lt;SomeHost_Name&amp;gt;"
 "policy": ""}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, if i try the below search, it generates False Positives because the raw data has everything in the same event:&amp;nbsp; &amp;nbsp;Effect = Allow , Effect = Deny, Principal = *&amp;nbsp; &amp;nbsp;and 2 values of SID&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;sourcetype=aws:cloudtrail eventName IN(PutBucketPolicy) userName="abcd" requestParameters.bucketPolicy.Statement{}.Effect = "Allow"  requestParameters.bucketPolicy.Statement{}.Principal = "*" requestParameters.bucketPolicy.Statement{}.Sid = "Cloudfront Access"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I am just lost as in how to build an eval statement to check if SID = CloudFront Access or SID!=MustBeEncryptedInTransit&amp;nbsp; only then check for values of Effect and Principal.&lt;BR /&gt;&lt;BR /&gt;Hope i am clear.&amp;nbsp; If you all have better suggestions to check for pubic access using Putbucketpolicy or ACL let me know&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 07:06:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-execution-of-search/m-p/570709#M198885</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2021-10-13T07:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional execution of search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-execution-of-search/m-p/570712#M198886</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="{\"eventName\": \"PutBucketPolicy\",
 \"awsRegion\": \"us-east-1\",
 \"sourceIPAddress\": \"x.x.x.x\",
 \"userAgent\": \"[&amp;lt;some agent&amp;gt;]\",
 \"requestParameters\": {\"bucketPolicy\": {\"Version\": \"2012-10-17\",
 \"Statement\": [{\"Sid\": \"MustBeEncryptedInTransit\",
 \"Effect\": \"Deny\",
 \"Action\": \"s3:*\",
 \"Resource\": [\"arn:aws:s3:::&amp;lt;Bucket_Name&amp;gt;/*\",
 \"arn:aws:s3:::&amp;lt;Bucket_Name&amp;gt;\"],
 \"Principal\": \"*\",
 \"Condition\": {\"Bool\": {\"aws:SecureTransport\": [\"false\"]}}},
 {\"Sid\": \"Cloudfront Access\",
 \"Effect\": \"Allow\",
 \"Action\": \"s3:*\",
 \"Resource\": \"arn:aws:s3::&amp;lt;Bucket_Name&amp;gt;/*\",
 \"Principal\": {\"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity XXXXXX\"}}]},
 \"bucketName\": \"&amp;lt;Bucket_Name&amp;gt;\",
 \"Host\": \"&amp;lt;SomeHost_Name&amp;gt;\",
 \"policy\": \"\"}}"



| spath requestParameters.bucketPolicy.Statement{} output=Statement
| mvexpand Statement
| spath input=Statement
| where Effect="Allow"
| where Principal="*" OR Principal.AWS="*"&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 13 Oct 2021 07:54:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-execution-of-search/m-p/570712#M198886</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-10-13T07:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional execution of search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-execution-of-search/m-p/570719#M198888</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp; Thank you for responding.&lt;BR /&gt;&lt;BR /&gt;I tried including your search beginning with |spath command onwards but it didn't work as expected.&amp;nbsp; Note- i did not run the makeresults because i cannot make&amp;nbsp; results in our production environment.&lt;BR /&gt;&lt;BR /&gt;I am seeing that irrespective of whatever value i put for &lt;STRONG&gt;Principal.AWS&lt;/STRONG&gt; in the where clause,&amp;nbsp; it shows NO Results found.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Meaning by supplying&amp;nbsp; &lt;STRONG&gt;Principal.AWS ="*"&lt;/STRONG&gt;&amp;nbsp; OR&amp;nbsp; &lt;STRONG&gt;Principal.AWS="arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity XXXXX"&lt;/STRONG&gt;&amp;nbsp; &amp;nbsp;both show&amp;nbsp; "No results found".&lt;BR /&gt;&lt;BR /&gt;In Theory if you look at the raw data,&amp;nbsp; if&amp;nbsp;Principal.AWS ="arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity XXXXX"&amp;nbsp; then it should have shown atleast that 1 event in results.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;| spath requestParameters.bucketPolicy.Statement{} output=Statement
| mvexpand Statement
| spath input=Statement
| where Effect="Allow"
| where Principal="*" OR Principal.AWS="*&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 08:31:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-execution-of-search/m-p/570719#M198888</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2021-10-13T08:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional execution of search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-execution-of-search/m-p/570724#M198890</link>
      <description>&lt;P&gt;Sorry, Principal.AWS needs to be in single quotes&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where Principal="*" OR 'Principal.AWS'="*"&lt;/LI-CODE&gt;&lt;P&gt;Does this give you what you want, i.e. are you looking for literal * or are you looking any value in Principal or Principal.AWS?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 09:02:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-execution-of-search/m-p/570724#M198890</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-10-13T09:02:54Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional execution of search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-execution-of-search/m-p/570725#M198891</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;can you try to change last where to&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| search Principal=* OR Principal.AWS=*&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually you could use | makeresults on your production when you are testing something. It just create temporary events (not store those to index) which you can manipulate on same SPL query.&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.2/SearchReference/Makeresults" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.2.2/SearchReference/Makeresults&lt;/A&gt;&lt;/P&gt;&lt;P&gt;r. Ismo&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 09:15:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-execution-of-search/m-p/570725#M198891</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2021-10-13T09:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional execution of search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-execution-of-search/m-p/570739#M198895</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;I am looking for literal * in Prinicpal.AWS and Principal fields.&amp;nbsp; Enclosing single quotes didn't have any effect.&lt;BR /&gt;&lt;BR /&gt;Actually using single or double quotes and&amp;nbsp; &lt;STRONG&gt;search&lt;/STRONG&gt; command instead of &lt;STRONG&gt;where&lt;/STRONG&gt; did the trick for the Prinicipal or Principal.AWS elements.&amp;nbsp; Below is what worked.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| search "Principal"="*" OR "Principal.AWS"="*"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 10:51:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-execution-of-search/m-p/570739#M198895</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2021-10-13T10:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional execution of search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-execution-of-search/m-p/570740#M198896</link>
      <description>&lt;P&gt;Thank you. That was very helpful&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 10:44:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-execution-of-search/m-p/570740#M198896</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2021-10-13T10:44:10Z</dc:date>
    </item>
  </channel>
</rss>

