Skip to content

Exercise A - Firewall Rule Optimizer

Exercise Metadata

FieldValue
Duration~25 minutes
TypeWorkflow Agent
FocusPrompt engineering + Knowledge Stores

Scenario

Your network security team exports firewall rule reports periodically. These reports contain hundreds of rules accumulated over years, many of which are outdated, overly permissive, or redundant. Manual review is time-consuming and error-prone.

Objective

Build a Kindo Workflow Agent that ingests a firewall rule report, analyzes each rule against security best practices, and produces a structured cleanup report.

Output Categories

CategoryMeaningExample Indicators
RISKYSignificant security exposureany-to-any rules, inbound to sensitive ports
OVER-PERMISSIVEBroader than necessaryallow all ports, overly broad ranges
UNUSEDZero or negligible hit counts0 hits over 90+ days
REDUNDANTCovered by another ruletraffic fully covered by higher-priority rule
COMPLIANTCorrectly scoped and actively usedspecific source/dest, appropriate ports, healthy hit count

Prerequisites

About the Sample Data

The sample firewall rule report contains 40 rules representing a realistic corporate firewall accumulated over several years. The rules include a deliberate mix of:

  • Clean rules that are correctly scoped and actively used (web server access, monitoring, security tooling)
  • Risky rules with direct internet exposure to sensitive services (SSH, RDP, MySQL open to any)
  • Over-permissive rules with overly broad scope (any-to-any permits, full internal subnet access)
  • Unused rules with zero hit counts from decommissioned projects, expired contracts, or completed engagements
  • Redundant rules whose traffic is already covered by broader rules at higher priority

As you iterate through the prompt engineering steps below, notice how your output quality changes — not just in formatting, but in whether the agent catches subtle issues like dev-to-prod database access or guest WiFi misconfigurations.

Step 1 - Create the Agent (3 min)

  1. Open Agents in the left sidebar.
  2. Click Create an Agent.
  3. Select Workflow Agent.
  4. Configure:
    • Name: Firewall Rule Optimizer
    • Description: Analyzes firewall rule reports and categorizes rules for cleanup.

Step 2 - Set Up the Knowledge Store (3 min)

  1. In the Agent Configuration panel, click Add Knowledge Store.
  2. Upload the sample firewall rule report (sample-firewall-rules.txt).

Step 3 - Build the Analysis Prompt Iteratively (12 min)

This is the core teaching moment of the exercise. Instead of pasting a final prompt immediately, you will build it in three iterations and compare how each change affects output quality.

  1. Click + to add a step and choose LLM Step.
  2. Name the step: Analyze and Categorize Rules.
  3. Use each iteration below, run it, and compare outputs.

Iteration 1 - Start Simple

Analyze the firewall rules in the knowledge store and identify which ones are risky or should be cleaned up.

Iteration 2 - Add Role and Structure

You are a senior network security engineer performing a firewall rule audit.
Analyze the firewall rule report in the knowledge store. For each rule, categorize it into exactly ONE of:
1. RISKY - Significant security exposure (e.g., any-to-any rules, inbound to sensitive ports)
2. OVER-PERMISSIVE - Broader than necessary
3. UNUSED - Zero or near-zero hit counts
4. REDUNDANT - Already covered by another rule
5. COMPLIANT - Correctly scoped, actively used, follows best practices
Output as a table with columns: Rule ID | Rule Name | Category | Recommendation

Iteration 3 - Production Prompt

You are a senior network security engineer performing a firewall rule audit.
TASK:
Analyze the firewall rule report in the knowledge store. For each rule, categorize it into exactly ONE of the following:
1. RISKY - Rules that create significant security exposure (e.g., any-to-any rules, inbound access to sensitive ports from untrusted sources, rules allowing dangerous protocols)
2. OVER-PERMISSIVE - Rules broader than necessary (e.g., allow all ports when specific ports would suffice, overly broad source/destination ranges)
3. UNUSED - Rules with zero or negligible hit counts during the analysis period (0 hits over 90+ days = unused; <10 hits over 90 days = near-unused)
4. REDUNDANT - Rules whose traffic is already fully covered by another rule with equal or higher priority
5. COMPLIANT - Rules that are correctly scoped, actively used, and follow security best practices (specific source/destination, appropriate ports, healthy hit counts)
ANALYSIS GUIDELINES:
- Consider source, destination, service/port, action (permit/deny), and hit count
- For RISKY: any rule allowing inbound traffic from "any" to critical infrastructure ports (22, 3389, 1433, 3306, 5432) should be flagged
- For OVER-PERMISSIVE: compare against the principle of least privilege
- If a rule could belong to multiple categories, choose the highest-risk category
OUTPUT FORMAT:
| Rule ID | Rule Name | Category | Confidence | Risk Level | Recommendation |
CONFIDENCE LEVELS:
- HIGH - Clear indicators support the categorization
- MEDIUM - Some ambiguity but categorization is likely correct
- LOW - Insufficient data; manual review recommended
After the table, provide:
1. Summary count of rules per category
2. Top 5 highest-priority rules to remediate immediately
3. Recommended next steps

Step 4 - Add the Report Formatting Step (5 min)

Add a second LLM step named Format Cleanup Report.

You are formatting the firewall rule analysis into an executive-ready cleanup report.
Take the categorized rule analysis from the previous step and produce:
SECTION 1 - EXECUTIVE SUMMARY
- Total rules analyzed, breakdown by category (count and percentage)
- Overall risk assessment (Critical / High / Medium / Low)
- Estimated effort to remediate
SECTION 2 - IMMEDIATE ACTION ITEMS
Top 10 highest-priority rules, sorted by risk:
- Rule ID and name
- Why it's flagged
- Recommended action (remove, tighten, merge, review)
- Estimated impact if left unaddressed
SECTION 3 - CATEGORY DETAIL
For each category, list all rules sorted by confidence level (HIGH first).
SECTION 4 - RECOMMENDATIONS
- Quick wins (high confidence, low effort)
- Rules requiring manual review (low confidence)
- Suggested review cadence going forward
- Integration recommendations (e.g., connect to CrowdStrike for threat-informed prioritization)
Keep the tone professional and direct. This report goes to the security operations manager.

Step 5 - Run and Review (5 min)

  1. Click Generate or Run.
  2. Validate output quality using the checklist below.
  3. Re-run with one prompt tweak and compare.

Quality Checklist

  • Categorization accuracy: categories align with the underlying rule evidence (e.g., FW-019 MySQL from any should be RISKY, not just OVER-PERMISSIVE)
  • Confidence calibration: HIGH items are clearly supported, LOW items are truly ambiguous
  • Executive utility: summary is actionable without reading every row
  • Recommendation specificity: concrete next actions instead of generic language like “review this rule”
  • Completeness: all 40 rules are accounted for — none silently skipped

Iterations to Try

  • Lower the UNUSED threshold and compare volume shifts
  • Add a new category such as EXPIRED for rules past a decommission date
  • Request output as JSON or CSV instead of markdown table
  • Upload a second file (a network security policy document) to the Knowledge Store and see if the agent references it during analysis

What You Learned

ConceptWhere You Used It
Knowledge StoresUploaded the firewall CSV as a reference for analysis
Prompt engineeringIterated from vague to production-quality through three versions
Role specificationSet the model’s expertise level and vocabulary
Output structuringControlled format with explicit tables, categories, and sections
Confidence levelsAdded calibration signals for downstream triage
Multi-step workflowsSeparated analysis from formatting for reusability

Discussion Points

  • Which prompt iteration had the biggest impact on output quality, and why?
  • What additional guardrails are needed before using this in production?
  • Where could you connect ticketing or trigger automation to close the loop (e.g., auto-create a Jira ticket for each RISKY rule)?
  • How would you adapt this pattern for a different security domain — vulnerability scan results, IAM policy reviews, or cloud security posture?

Troubleshooting

IssueLikely CauseHow To Fix
Output is vague and inconsistentPrompt lacks role, constraints, and schemaMove from Iteration 1 to Iteration 3 prompt structure
Most rules marked as RISKYCategories are underspecified or rule data is sparseAdd explicit category definitions and confidence rules
Missing rules in outputModel hit context limits or skipped rowsAsk for chunked analysis (for example, 100 rules at a time) and merge results
Confidence levels all HIGHPrompt does not define evidence standardsKeep the explicit HIGH/MEDIUM/LOW criteria block
Recommendations are genericFormatting step not includedAdd Step 4 report formatter and require prioritized actions

Next Exercise

Continue to Exercise B - Universal Security Triage Agent.