<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sampson Akpomiomio on Medium]]></title>
        <description><![CDATA[Stories by Sampson Akpomiomio on Medium]]></description>
        <link>https://medium.com/@akpomiomio.sampson?source=rss-8e29737a619e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*46lvAWKmOBU6zeAOyv2tmA.png</url>
            <title>Stories by Sampson Akpomiomio on Medium</title>
            <link>https://medium.com/@akpomiomio.sampson?source=rss-8e29737a619e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 20:52:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akpomiomio.sampson/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Turning Detection into Code: Automating Security Operations with Google SecOps and Harness CI]]></title>
            <link>https://medium.com/@akpomiomio.sampson/turning-detection-into-code-automating-security-operations-with-google-secops-and-harness-ci-14964ff5de7c?source=rss-8e29737a619e------2</link>
            <guid isPermaLink="false">https://medium.com/p/14964ff5de7c</guid>
            <dc:creator><![CDATA[Sampson Akpomiomio]]></dc:creator>
            <pubDate>Tue, 11 Nov 2025 11:08:32 GMT</pubDate>
            <atom:updated>2025-11-11T14:20:51.996Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x1B00BWsL9yu0XC9Hv5Ljg.png" /><figcaption>Infrastructure-as-Code</figcaption></figure><p>Security teams are in a constant race against evolving threats regardless of wether the underlying infrastructure changes or not. Managing detection rules manually across different environments is slow, prone to human error, and lacks auditable change history. This traditional approach simply doesn’t scale in modern cloud-native environments.</p><p>Detection-as-Code (DaC) is a paradigm shift that applies the principles of software development and DevOps to security detection. By treating detection rules as code, you can version, test, and deploy them through automated, repeatable workflows.</p><p>Google SecOps SIEM (formerly Chronicle) is built with this philosophy in mind, offering a robust API and native Terraform support. This article will demonstrate a complete, production-ready workflow for implementing Detection-as-Code, from authoring a rule to deploying it automatically with a Harness CI pipeline.</p><p>A brief workflow description<strong>:</strong></p><ol><li><strong>The Foundation:</strong> Storing YARA-L rules in a Git repository.</li><li><strong>Quality Gates:</strong> Validating rule syntax and logic with the VerifyRule API.</li><li><strong>Deployment:</strong> Pushing rules to Google SecOps using Terraform and the Detection engine API.</li><li><strong>Auditing:</strong> Tracking changes with built-in rule versioning.</li><li><strong>Automation:</strong> Scaling rule management with a Harness CI/CD pipeline.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xcwa330Um4RPWmavXTRPwg.png" /><figcaption><em>A high-level overview of the CI/CD workflow for detection rules.</em></figcaption></figure><p>Ensure the following requirements have been met:</p><ul><li>A Google SecOps SIEM instance.</li><li>A GCP project with the Chronicle API enabled.</li><li>A GCP Service Account with the <strong>Chronicle API A</strong>dmin (roles/chronicle.admin) role.</li><li>The Service Account key in JSON format.</li><li>A Git repository (e.g., on GitHub, GitLab, or Harness) to store your rules and files from <a href="https://github.com/GoogleCloudPlatform/secops-toolkit/tree/main/pipelines/detection-as-code">cloned repository</a>.</li><li><a href="https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli">Terraform</a> installed locally. (<em>Terraform cloud is still optional)</em></li><li>A CI platform account (<a href="https://www.harness.io/">Harness</a> is being used here, but the principles apply to Github, GitLab, CircleCI, etc.).</li></ul><h3>Step 1: Storing Rules in Git</h3><p>The first step is to establish a structured Git repository for all YARA-L rules. This repository becomes the single source of truth for the entire detection project.</p><p><strong>Repository Structure:</strong></p><pre>├── rules/                  # YARA-L detection rules<br>│   ├── gcp_anomalous_iam_grant.yaral<br>│   ├── gcp_firewall_rule_change.yaral<br>│   └── remote_desktop_from_internet_via_audit.yaral                   <br>├── secops_reference_lists/   # Reference lists for rules<br>├── README.md<br>├── terraform/              # Terraform configurations<br>│   ├── main.tf<br>│   ├── variables.tf<br>│   └── outputs.tf<br>├── .harness/              # Harness pipeline configurations (Inline)<br>│   └── pipeline.yaml      # Pipeline definition (Inline)<br>└── secops_rules.yaml     # Rule deployment settings</pre><p><strong>Example YARA-L Rule (</strong><strong>remote_desktop_from_internet_via_audit.yaral):</strong></p><pre>rule remote_desktop_from_internet_via_audit {<br> meta:<br>    author = &quot;Google Cloud Security&quot;<br>    description = &quot;Detects RDP logons from non-private ip ranges. RDP &amp; Local Administrator accounts are often targeted for remote access.  License: https://github.com/Neo23x0/sigma/blob/master/LICENSE.Detection.Rules.md.&quot;<br>    reference = &quot;https://tdm.socprime.com/tdm/info/DS3MRqpI1PBa&quot;<br>    version = &quot;0.01&quot;<br>    created = &quot;2021-03-09&quot;<br>    product = &quot;windows&quot;<br>    service = &quot;security&quot;<br>    mitre = &quot;initial_access, t1076, t1078&quot;<br><br>  events:<br>    ($selection1.metadata.product_event_type = &quot;4624&quot; and $selection1.extensions.auth.mechanism  = 10)<br>    not $selection1.principal.ip in cidr %private_ip_ranges<br><br>  condition:<br>    $selection1<br>}</pre><p>With all rules in Git, every change is now a commit. This gives a complete, auditable history of who changed what, when, and why.</p><h3>Step 2: Validating Rules with the &quot;VerifyRule” API</h3><p>Before deploying a rule, ensure it’s valid. A syntax error could break the rule, rendering it useless even after deploying. The Google SecOps VerifyRule API endpoint is a critical quality gate.</p><p>Test this with a simple curl command. An access token is needed first.</p><p><strong>1. Get an Access Token:</strong></p><pre># gcloud auth activate-service-account --key-file=[service-account-key.json]</pre><pre>ACCESS_TOKEN=$(gcloud auth print-access-token)<br>CUSTOMER_ID=&quot;CHRONICLE_CUSTOMER_ID&quot;</pre><p><strong>2. Call the </strong><strong>VerifyRule API Endpoint:</strong></p><pre># install google-api-python-client from terminal<br>from google.auth.transport import requests<br>from google.oauth2 import service_account<br><br>SCOPES = [&#39;https://www.googleapis.com/auth/chronicle-backstory&#39;]<br><br>SERVICE_ACCOUNT_FILE = &#39;chronicle-api-sa.json&#39;<br><br>credentials = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES)<br><br>http_session = requests.AuthorizedSession(credentials)<br><br>url = &#39;https://backstory.googleapis.com/v2/detect/rules:verifyRule&#39;<br><br># Read the rule content into a variable<br>RULE_TEXT=$(cat ./gcp/gcp_anomalous_iam_grant.yaral)<br>body = {<br>  &quot;ruleText&quot;: RULE_TEXT<br>}<br><br>response = http_session.request(&quot;POST&quot;, url, json=body)<br><br>if response.status_code != 200:<br>    print(f&quot;Error: HTTP {response.status_code}: {response.text}\n&quot;)<br>    exit_code = 1<br><br>    result = response.json()<br>    success = result.get(&quot;success&quot;)<br>    context = result.get(&quot;context&quot;)<br><br>if success is True:<br>    print(f&quot;Verified:&quot;)<br>    print(f&quot;   Context: {context}\n&quot;)<br>else:<br>    print(f&quot;Verification failed&quot;)<br>    print(f&quot;   Context: {context}\n&quot;)<br>    exit_code = 1</pre><ul><li><strong>Successful Response (HTTP 200 OK):</strong> An empty JSON body {} indicates the rule syntax is valid.</li><li><strong>Failed Response (HTTP 400 Bad Request):</strong> The response will contain a detailed error message, which is invaluable for debugging.</li></ul><p>This validation step should be the first stage in any automated pipeline.</p><h3>Step 3: Deploying Rules with Terraform</h3><p>While detection engine API’s can be used to create/manage rules, the best practice is to use Terraform. It allows you to manage rules declaratively, maintain state, and understand the impact of changes before applying them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*DyHx7AxBX510uGTCT8ZaWA.png" /></figure><p><strong>1. Configure the Terraform Provider:</strong> Create a providers.tf file. We use the google-beta provider as it often has the latest Chronicle features.</p><pre>terraform {<br>  required_providers {<br>    google-beta = {<br>      source  = &quot;hashicorp/google-beta&quot;<br>      version = &quot;&gt;= 5.10.0&quot;<br>    }<br>  }<br>}<br><br>provider &quot;google-beta&quot; {<br>  project = &quot;&lt;gcp-project-id&gt;&quot;<br>  // Credentials can be configured via environment variables<br>}</pre><p><strong>2. Define the Rule Resource:</strong> In main.tf, define a resource for each rule file.</p><pre>/**<br> * Copyright 2025 Google LLC<br> *<br> * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);<br> * you may not use this file except in compliance with the License.<br> * You may obtain a copy of the License at<br> *<br> *      http://www.apache.org/licenses/LICENSE-2.0<br> *<br> * Unless required by applicable law or agreed to in writing, software<br> * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,<br> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br> * See the License for the specific language governing permissions and<br> * limitations under the License.<br> */<br><br>locals {<br>  # reference_lists = yamldecode(file(&quot;${path.module}/${var.secops_content_config.reference_lists}&quot;))<br>  reference_list_type_mapping = {<br>    STRING = &quot;REFERENCE_LIST_SYNTAX_TYPE_PLAIN_TEXT_STRING&quot;<br>    REGEX  = &quot;REFERENCE_LIST_SYNTAX_TYPE_REGEX&quot;<br>    CIDR   = &quot;REFERENCE_LIST_SYNTAX_TYPE_CIDR&quot;<br>  }<br>  secops_rules = {<br>    for file_name in fileset(&quot;${path.module}/rules&quot;, &quot;*.yaral&quot;) : replace(file_name, &quot;.yaral&quot;, &quot;&quot;) =&gt; file(&quot;${path.module}/rules/${file_name}&quot;)<br>  }<br>  secops_rule_deployment = yamldecode(file(&quot;${path.module}/${var.secops_content_config.rules}&quot;))<br>}<br><br># resource &quot;google_chronicle_reference_list&quot; &quot;reference_list&quot; {<br>#   for_each          = local.reference_lists<br>#   project           = var.secops_project_id<br>#   location          = var.secops_region<br>#   instance          = var.secops_customer_id<br>#   reference_list_id = each.key<br>#   description       = each.value.description<br>#   dynamic &quot;entries&quot; {<br>#     for_each = toset(split(&quot;\n&quot;, file(&quot;${path.module}/reference_lists/${each.key}.txt&quot;)))<br>#     content {<br>#       value = entries.value<br>#     }<br>#   }<br>#   syntax_type = local.reference_list_type_mapping[each.value.type]<br># }<br><br>resource &quot;google_chronicle_rule&quot; &quot;rule&quot; {<br>  for_each        = local.secops_rule_deployment<br>  project         = var.secops_project_id<br>  location        = var.secops_region<br>  instance        = var.secops_customer_id<br>  deletion_policy = &quot;FORCE&quot;<br>  text            = local.secops_rules[each.key]<br>  # depends_on = [<br>  #   google_chronicle_reference_list.reference_list<br>  # ]<br>}<br><br>resource &quot;google_chronicle_rule_deployment&quot; &quot;rule_deployment&quot; {<br>  for_each      = local.secops_rule_deployment<br>  project       = var.secops_project_id<br>  location      = var.secops_region<br>  instance      = var.secops_customer_id<br>  rule          = google_chronicle_rule.rule[each.key].rule_id<br>  enabled       = each.value.enabled<br>  alerting      = each.value.alerting<br>  archived      = each.value.archived<br>  run_frequency = each.value.run_frequency<br>}</pre><p><strong>3. The Terraform Workflow:</strong></p><ul><li>terraform init: Initialize the backend and providers.</li><li>terraform plan: See a preview of changes (create, update, or delete). This is a crucial review step.</li><li>terraform apply: Execute the plan and deploy the rules to Google SecOps SIEM.</li></ul><p>Terraform will now manage the state of detection rules, making updates and deletions safe and predictable.</p><h3>Step 4: Tracking Changes with Rule Versioning</h3><p>Google SecOps automatically versions every rule created or updated. When a change is pushed via Terraform or the API, it doesn’t overwrite the old rule; it creates a new, active version.</p><ul><li><strong>VER_1</strong>, <strong>VER_2</strong>, etc., are created for each update.</li><li>The most recent version becomes the <strong>LIVE</strong> version.</li><li>You can view, and even revert to, previous versions directly in the UI.</li></ul><p>This provides an immediate audit trail within the SIEM, which perfectly complements the commit history in the Git repository. Git commit hash can easily be correlated with a specific rule version in Chronicle for end-to-end auditability.</p><h3>Step 5: Scaling with a Harness CI Pipeline</h3><p>Bringing it all together, a CI pipeline automates the entire lifecycle. On every commit to the main branch, the pipeline will trigger, ensuring rules are validated and deployed consistently.</p><p>Here’s a conceptual Harness pipeline template(.harness/pipeline.yml):</p><pre>template:<br>  name: pipeline_template<br>  identifier: pipeline_template<br>  orgIdentifier: &lt;HARNESS_ORG_IDENTIFIER&gt;<br>  versionLabel: version1<br>  type: Pipeline<br>  tags: {}<br>  spec:<br>    properties:<br>      ci:<br>        codebase:<br>          repoName: &lt;+input&gt;<br>          build: &lt;+input&gt;<br>    stages:<br>      - stage:<br>          name: terraform-plan<br>          identifier: tfplan<br>          description: &quot;&quot;<br>          type: CI<br>          spec:<br>            cloneCodebase: true<br>            caching:<br>              enabled: false<br>              override: false<br>              paths: []<br>            infrastructure:<br>              type: KubernetesDirect<br>              spec:<br>                connectorRef: account.&lt;CONNECTOR_ID&gt;<br>                namespace: default<br>                labels:<br>                  key: &lt;VALUE&gt;<br>                automountServiceAccountToken: true<br>                nodeSelector: {}<br>                os: Linux<br>            execution:<br>              steps:<br>                - step:<br>                    type: Run<br>                    name: terraform-plan<br>                    identifier: tfplan<br>                    spec:<br>                      connectorRef: account.&lt;CONNECTOR_ID&gt;<br>                      image: europe-east2-docker.pkg.dev/{project}/{dir}/{image-name}:{tag}<br>                      shell: Bash<br>                      command: ls -l &amp;&amp; pwd &amp;&amp; cd detection-as-code &amp;&amp; terraform init &amp;&amp; terraform plan<br>                      envVariables:<br>                        TF_TOKEN_app_terraform_io: &lt;+secrets.getValue(&quot;account.TERRAFORM_TOKEN&quot;)&gt;<br>                        GOOGLE_CREDENTIALS: &lt;+secrets.getValue(&quot;account.chronicle-google-credentials&quot;)&gt;<br>            buildIntelligence:<br>              enabled: false<br>      - stage:<br>          name: Terraform Apply Approval<br>          identifier: Terraform_Apply_Approval<br>          description: &quot;&quot;<br>          type: Approval<br>          spec:<br>            execution:<br>              steps:<br>                - step:<br>                    name: Terraform Apply Approval<br>                    identifier: Terraform_Apply_Approval<br>                    type: HarnessApproval<br>                    timeout: 1d<br>                    spec:<br>                      approvalMessage: |-<br>                        Kindly review the following changes<br>                        and approve the pipeline progression<br>                      includePipelineExecutionHistory: true<br>                      approvers:<br>                        minimumCount: 1<br>                        disallowPipelineExecutor: false<br>                        userGroups:<br>                          - org.Terraform_Approvals<br>                      isAutoRejectEnabled: false<br>                      approverInputs: []<br>          tags: {}<br>          when:<br>            pipelineStatus: Success<br>            condition: (&lt;+trigger.event&gt; == &quot;PUSH&quot;) &amp;&amp; ((&lt;+codebase.branch&gt; == &quot;main&quot;))<br>      - stage:<br>          name: terraform-apply<br>          identifier: tfapply<br>          description: &quot;&quot;<br>          type: CI<br>          spec:<br>            cloneCodebase: true<br>            caching:<br>              enabled: true<br>              override: false<br>            infrastructure:<br>              useFromStage: tfplan<br>            execution:<br>              steps:<br>                - step:<br>                    type: Run<br>                    name: tf-apply<br>                    identifier: tfapply<br>                    spec:<br>                      connectorRef: account.&lt;CONNECTOR_ID&gt;<br>                      image: europe-east2-docker.pkg.dev//{project}/{dir}/{image-name}:{tag}<br>                      shell: Sh<br>                      command: echo $GOOGLE_CREDENTIALS &amp;&amp; ls -l &amp;&amp; pwd &amp;&amp; cd detection-as-code &amp;&amp; terraform init &amp;&amp; terraform apply -auto-approve<br>                      envVariables:<br>                        TF_TOKEN_app_terraform_io: &lt;+secrets.getValue(&quot;account.TERRAFORM_TOKEN&quot;)&gt;<br>                        GOOGLE_CREDENTIALS: &lt;+secrets.getValue(&quot;account.chronicle-google-credentials&quot;)&gt;<br>          when:<br>            pipelineStatus: Success<br>            condition: (&lt;+trigger.event&gt; == &quot;PUSH&quot;) &amp;&amp; ((&lt;+codebase.branch&gt; == &quot;main&quot;))<br></pre><p><strong>This pipeline enforces the workflow:</strong></p><ol><li><strong>Commit:</strong> A security engineer pushes a new or updated rule to Git.</li><li><strong>Validate:</strong> The pipeline automatically triggers and runs the VerifyRule script. If it fails, the process stops, and the developer is notified.</li><li><strong>Plan:</strong> If validation passes, terraform plan runs, showing the expected changes.</li><li><strong>Approve:</strong> The pipeline pauses for a manual review. A team lead can inspect the plan and approve or reject it.</li><li><strong>Apply:</strong> On approval, terraform apply runs, deploying the rule to Google SecOps.</li></ol><p>By adopting a Detection-as-Code approach, rule management can be transformed from a manual, brittle process into a robust, automated, and scalable workflow. This methodology empowers security teams to:</p><ul><li><strong>Increase Velocity:</strong> Deploy new detections rapidly in response to emerging threats.</li><li><strong>Improve Reliability:</strong> Catch errors early through automated validation.</li><li><strong>Enhance Auditing:</strong> Maintain a clear, version-controlled history of all detection changes.</li><li><strong>Boost Collaboration:</strong> Use merge requests and code reviews to improve rule quality.</li></ul><p>Integrating tools like Google SecOps SIEM, Terraform, and a modern CI/CD platform isn’t just an operational improvement; it’s a strategic advantage that allows security teams to keep pace with the modern threat landscape.</p><h3>References</h3><p><a href="https://medium.com/google-cloud/detection-as-code-in-google-secops-with-terraform-646de8967278">Detection as Code in Google SecOps with Terraform</a> — Part 1 — Simone Brusschesse</p><p><a href="https://medium.com/google-cloud/detection-as-code-in-google-secops-with-terraform-part-2-907a5cffe3d8">Detection as Code in Google SecOps with Terraform</a> — Part 2 — Simone Brusschesse</p><p><a href="https://www.googlecloudcommunity.com/gc/Community-Blog/Getting-Started-with-Detection-as-Code-and-Chronicle-Security/ba-p/702154">Getting Started with Detection-as-Code and Chronicle Security Operations (Part 1 of 2) </a>— David French</p><p><a href="https://www.googlecloudcommunity.com/gc/Community-Blog/Getting-Started-with-Detection-as-Code-and-Chronicle-Security/ba-p/702956">Getting Started with Detection-as-Code and Chronicle Security Operations (Part 2 of 2)</a> — David French</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14964ff5de7c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>