# 🚀 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) - [Configuration HTTPS](#-configuration-https) - [SystĂšme de Licence](#-systĂšme-de-licence) - [Utilisation](#-utilisation) - [SĂ©curitĂ©](#-sĂ©curitĂ©) - [Personnalisation du Dashboard](#-personnalisation-du-dashboard) - [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 | | **Support HTTPS** | Communication sĂ©curisĂ©e avec certificats SSL | | **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/HTTPS 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 │ └── certs/ # Certificats SSL │ ├── server.crt │ └── server.key └── README.md ``` ### Flux de donnĂ©es ``` ┌─────────────────┐ ┌────────────────────┐ ┌─────────────┐ │ Splunk │────▶│ Git Pusher │────▶│ Git Repo │ │ Dashboard │ │ Server:9999 │ │ (Remote) │ │ (HTTPS) │ │ (HTTP/HTTPS) │ │ │ └─────────────────┘ └────────────────────┘ └─────────────┘ │ ┌──────┮──────┐ │ /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`) - OpenSSL (pour la gĂ©nĂ©ration des certificats HTTPS) - 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. Configurer HTTPS (si Splunk est en HTTPS) Voir la section [Configuration HTTPS](#-configuration-https). #### 4. DĂ©marrer le serveur Git Pusher ```bash ./start_git_pusher.sh start ``` #### 5. 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 ``` #### 6. RedĂ©marrer Splunk ```bash /opt/splunk/bin/splunk restart ``` #### 7. AccĂ©der au dashboard Ouvrez votre navigateur et allez sur : ``` http://VOTRE_IP_SPLUNK:8000/app/pusher_app_prem/git_pusher_-_deploy_applications ``` Ou en HTTPS : ``` https://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) | | `local/certs/server.crt` | Certificat SSL | | `local/certs/server.key` | ClĂ© privĂ©e SSL | --- ## 🔒 Configuration HTTPS Si votre Splunk est configurĂ© en HTTPS, le serveur Git Pusher doit Ă©galement ĂȘtre en HTTPS pour Ă©viter les erreurs "Mixed Content" du navigateur. ### 1. GĂ©nĂ©rer les certificats SSL ```bash # CrĂ©er le dossier des certificats mkdir -p /opt/splunk/etc/apps/pusher_app_prem/local/certs # GĂ©nĂ©rer un certificat auto-signĂ© (valide 365 jours) openssl req -x509 -newkey rsa:4096 \ -keyout /opt/splunk/etc/apps/pusher_app_prem/local/certs/server.key \ -out /opt/splunk/etc/apps/pusher_app_prem/local/certs/server.crt \ -days 365 -nodes -subj "/CN=git-pusher" # DĂ©finir les permissions chmod 600 /opt/splunk/etc/apps/pusher_app_prem/local/certs/server.key chown -R splunk:splunk /opt/splunk/etc/apps/pusher_app_prem/local/certs/ ``` ### 2. RedĂ©marrer le serveur ```bash ./start_git_pusher.sh restart ``` ### 3. VĂ©rifier que HTTPS fonctionne ```bash curl -k https://127.0.0.1:9999/health ``` Vous devriez voir : ```json {"status": "ok", "service": "git_pusher", "timestamp": "..."} ``` ### 4. Accepter le certificat dans le navigateur Comme le certificat est auto-signĂ©, le navigateur ne lui fait pas confiance par dĂ©faut. 1. Ouvrez un nouvel onglet 2. Allez sur : `https://VOTRE_IP_SPLUNK:9999/health` 3. Cliquez sur **"AvancĂ©"** puis **"Accepter le risque et continuer"** 4. Retournez sur le dashboard Splunk et rafraĂźchissez (Ctrl+Shift+R) ### 5. (Optionnel) DĂ©sactiver HTTPS Si vous souhaitez forcer le mode HTTP : ```bash cd /opt/splunk/etc/apps/pusher_app_prem/bin/ python3 git_pusher.py --no-ssl ``` ### VĂ©rification dans les logs ```bash tail -20 /opt/splunk/var/log/splunk/git_pusher.log ``` Vous devriez voir : ``` SSL enabled using: /opt/splunk/etc/apps/pusher_app_prem/local/certs/server.crt Git Pusher server listening on 0.0.0.0:9999 (HTTPS) ``` --- ## 🔐 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 ``` ### Communication HTTPS - Le serveur Git Pusher supporte HTTPS avec certificats SSL - Les certificats auto-signĂ©s sont supportĂ©s - Communication chiffrĂ©e entre le navigateur et le serveur ### 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 HTTPS pour Splunk et Git Pusher 2. ✅ Utiliser des tokens Git avec permissions minimales 3. ✅ Renouveler les tokens rĂ©guliĂšrement 4. ✅ Utiliser HTTPS pour les repositories Git 5. ✅ Restreindre l'accĂšs au dashboard aux administrateurs --- ## 🎹 Personnalisation du Dashboard ### Masquer les boutons d'Ă©dition Pour empĂȘcher la modification du dashboard par les utilisateurs, Ă©ditez le fichier XML : ```bash nano /opt/splunk/etc/apps/pusher_app_prem/default/data/ui/views/git_pusher_-_deploy_applications.xml ``` Modifiez la premiĂšre ligne : ```xml ``` ### Options disponibles | Attribut | Description | |----------|-------------| | `hideEdit="true"` | Masque le bouton "Modifier" | | `hideExport="true"` | Masque le bouton "Exporter" | | `hideTitle="true"` | Masque le titre du dashboard | | `hideSplunkBar="true"` | Masque la barre Splunk en haut | | `hideAppBar="true"` | Masque la barre de l'application | | `hideFooter="true"` | Masque le footer | ### Appliquer les changements ```bash rm -rf /opt/splunk/var/run/splunk/appserver/* /opt/splunk/bin/splunk restart ``` --- ## 🔧 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 automatiquement. 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'; ``` ### Erreur CORS avec HTTPS Si vous voyez une erreur CORS avec HTTPS et un certificat auto-signĂ© : 1. Ouvrez `https://VOTRE_IP:9999/health` dans un nouvel onglet 2. Acceptez le certificat 3. Retournez sur Splunk et rafraĂźchissez ### Erreur SSL "wrong version number" Le serveur n'a pas activĂ© SSL. VĂ©rifiez : ```bash # Les certificats existent-ils ? ls -la /opt/splunk/etc/apps/pusher_app_prem/local/certs/ # Les logs montrent-ils SSL enabled ? grep -i ssl /opt/splunk/var/log/splunk/git_pusher.log ``` Si les certificats n'existent pas, crĂ©ez-les (voir section HTTPS). ### 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 -k https://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 ``` ### Les boutons ne fonctionnent pas VĂ©rifiez la console du navigateur (F12). Si les fonctions ne sont pas dĂ©finies, videz le cache : ```bash rm -rf /opt/splunk/var/run/splunk/appserver/* /opt/splunk/bin/splunk restart ``` Puis dans le navigateur : **Ctrl+Shift+R** ### 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 -k https://localhost:9999/health ``` ```json { "status": "ok", "service": "git_pusher", "timestamp": "2026-01-31T12:00:00.000000" } ``` ### Exemple : Statut de licence ```bash curl -k https://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 -k -X POST "https://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 (FĂ©vrier 2026) - ✹ Nouveau systĂšme de licence par fichier `.lic` - 🔐 Credentials Splunk chiffrĂ©s - 🔒 Support HTTPS avec certificats SSL - 🎹 Interface utilisateur modernisĂ©e - 📊 Badge de licence en temps rĂ©el - 🔧 Script de gestion amĂ©liorĂ© - đŸ›Ąïž Options pour masquer les boutons d'Ă©dition du dashboard - 📝 Logs dĂ©taillĂ©s - 🐛 Correction des problĂšmes CORS ### 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. Configuration (HTTP/HTTPS) 4. Logs (`/opt/splunk/var/log/splunk/git_pusher.log`) 5. Erreurs de la console navigateur (F12) 6. É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