Skip to content

Commit 010eda1

Browse files
committed
Release v0.9.0 - AI-powered HTTP attack detection for Rails
Features: - Model2Vec embeddings via ONNX Runtime (~2ms inference) - 8 attack types: SQLi, XSS, path traversal, command injection, credential stuffing, spam bots, scanners - Rails middleware and controller concern integration - Auto-download model from HuggingFace (khasinski/ai-bouncer) - Optional PostgreSQL + pgvector storage via neighbor gem - 92%+ accuracy on 3,053 pattern test set Includes: - Configurable actions: :block, :log, :challenge - Generators for initializer and migration - Rake tasks for download, seed, stats, test, benchmark
0 parents  commit 010eda1

27 files changed

+2551
-0
lines changed

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Bundler
2+
Gemfile.lock
3+
4+
# RSpec
5+
spec/examples.txt
6+
7+
# Model data (downloaded from HuggingFace)
8+
data/*.onnx
9+
data/*.bin
10+
data/*.json
11+
!data/README.md
12+
13+
# Gem build artifacts
14+
*.gem
15+
pkg/
16+
17+
# IDE
18+
.idea/
19+
.vscode/
20+
*.swp
21+
*.swo
22+
23+
# macOS
24+
.DS_Store

CHANGELOG.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.9.0] - 2025-01-17
9+
10+
### Added
11+
12+
- **Core Classification Engine**
13+
- Model2Vec-based text embeddings via ONNX Runtime
14+
- KNN classifier with cosine similarity for attack detection
15+
- Support for 8 attack types: SQLi, XSS, path traversal, command injection, credential stuffing, spam bots, scanners, and clean traffic
16+
17+
- **Rails Integration**
18+
- Rack middleware for automatic request classification
19+
- Controller concern with `protect_from_attacks` DSL
20+
- Configurable actions: `:block`, `:log`, `:challenge`
21+
- Callbacks for attack detection and monitoring
22+
23+
- **Storage Options**
24+
- In-memory mode (default): ~2ms latency, ~30MB RAM
25+
- Database mode: PostgreSQL + pgvector via neighbor gem
26+
27+
- **Auto-Download**
28+
- Model files automatically downloaded from HuggingFace on first use
29+
- Hosted at [huggingface.co/khasinski/ai-bouncer](https://huggingface.co/khasinski/ai-bouncer)
30+
31+
- **Generators**
32+
- `rails generate ai_bouncer:install` - Creates initializer
33+
- `rails generate ai_bouncer:migration` - Creates pgvector migration
34+
35+
- **Rake Tasks**
36+
- `ai_bouncer:download` - Download model files
37+
- `ai_bouncer:seed` - Seed database with attack patterns
38+
- `ai_bouncer:stats` - Show pattern statistics
39+
- `ai_bouncer:test` - Test classification
40+
- `ai_bouncer:benchmark` - Benchmark performance
41+
42+
### Model
43+
44+
- 3,053 attack pattern vectors
45+
- Trained on SecLists, CSIC 2010, ModSecurity CRS, and real nginx logs
46+
- 92%+ accuracy on test set
47+
48+
## [Unreleased]
49+
50+
### Planned
51+
52+
- Rate limiting integration
53+
- IP reputation scoring
54+
- Custom pattern training interface
55+
- Prometheus metrics export

Gemfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
gemspec
6+
7+
gem "rake", "~> 13.0"
8+
gem "rspec", "~> 3.0"
9+
gem "rubocop", "~> 1.0"

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2025 Chris Hasinski
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

0 commit comments

Comments
 (0)