Skip to content

ngctnnnn/conditional_firewall

Repository files navigation

Firewall Layer

Modular firewall system for monitoring and blocking network/LLM requests.

Installation

pip install -e .

Or install from the parent project:

pip install -e ../firewall_layer

Structure

  • logger.py - Logging setup
  • rules.py - Firewall rules (block POST, allow localhost, etc.)
  • observer.py - Request/LLM observation handlers
  • firewall.py - Main firewall context manager
  • __init__.py - Public API

Usage

Basic Usage

from firewall_layer import observe_extract_content

with observe_extract_content() as observations:
    # Your code here
    result = some_function()
    # observations contains all network/LLM activity

Custom Firewall Rules

from firewall_layer import Firewall
from firewall_layer.rules import BlockPostRule, AllowLocalhostRule, FirewallRules

# Create custom rules
rules = FirewallRules([
    BlockPostRule(),  # Block all POST
    AllowLocalhostRule(),  # Allow localhost (overrides block)
])

with Firewall(rules=rules) as firewall:
    # Your code
    pass

Available Rules

  • BlockPostRule() - Blocks all POST requests
  • AllowLocalhostRule() - Allows requests to localhost
  • BlockDomainRule(domains=['example.com']) - Blocks specific domains

Features

  • Monitors requests library calls
  • Monitors aiohttp calls (async)
  • Monitors LLM invoke calls
  • Blocks requests based on rules
  • Logs all activity to file
  • Modular and extensible

About

Firewall for VLM application from eavesdropping

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages