<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Adewumi Victor</title>
    <description>The latest articles on Forem by Adewumi Victor (@adewumicrown).</description>
    <link>https://forem.com/adewumicrown</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3904453%2F4a0c8b14-8f53-4721-8f5d-660aeca00624.jpg</url>
      <title>Forem: Adewumi Victor</title>
      <link>https://forem.com/adewumicrown</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/adewumicrown"/>
    <language>en</language>
    <item>
      <title>Beyond Automation: Building a Policy-Gated Deployment Engine with OPA and Prometheus</title>
      <dc:creator>Adewumi Victor</dc:creator>
      <pubDate>Wed, 06 May 2026 21:10:44 +0000</pubDate>
      <link>https://forem.com/adewumicrown/beyond-automation-building-a-policy-gated-deployment-engine-with-opa-and-prometheus-c1l</link>
      <guid>https://forem.com/adewumicrown/beyond-automation-building-a-policy-gated-deployment-engine-with-opa-and-prometheus-c1l</guid>
      <description>&lt;p&gt;When you first start in DevOps, you think the goal is a "Green Pipeline." You want the code to build, the container to start, and the URL to load. But as systems scale, a "Green Pipeline" can actually be a disaster.&lt;/p&gt;

&lt;p&gt;What if your container starts, but the server is out of disk space? What if the code runs, but it’s so slow that users give up? In this project, I moved beyond simple automation to Governance. I built SwiftDeploy: a deployment tool that doesn't just act; it thinks.&lt;/p&gt;

&lt;p&gt;The Core Problem: The "Blind" Deployment&lt;br&gt;
Most basic CI/CD setups are "blind." They push code and hope for the best. If the environment is unhealthy, the deployment crashes. If the code is buggy, the users suffer.&lt;/p&gt;

&lt;p&gt;To solve this, I added three human-like qualities to my deployment script:&lt;/p&gt;

&lt;p&gt;Eyes (Observability): The ability to see how the app is performing in real-time.&lt;/p&gt;

&lt;p&gt;A Brain (Policy Enforcement): A central logic engine to decide if a deployment is safe.&lt;/p&gt;

&lt;p&gt;A Memory (Auditing): A permanent record of every decision made.&lt;/p&gt;

&lt;p&gt;Step 1: The Architecture of Safety&lt;br&gt;
I designed SwiftDeploy as a multi-container ecosystem. Instead of one big app, I used a Sidecar Pattern.&lt;/p&gt;

&lt;p&gt;The CLI: My Python-based orchestrator.&lt;/p&gt;

&lt;p&gt;The App: Instrumented with Prometheus metrics.&lt;/p&gt;

&lt;p&gt;Open Policy Agent (OPA): Our "Supreme Court." It holds the laws (policies) and gives the final verdict on deployments.&lt;/p&gt;

&lt;p&gt;Nginx: The traffic controller that handles the switch from a "Canary" (test version) to "Stable" (live version).&lt;/p&gt;

&lt;p&gt;Step 2: Implementing the "Eyes" (Instrumentation)&lt;br&gt;
To make the app observable, I used the Prometheus text format. I modified my API to expose a /metrics endpoint. This isn't just a status page; it’s a high-speed stream of data tracking:&lt;/p&gt;

&lt;p&gt;Throughput: How many people are using the app?&lt;/p&gt;

&lt;p&gt;Error Rate: Is the app failing?&lt;/p&gt;

&lt;p&gt;Latency (P99): Is the app slow for the unluckiest 1% of users?&lt;/p&gt;

&lt;p&gt;Why P99? Average latency is a lie. If 99 people have a 1ms response and 1 person has a 10-second response, the "average" looks fine, but you’re losing 1% of your customers. SwiftDeploy looks at the P99 to ensure everyone has a good experience.&lt;/p&gt;

&lt;p&gt;Step 3: Implementing the "Brain" (OPA &amp;amp; Rego)&lt;br&gt;
This was the most exciting part. I used Open Policy Agent (OPA). OPA uses a language called Rego.&lt;/p&gt;

&lt;p&gt;The magic here is Decoupling. My CLI doesn't have hardcoded rules like if disk &amp;lt; 10GB. Instead, the CLI asks OPA: "Here is the current disk space and the user's requirements. Should I deploy?"&lt;/p&gt;

&lt;p&gt;I wrote two distinct policy domains:&lt;/p&gt;

&lt;p&gt;Infrastructure Policy: Guards the "physical" health (Disk, CPU, RAM).&lt;/p&gt;

&lt;p&gt;Canary Policy: Guards the "performance" health (Error rates, Latency).&lt;/p&gt;

&lt;p&gt;Step 4: The Gated Lifecycle in Action&lt;br&gt;
When I run ./swiftdeploy promote, a complex dance happens behind the scenes:&lt;/p&gt;

&lt;p&gt;Scrape: The CLI hits the Canary’s /metrics endpoint.&lt;/p&gt;

&lt;p&gt;Calculate: It computes the current Error Rate and P99 Latency.&lt;/p&gt;

&lt;p&gt;Consult: It sends this data to OPA.&lt;/p&gt;

&lt;p&gt;Decision: If OPA sees that the Error Rate is &amp;gt; 1%, it returns a DENY with a reason.&lt;/p&gt;

&lt;p&gt;Stop: The CLI aborts the promotion, keeping the "Stable" version safe and sound.&lt;/p&gt;

&lt;p&gt;Step 5: Chaos Engineering (Testing the Guardrails)&lt;br&gt;
A safety system is only good if it’s tested. I intentionally "broke" my environment to see if SwiftDeploy would catch it.&lt;/p&gt;

&lt;p&gt;Scenario A: I manually lowered the disk threshold in my config. Result: SwiftDeploy blocked the deployment immediately with a clear error message.&lt;/p&gt;

&lt;p&gt;Scenario B: I injected "Chaos" into the Canary, forcing it to return 500 errors. Result: The CLI refused to promote the Canary, saving the production environment from a faulty update.&lt;/p&gt;

&lt;p&gt;Step 6: The Audit Trail (The "Memory")&lt;br&gt;
In a professional setting, you need to know why a deployment failed three weeks ago. SwiftDeploy solves this by generating an audit_report.md.&lt;br&gt;
Every time the CLI checks a policy, it logs the input, the decision, and the reasoning into a history.jsonl file. This creates a transparent, unchangeable timeline of the system's health.&lt;/p&gt;

&lt;p&gt;Conclusion: What I Learned&lt;br&gt;
Building SwiftDeploy taught me that DevOps is about trust.&lt;/p&gt;

&lt;p&gt;You trust your metrics to tell the truth.&lt;/p&gt;

&lt;p&gt;You trust your policies to enforce the rules.&lt;/p&gt;

&lt;p&gt;You trust your automation to stay stopped when things go wrong.&lt;/p&gt;

&lt;p&gt;By separating the "How" (Docker/Nginx) from the "Why" (OPA/Rego), I’ve built a tool that is ready for the complexities of modern cloud-native engineering.&lt;br&gt;
you can checkout my repo to see all the project code at &lt;a href="https://github.com/Adewumicrown/swiftdeploy" rel="noopener noreferrer"&gt;https://github.com/Adewumicrown/swiftdeploy&lt;/a&gt;&lt;/p&gt;

</description>
      <category>automation</category>
      <category>cicd</category>
      <category>devops</category>
      <category>monitoring</category>
    </item>
    <item>
      <title>Building a Self-Learning DDoS Guard</title>
      <dc:creator>Adewumi Victor</dc:creator>
      <pubDate>Wed, 29 Apr 2026 13:40:22 +0000</pubDate>
      <link>https://forem.com/adewumicrown/building-a-self-learning-ddos-guard-4jd4</link>
      <guid>https://forem.com/adewumicrown/building-a-self-learning-ddos-guard-4jd4</guid>
      <description>&lt;p&gt;Real-Time Anomaly Detection with&lt;br&gt;
Python&lt;br&gt;
By Victor • HNG DevSecOps Project Case Study&lt;/p&gt;

&lt;p&gt;In the modern web landscape, static rate limiting is often a blunt instrument. While it&lt;br&gt;
can stop basic brute-force attacks, it struggles with sophisticated, low-and-slow DDoS&lt;br&gt;
attacks or sudden legitimate traffic spikes. For my latest HNG DevSecOps project, I&lt;br&gt;
built a dynamic Anomaly Detection &amp;amp; DDoS Engine that learns from your traffic&lt;br&gt;
patterns and defends your AWS infrastructure in real-time.&lt;/p&gt;

&lt;p&gt;The Problem: Why Static Limits Fail&lt;br&gt;
Most developers set a hard limit: "Allow 100 requests per minute." But what happens at&lt;br&gt;
2:00 AM when your server is usually empty? A sudden burst of 90 requests per&lt;br&gt;
minute from a single IP might be an attack, yet it passes under the radar. Conversely,&lt;br&gt;
during a Black Friday sale, 150 requests might be perfectly normal. I needed a system&lt;br&gt;
that understood context.&lt;/p&gt;

&lt;p&gt;The Solution: Statistical Learning&lt;br&gt;
The heart of this engine is a Python-based daemon that "learns" what normal traffic&lt;br&gt;
looks like for every hour of the day. It uses two key mathematical concepts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The Rolling Baseline&lt;br&gt;
Instead of hardcoded numbers, the engine maintains a 30-minute rolling window&lt;br&gt;
of traffic metrics. It calculates the mean and standard deviation for every hour&lt;br&gt;
slot. This allows the system to distinguish between a busy Monday afternoon and&lt;br&gt;
a quiet Sunday night.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Z-Score&lt;br&gt;
To identify an anomaly, we calculate the Z-Score of incoming traffic. The formula&lt;br&gt;
is:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;z = (x - μ) / σ&lt;/p&gt;

&lt;p&gt;Where x is the current traffic rate, μ is the learned mean, and σ is the standard&lt;br&gt;
deviation. If the z exceeds 3.0, the system flags the IP as an anomaly.&lt;/p&gt;

&lt;p&gt;The Architecture&lt;br&gt;
The project is deployed on AWS EC2 using a Dockerized stack:&lt;br&gt;
Nginx: Acts as the frontline, logging every request in a structured JSON format.&lt;br&gt;
Nextcloud: Our sample application being protected.&lt;br&gt;
Python Detector: The "Brain." It tails the Nginx logs, performs statistical&lt;br&gt;
analysis, and makes decisions.&lt;/p&gt;

&lt;p&gt;Active Defense with Iptables&lt;br&gt;
Detection is useless without action. When an IP is flagged, the engine doesn't just&lt;br&gt;
send an alert; it executes a system-level command using iptables to DROP all&lt;br&gt;
traffic from that IP. To ensure we don't block legitimate users forever, I implemented&lt;br&gt;
an Unbanner module. It follows an exponential backoff schedule: 10 minutes, then&lt;br&gt;
30 minutes, then 2 hours, before finally issuing a permanent ban for repeat&lt;br&gt;
offenders.&lt;/p&gt;

&lt;p&gt;Real-Time Visibility&lt;br&gt;
I integrated a Slack notification system to keep the DevOps team informed. Whether&lt;br&gt;
it’s a specific IP being banned, a global traffic surge, or an automatic unban, the team&lt;br&gt;
receives a formatted alert within seconds. Additionally, a Flask-based dashboard&lt;br&gt;
provides a live look at current metrics and system health.&lt;br&gt;
•&lt;br&gt;
•&lt;br&gt;
•&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
Securing infrastructure is not just about building walls; it's about building systems&lt;br&gt;
that can think. By combining Python’s data processing power with Linux’s networking&lt;br&gt;
tools, I've created a resilient, self-correcting defense mechanism that scales its&lt;br&gt;
sensitivity based on actual usage patterns.&lt;br&gt;
The code for this project is open-source and available on GitHub at &lt;a href="https://github.com/Adewumicrown/hng-anomaly-detector" rel="noopener noreferrer"&gt;https://github.com/Adewumicrown/hng-anomaly-detector&lt;/a&gt; for anyone looking to try it on their own&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>tutorial</category>
      <category>security</category>
      <category>buildinpublic</category>
    </item>
  </channel>
</rss>
