diff --git a/apps/pusher_app_prem/README.md b/apps/pusher_app_prem/README.md new file mode 100644 index 00000000..fe64ffbc --- /dev/null +++ b/apps/pusher_app_prem/README.md @@ -0,0 +1,532 @@ +# đ Git Pusher for Splunk + +**Version 2.0** | Application Splunk pour dĂ©ployer vos applications vers Git + +--- + +## đ Table des matiĂšres + +- [PrĂ©sentation](#-prĂ©sentation) +- [FonctionnalitĂ©s](#-fonctionnalitĂ©s) +- [Architecture](#-architecture) +- [Installation](#-installation) +- [Configuration](#-configuration) +- [SystĂšme de Licence](#-systĂšme-de-licence) +- [Utilisation](#-utilisation) +- [SĂ©curitĂ©](#-sĂ©curitĂ©) +- [DĂ©pannage](#-dĂ©pannage) +- [API Reference](#-api-reference) +- [Changelog](#-changelog) +- [Support](#-support) + +--- + +## đŻ PrĂ©sentation + +**Git Pusher** est une application Splunk Enterprise qui permet de versionner et dĂ©ployer vos applications Splunk vers un repository Git en quelques clics. + +IdĂ©al pour : +- đŠ Sauvegarder vos configurations Splunk +- đ Versionner vos dashboards et applications +- đ„ Collaborer en Ă©quipe sur les dĂ©veloppements Splunk +- đ Mettre en place un workflow CI/CD pour Splunk + +--- + +## âš FonctionnalitĂ©s + +| FonctionnalitĂ© | Description | +|----------------|-------------| +| **Push vers Git** | DĂ©ployez une ou plusieurs applications Splunk vers votre repository Git | +| **Interface moderne** | Dashboard intuitif avec sĂ©lection visuelle des applications | +| **Multi-repository** | Support de GitHub, GitLab, Gitea, Bitbucket et tout serveur Git | +| **SystĂšme de licence** | Gestion par fichier `.lic` sĂ©curisĂ© | +| **Credentials sĂ©curisĂ©s** | Chiffrement des mots de passe Splunk | +| **Logs dĂ©taillĂ©s** | TraçabilitĂ© complĂšte des opĂ©rations | + +--- + +## đ Architecture + +``` +pusher_app_prem/ +âââ bin/ +â âââ git_pusher.py # Serveur HTTP principal (port 9999) +â âââ license_validator.py # Validation des licences +â âââ license_generator.py # GĂ©nĂ©ration des licences (vendeur) +â âââ credentials_manager.py # Gestion sĂ©curisĂ©e des credentials +â âââ start_git_pusher.sh # Script de dĂ©marrage +âââ appserver/static/ +â âââ git_pusher.js # Logique JavaScript principale +â âââ license_validation.js # Interface de gestion des licences +âââ default/data/ui/views/ +â âââ git_pusher_-_deploy_applications.xml # Dashboard principal +âââ local/ +â âââ license.lic # Fichier de licence (aprĂšs activation) +â âââ .credentials # Credentials chiffrĂ©s +â âââ .key # ClĂ© de chiffrement +âââ README.md +``` + +### Flux de donnĂ©es + +``` +âââââââââââââââ ââââââââââââââââ âââââââââââââââ +â Splunk ââââââ¶â Git Pusher ââââââ¶â Git Repo â +â Dashboard â â Server:9999 â â (Remote) â +âââââââââââââââ ââââââââââââââââ âââââââââââââââ + â + ââââââââŽâââââââ + â /opt/splunk/etc/apps/ â + â (Applications locales) â + âââââââââââââââââââââââââââ +``` + +--- + +## đ„ Installation + +### PrĂ©requis + +- Splunk Enterprise 8.x ou supĂ©rieur +- Python 3.7+ +- Git installĂ© sur le serveur (`yum install git` ou `apt install git`) +- AccĂšs rĂ©seau vers votre repository Git + +### Ătapes d'installation + +#### 1. Extraire l'application + +```bash +# Copier l'application dans Splunk +cp -r pusher_app_prem /opt/splunk/etc/apps/ + +# DĂ©finir les permissions +chown -R splunk:splunk /opt/splunk/etc/apps/pusher_app_prem +chmod +x /opt/splunk/etc/apps/pusher_app_prem/bin/*.sh +``` + +#### 2. Configurer les credentials Splunk + +```bash +cd /opt/splunk/etc/apps/pusher_app_prem/bin/ +./start_git_pusher.sh credentials setup +``` + +``` +================================================== +Git Pusher - Credentials Setup +================================================== + +Splunk Username [admin]: admin +Splunk Password: ******** +Confirm Password: ******** + +â Credentials saved securely! +``` + +#### 3. DĂ©marrer le serveur Git Pusher + +```bash +./start_git_pusher.sh start +``` + +#### 4. Ouvrir le firewall (si nĂ©cessaire) + +```bash +# FirewallD +sudo firewall-cmd --add-port=9999/tcp --permanent +sudo firewall-cmd --reload + +# UFW +sudo ufw allow 9999/tcp +``` + +#### 5. RedĂ©marrer Splunk + +```bash +/opt/splunk/bin/splunk restart +``` + +#### 6. AccĂ©der au dashboard + +Ouvrez votre navigateur et allez sur : +``` +http://VOTRE_IP_SPLUNK:8000/app/pusher_app_prem/git_pusher_-_deploy_applications +``` + +--- + +## âïž Configuration + +### Commandes du script de gestion + +```bash +# DĂ©marrer le serveur +./start_git_pusher.sh start + +# ArrĂȘter le serveur +./start_git_pusher.sh stop + +# RedĂ©marrer le serveur +./start_git_pusher.sh restart + +# Voir le statut +./start_git_pusher.sh status + +# Voir les logs +./start_git_pusher.sh logs +./start_git_pusher.sh logs -f # Mode follow + +# Gestion des credentials +./start_git_pusher.sh credentials setup +./start_git_pusher.sh credentials status +./start_git_pusher.sh credentials delete +``` + +### Variables d'environnement (optionnel) + +Si vous prĂ©fĂ©rez ne pas utiliser le credentials manager : + +```bash +export SPLUNK_USERNAME=admin +export SPLUNK_PASSWORD=your_password +export SPLUNK_HOME=/opt/splunk +``` + +### Fichiers de configuration + +| Fichier | Description | +|---------|-------------| +| `local/license.lic` | Fichier de licence | +| `local/.credentials` | Credentials Splunk chiffrĂ©s | +| `local/.key` | ClĂ© de chiffrement (gĂ©nĂ©rĂ©e automatiquement) | + +--- + +## đ SystĂšme de Licence + +Git Pusher utilise un systĂšme de licence par fichier `.lic` pour activer les fonctionnalitĂ©s. + +### Types de licences + +| Type | DurĂ©e | Apps max | Pushes/jour | FonctionnalitĂ©s | +|------|-------|----------|-------------|-----------------| +| **Trial** | 14 jours | 3 | 5 | Push basique | +| **Starter** | 1 an | 10 | 50 | + Push programmĂ© | +| **Professional** | 1 an | IllimitĂ© | IllimitĂ© | + Multi-repo, Support prioritaire | +| **Enterprise** | 1 an | IllimitĂ© | IllimitĂ© | + Branding personnalisĂ©, API | + +### Obtenir une licence + +1. **RĂ©cupĂ©rer votre hostname Splunk** + - Visible dans le dashboard Git Pusher lors de l'activation + - Ou via la commande : `hostname` + +2. **Contacter le support** avec : + - Votre hostname Splunk + - Votre email + - Le type de licence souhaitĂ© + +3. **Recevoir votre fichier `.lic`** + +4. **Activer la licence** + - Ouvrir le dashboard Git Pusher + - Glisser-dĂ©poser le fichier `.lic` + - Cliquer sur "Activer" + +### Structure du fichier de licence + +``` +# ============================================= +# Git Pusher License File +# ============================================= +# Customer: Acme Corp +# Email: admin@acme.com +# Type: Professional +# Hostname: splunk-prod-01 +# Expires: 2026-01-30 +# License ID: A1B2C3D4E5F6 +# ============================================= +# DO NOT MODIFY THIS FILE +# ============================================= + +eyJsaWNlbnNlIjogey4uLn0sICJzaWduYXR1cmUiOiAiLi4uIn0= + +# ============================================= +# END OF LICENSE +# ============================================= +``` + +### GĂ©nĂ©ration de licences (Vendeur uniquement) + +```bash +# Mode interactif +python3 license_generator.py + +# Mode rapide +python3 license_generator.py quick "Client Name" "email@client.com" "hostname" "professional" + +# Valider une licence +python3 license_generator.py validate +``` + +--- + +## đ Utilisation + +### Pousser des applications vers Git + +1. **Ouvrir le dashboard** Git Pusher + +2. **Configurer Git** + - **Repository URL** : `https://github.com/user/repo.git` ou `https://gitlab.com/user/repo.git` + - **Branch** : `main`, `master`, ou votre branche + - **Token** : Personal Access Token avec droits `write` + +3. **SĂ©lectionner les applications** + - Cocher les applications Ă dĂ©ployer + - Utiliser "Select All" pour tout sĂ©lectionner + +4. **Ăcrire le message de commit** + - DĂ©crivez les changements effectuĂ©s + +5. **Cliquer sur "Deploy to Git"** + +### Obtenir un token Git + +#### GitHub +1. Settings â Developer settings â Personal access tokens â Tokens (classic) +2. Generate new token +3. Cocher : `repo` (Full control) + +#### GitLab +1. Preferences â Access Tokens +2. Create personal access token +3. Scopes : `write_repository` + +#### Gitea +1. Settings â Applications â Generate New Token +2. Permissions : `repository: write` + +--- + +## đ SĂ©curitĂ© + +### Credentials Splunk + +Les credentials Splunk sont : +- **ChiffrĂ©s** avec une clĂ© dĂ©rivĂ©e de l'ID machine +- **StockĂ©s** dans un fichier avec permissions `600` +- **Jamais visibles** en clair dans les logs ou scripts + +```bash +# Les credentials sont stockĂ©s ici (chiffrĂ©s) +/opt/splunk/etc/apps/pusher_app_prem/local/.credentials + +# La clĂ© de chiffrement (unique par machine) +/opt/splunk/etc/apps/pusher_app_prem/local/.key +``` + +### Token Git + +- Le token Git n'est **jamais stockĂ©** sur le serveur +- Il est transmis uniquement lors de l'opĂ©ration de push +- Option "Save credentials" stocke en localStorage du navigateur (encodĂ©) + +### Licence + +- Signature HMAC-SHA256 anti-falsification +- Binding au hostname Splunk +- VĂ©rification de l'expiration + +### Recommandations + +1. â Utiliser des tokens Git avec permissions minimales +2. â Renouveler les tokens rĂ©guliĂšrement +3. â Utiliser HTTPS pour les repositories Git +4. â Restreindre l'accĂšs au dashboard aux administrateurs + +--- + +## đ§ DĂ©pannage + +### Le serveur ne dĂ©marre pas + +```bash +# VĂ©rifier les logs +tail -f /opt/splunk/var/log/splunk/git_pusher.log + +# VĂ©rifier si le port est utilisĂ© +ss -tlnp | grep 9999 + +# VĂ©rifier les permissions +ls -la /opt/splunk/etc/apps/pusher_app_prem/bin/ +``` + +### Erreur "Connexion refusĂ©e" + +```bash +# VĂ©rifier que le serveur tourne +ps aux | grep git_pusher + +# VĂ©rifier le firewall +sudo firewall-cmd --list-ports + +# Ouvrir le port +sudo firewall-cmd --add-port=9999/tcp --permanent +sudo firewall-cmd --reload +``` + +### Erreur CORS + +Les fichiers JavaScript doivent utiliser l'adresse IP du serveur, pas `127.0.0.1`. + +VĂ©rifier : +```bash +head -10 /opt/splunk/etc/apps/pusher_app_prem/appserver/static/license_validation.js +``` + +Doit contenir : +```javascript +const LICENSE_API_URL = window.location.protocol + '//' + window.location.hostname + ':9999'; +``` + +### Les applications ne sont pas poussĂ©es + +```bash +# VĂ©rifier les logs +tail -50 /opt/splunk/var/log/splunk/git_pusher.log + +# Tester manuellement +curl -X POST "http://localhost:9999/health" +``` + +### Erreur de licence + +```bash +# VĂ©rifier le hostname +hostname + +# VĂ©rifier la licence +python3 /opt/splunk/etc/apps/pusher_app_prem/bin/license_validator.py status +``` + +### Vider le cache Splunk + +```bash +rm -rf /opt/splunk/var/run/splunk/appserver/* +/opt/splunk/bin/splunk restart +``` + +--- + +## đĄ API Reference + +### Endpoints + +| MĂ©thode | Endpoint | Description | +|---------|----------|-------------| +| `GET` | `/health` | Health check | +| `GET` | `/license` | Statut de la licence | +| `GET` | `/license/hostname` | Hostname Splunk | +| `POST` | `/license/upload` | Uploader une licence | +| `POST` | `/push` | Pousser les applications | + +### Exemple : Health Check + +```bash +curl http://localhost:9999/health +``` + +```json +{ + "status": "ok", + "service": "git_pusher", + "timestamp": "2026-01-31T12:00:00.000000" +} +``` + +### Exemple : Statut de licence + +```bash +curl http://localhost:9999/license +``` + +```json +{ + "status": "valid", + "hostname": "splunk-server", + "license": { + "license_id": "A1B2C3D4E5F6", + "type": "professional", + "type_name": "Professional", + "expires": "2027-01-30", + "days_remaining": 365 + } +} +``` + +### Exemple : Push + +```bash +curl -X POST "http://localhost:9999/push?git_url=https://github.com/user/repo.git&git_branch=main&git_token=TOKEN&commit_message=Update&apps=[{\"id\":\"my_app\"}]&user=admin" +``` + +```json +{ + "status": "success", + "message": "Successfully pushed 1 application(s) to Git", + "apps_pushed": 1, + "license_type": "Professional" +} +``` + +--- + +## đ Changelog + +### Version 2.0.0 (Janvier 2026) +- âš Nouveau systĂšme de licence par fichier `.lic` +- đ Credentials Splunk chiffrĂ©s +- đš Interface utilisateur modernisĂ©e +- đ Badge de licence en temps rĂ©el +- đ§ Script de gestion amĂ©liorĂ© +- đ Logs dĂ©taillĂ©s + +### Version 1.0.0 +- đ Version initiale +- Push d'applications vers Git +- Interface basique + +--- + +## đ Support + +### Obtenir de l'aide + +- đ§ Email : support@gitpusher.com +- đ Site web : https://gitpusher.com +- đ Documentation : https://docs.gitpusher.com + +### Signaler un bug + +Incluez dans votre rapport : +1. Version de Git Pusher +2. Version de Splunk +3. Logs (`/opt/splunk/var/log/splunk/git_pusher.log`) +4. Ătapes pour reproduire le problĂšme + +--- + +## đ Licence + +Git Pusher est un logiciel propriĂ©taire. Une licence valide est requise pour son utilisation. + +© 2026 Git Pusher - Tous droits rĂ©servĂ©s + +--- + +
+ Made with â€ïž for Splunk administrators +
diff --git a/apps/pusher_app_prem/local/usage_stats.json b/apps/pusher_app_prem/local/usage_stats.json index 7619f5e5..5eeeb672 100644 --- a/apps/pusher_app_prem/local/usage_stats.json +++ b/apps/pusher_app_prem/local/usage_stats.json @@ -1 +1 @@ -{"pushes_today": 1, "pushes_total": 10, "last_push_date": "2026-02-01", "apps_pushed": []} \ No newline at end of file +{"pushes_today": 2, "pushes_total": 11, "last_push_date": "2026-02-01", "apps_pushed": []} \ No newline at end of file