Skip to content

qc824676623/GitGuard-Analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IPGeoAnalyzer for GitLab / IPGeoAnalyzer for GitLab

Version Python License

A specialized IP geographic threat analysis tool built for GitLab, based on nginx log analysis, providing global access source visualization.

专为GitLab构建的IP地理威胁分析工具,基于gitlab内置的nginx日志分析,提供全球异常访问来源可视化。

🌐 Languages / 语言选择

English

📦 Deployment Guide

  • Run as a Docker container without local environment setup
  • Deploy from source code

🐳 Using Docker Image (Recommended)

We've packaged the tool as a Docker image and pushed it to Alibaba Cloud Container Registry. You can directly pull and run it:

Pull the Image

docker pull registry.cn-hangzhou.aliyuncs.com/qc123mjs/gitguard-analyzer:latest

Run the Container

docker run -d -p 5000:5000 -v /var/log/gitlab/nginx:/var/log/gitlab/nginx --name gitguard-analyzer gitguard-analyzer

-p [Host Port]:[Container Port 5000] -v [Host Directory]:[Container Directory /var/log/gitlab/nginx]

🛠️ Local Development (Optional)

If you want to build the Docker image yourself:

cd /GitGuard-Analyzer
docker build -t gitguard-analyzer .

Project Structure

ipanalyzer/
├── nginx_ip_geo_stats.py# Main application file
├── map/# Map data directory
│  ├── dbip_geo.txt# Geographic text data
│  ├── dbip_index.bin# Binary index (need to unzip due to upload limits)
│  └── dbip_tobin.py# Data conversion tool
├── dbip-city-lite-2025-09.csv # IP database (too large, download when needed)
└── gitlab_error.log# Error log (for testing)

Configuration

LOG_DIR = "/var/log/gitlab/nginx/"# Nginx log directory
BIN_INDEX_PATH = "map/dbip_index.bin" # Binary index path
GEO_TEXT_PATH = "map/dbip_geo.txt"# Geographic text path

🚀 Core Features

Feature Status Description
🌍 IP Geographic Distribution Global access source visualization
📊 Real-time Log Analysis Support .gz compressed logs
🗺️ Interactive Map Folium heatmap
⏰ Multiple Time Granularities Day/Week/Month analysis
🇨🇳 Chinese Support Complete Chinese font support

🔍 How It Works

Data Processing Flow

  • Log Parsing: Read GitLab's built-in nginx logs including gitlab_error.log and gitlab_error.log.*.gz, extract IP, timestamp, URL using regex
  • IP Geolocation: Convert IP to integer format, binary search to match IP ranges
  • Data Statistics: Multi-dimensional access frequency statistics, time aggregation analysis
  • Visualization: Matplotlib charts + Folium interactive maps

Core Technologies

  • IP conversion algorithm: IPv4 to 32-bit integer for fast lookup
  • Binary search optimization: O(log n) efficient IP matching
  • Multi-threaded processing: Concurrent log file processing
  • Memory mapping: Binary indexing reduces memory usage

📋 Usage Instructions

  1. Install Dependencies:
pip install -r requirements.txt
  1. Prepare Data [Execute only when updating map information]:
python3 map/dbip_tobin.py
  1. Start Application:
python3 nginx_ip_geo_stats.py
  1. Access Interface: http://localhost:5000

✨ Project Features

  • 🚀 Single-file core application
  • 📊 Rich data visualization
  • 🔧 Cross-platform support
  • 📈 Production environment ready
  • ⚡ High-performance processing

📁 Data Files

dbip-city-lite-2025-09.csv

Source: DB-IP free geographic database Format: Start IP|End IP|Country Code|Country|Region|City|Latitude|Longitude Update: Monthly download from https://db-ip.com

dbip_tobin.py

Function: CSV to binary index conversion

  • IP range indexing: 12 bytes/record (start IP + end IP + location offset)
  • Location deduplication: Reduces storage space
  • Performance improvement: 10-100x faster than CSV queries

🖼️ Interface Preview

Dashboard Interface Figure 1: System Dashboard Interface

Dashboard Figure 2: URL Access Frequency Statistics

Time Distribution Figure 3: Time Distribution Chart

Access Statistics Detailed Analysis Real-time Monitoring Figure 4: Detailed Analysis Page

Python Version Requirements

This project recommends using Python 3.6+ version

Dependencies List

numpy==1.26.4
Flask==2.3.3
folium==0.20.0
matplotlib==3.9.2
pandas==2.2.2
seaborn==0.13.2
gevent==23.9.1
gunicorn==21.2.0
Jinja2==3.1.2 

📄 License

This project is licensed under the GNU General Public License v3.0.

Key Terms:

  • ✅ Free use, modification, and distribution allowed
  • ✅ Derivative works must be open source
  • ✅ Copyright notices must be preserved
  • ✅ Same license must be adopted
  • 📝 Changes must be clearly documented

Complete license content please see LICENSE file


📞 Issue Reporting | ✨ Feature Requests | 🐛 Bug Reports

© 2025 IPGeoAnalyzer Project Team. GPL-3.0 License.


About

Customized IP Geographic Threat Analysis Tool for GitLab Built in nginx

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published