Skip to content

Conversation

f0ssel
Copy link
Collaborator

@f0ssel f0ssel commented Sep 9, 2025

Changes

  • Add comprehensive audit package with Request struct and LoggingAuditor implementation
  • Split main.go logic into modular cli package for better organization
  • Remove Action type from rules package, simplify to boolean allow/deny logic
  • Restructure audit package into separate files (request.go, logging_auditor.go)
  • Remove Request.Reason field to simplify audit API
  • Add extensive test coverage with buffer-based logging verification
  • Update proxy to use concrete LoggingAuditor type instead of interface
  • Add ReasonNoMatchingRules constant and comprehensive edge case testing
  • Move LoggingAuditor tests to dedicated test file for better organization
  • Implement HTTPRequestToAuditRequest conversion function
  • Clean separation of concerns between rules evaluation and audit logging

🤖 Generated with Claude Code

f0ssel and others added 2 commits September 9, 2025 13:46
- Create audit.Auditor interface for pluggable audit implementations
- Add audit.LoggingAuditor that logs to slog (replaces rules engine logging)
- Integrate auditor into proxy request handling pipeline
- Update rules engine with EvaluateWithRule() to return rule details
- Remove logging responsibility from rules engine (separation of concerns)
- Add comprehensive tests for audit package

All HTTP requests (allow/deny) now go through consistent audit pipeline

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Remove Action enum (Allow/Deny) from rules package
- Update rules engine to return bool instead of Action
- Update EvaluationResult to use Allowed bool field
- Update audit package to use boolean logic instead of Action
- Update proxy to use boolean conditions (!result.Allowed)
- Update all tests to use true/false instead of Allow/Deny
- Remove unnecessary dependencies between packages

Simplifies codebase by using intuitive boolean logic throughout

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@f0ssel f0ssel requested a review from bcpeinhardt September 9, 2025 17:54
f0ssel and others added 5 commits September 9, 2025 14:21
… common reason

- Replace test logger that discarded output with buffer-based approach for proper verification
- Add ReasonNoMatchingRules constant to avoid string duplication
- Enhance tests to verify log levels and content fields
- Tests now actually validate that audit logging works correctly

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Move all CLI logic from main.go into new cli package for better modularity
- main.go is now extremely slim (18 lines), only importing and calling cli package
- Add comprehensive audit package test coverage:
  - Edge cases (empty fields, special characters, long URLs, custom reasons)
  - Different log levels and filtering behavior
  - Nil logger/request handling with graceful panic testing
  - Enhanced HTTPRequestToAuditRequest tests for all HTTP methods
  - Interface compliance, JSON/text handlers, and discard handler testing
  - 11 test functions with 24 sub-tests providing thorough coverage

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Split audit.go into separate files:
  - request.go: Request struct and HTTPRequestToAuditRequest function
  - logging_auditor.go: LoggingAuditor implementation and Auditor interface
- Move LoggingAuditor tests to logging_auditor_test.go
- Keep general audit tests (HTTPRequestToAuditRequest) in request_test.go
- Remove Request.Reason field and ReasonNoMatchingRules constant
- Update proxy to use concrete LoggingAuditor type instead of interface
- Simplify audit logging by removing reason parameter from DENY logs
- All tests pass with improved organization and cleaner API

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Remove the nil request test case that was testing edge case behavior
- Keep the main HTTPRequestToAuditRequest test function with 8 test cases
- Cleaner test file focusing on valid request conversion scenarios

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Rename RuleEngine.EvaluateWithRule() to Evaluate() for simpler API
- Remove old boolean-only Evaluate() method
- Update proxy.go to use renamed Evaluate() method
- Fix rules tests to work with EvaluationResult struct
- Clean up formatting and remove extra blank lines
- All tests pass with unified evaluation method

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@f0ssel f0ssel requested a review from bcpeinhardt September 9, 2025 19:05
}()

// Give proxy time to start
time.Sleep(100 * time.Millisecond)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still weak at this

@f0ssel f0ssel merged commit 31f1722 into blink/httpjail-go-implementation Sep 9, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants