Accepts incoming events and correctly parses them into events. GeoLite2 integration complete"

This commit is contained in:
Dan Milne
2025-11-04 00:11:10 +11:00
parent 0cbd462e7c
commit 5ff166613e
49 changed files with 4489 additions and 322 deletions

View File

@@ -0,0 +1,31 @@
# frozen_string_literal: true
require 'fileutils'
# MaxMind GeoIP Configuration
Rails.application.configure do
config.maxmind = ActiveSupport::OrderedOptions.new
# Database configuration
config.maxmind.database_url = ENV.fetch('MAXMIND_DATABASE_URL', 'https://github.com/P3TERX/GeoLite.mmdb/raw/download/GeoLite2-Country.mmdb')
config.maxmind.database_type = 'GeoLite2-Country'
# Local storage paths
config.maxmind.storage_path = Rails.root.join('db', 'geoip')
config.maxmind.database_filename = 'GeoLite2-Country.mmdb'
# Update configuration
config.maxmind.auto_update_enabled = ENV.fetch('MAXMIND_AUTO_UPDATE', 'true').downcase == 'true'
config.maxmind.update_interval_days = ENV.fetch('MAXMIND_UPDATE_INTERVAL_DAYS', 7).to_i
config.maxmind.max_age_days = ENV.fetch('MAXMIND_MAX_AGE_DAYS', 30).to_i
# Note: MaxMind DB has its own internal caching, no additional caching needed
# Fallback settings
config.maxmind.fallback_country = ENV.fetch('MAXMIND_FALLBACK_COUNTRY', nil)
config.maxmind.enable_fallback = ENV.fetch('MAXMIND_ENABLE_FALLBACK', 'false').downcase == 'true'
end
# Ensure storage directory exists
maxmind_storage_path = Rails.application.config.maxmind.storage_path
FileUtils.mkdir_p(maxmind_storage_path) unless Dir.exist?(maxmind_storage_path)

View File

@@ -5,9 +5,14 @@ Rails.application.routes.draw do
# Can be used by load balancers and uptime monitors to verify that the app is live.
get "up" => "rails/health#show", as: :rails_health_check
# WAF Event Ingestion API
# WAF API
namespace :api, defaults: { format: :json } do
# Event ingestion
post ":project_id/events", to: "events#create"
# Rule synchronization
get ":public_key/rules/version", to: "rules#version"
get ":public_key/rules", to: "rules#index"
end
# Root path - projects dashboard