# Git : Divers



#### Trouver tous les repos:

```bash
find . -type d -exec [ -e '{}/.git' ] ';' -prune -print
```



#### Gitleaks

```bash
$ gitleaks detect -v

    ○
    │╲
    │ ○
    ○ ░
    ░    gitleaks

Finding:     APIKEY="P500SaGgEA79l6wktSbakYGPjXfvAkTw0PMXykzKkrxLp"
Secret:      P500SaGgEA79l6wktSbakYGPjXfvAkTw0PMXykzKkrxLp
RuleID:      generic-api-key
Entropy:     4.631305
File:        soco-cli-gui.sh
Line:        49
Commit:      8adf31b467bbe71d9a56b74761c40aeec5ceb171
Author:      JohnDoe
Email:       john@doe.com
Date:        2023-03-13T07:56:12Z
Fingerprint: 8adf31b467bbe71d9a56b74761c40aeec5ceb171:soco-cli-gui.sh:generic-api-key:49

Finding:     APIKEY="P500SaGgEA79l6wktSbakYGPjXfvAkTw0PMXykzKkrxLp"
Secret:      P500SaGgEA79l6wktSbakYGPjXfvAkTw0PMXykzKkrxLp
RuleID:      generic-api-key
Entropy:     4.631305
File:        soco-cli-gui.sh
Line:        1443
Commit:      bdc25bc0a3eb61663a6437621f0ac3b7c41701ee
Author:      JohnDoe
Email:       john@doe.com
Date:        2023-03-11T14:57:24Z
Fingerprint: bdc25bc0a3eb61663a6437621f0ac3b7c41701ee:soco-cli-gui.sh:generic-api-key:1443

Finding:     GITHUB_TOKEN=gdxfdo25vth9pvk3mev05s1z87y4t4s
Secret:      gdxfdo25vth9pvk3mev05s1z87y4t4s
RuleID:      generic-api-key
Entropy:     3.862815
File:        soco-cli-gui.sh
Line:        17
Commit:      e3fc8b675561b3d608e12a10cc1dd70241dcbc84
Author:      JohnDoe
Email:       john@doe.com
Date:        2021-01-16T11:04:35Z
Fingerprint: e3fc8b675561b3d608e12a10cc1dd70241dcbc84:soco-cli-gui.sh:generic-api-key:17

3:39PM INF 60 commits scanned.
3:39PM INF scan completed in 36.7ms
3:39PM WRN leaks found: 3
```



On indique les chaines à remplacer dans le fichier 'replace.txt':

```bash
~/Documents/Scripts/sonos main                                                                                                                            15:39:25
$ echo '13314ba0099450eaa6c0b2233d0f6adde1f5c718==>GITHUB_TOKEN' >> replace.txt
```

```bash
~/Documents/Scripts/sonos main*                                                                                                                           15:39:43
$ echo 'AIzaSyBtEqykacvWuWiLqq1-eIBZBrJzAYEx_xU==>GM_APIKEY' >> replace.txt
```



On initie le remplacement avec --force:

```bash
~/Documents/Scripts/sonos main*                                                                                                                           15:39:49
$ git filter-repo --replace-text replace.txt
Aborting: Refusing to destructively overwrite repo history since
this does not look like a fresh clone.
  (expected one remote, origin)
Please operate on a fresh clone instead.  If you want to proceed
anyway, use --force.
```

```bash
~/Documents/Scripts/sonos main*                                                                                                                           15:40:13
$ git filter-repo --replace-text replace.txt --force
Parsed 60 commits
New history written in 0.37 seconds; now repacking/cleaning...
Repacking your repo and cleaning out old unneeded objects
HEAD est maintenant à 0279b2d Rework alarms functions
Énumération des objets: 187, fait.
Décompte des objets: 100% (187/187), fait.
Compression par delta en utilisant jusqu'à 8 fils d'exécution
Compression des objets: 100% (111/111), fait.
Écriture des objets: 100% (187/187), fait.
Total 187 (delta 111), réutilisés 87 (delta 74), réutilisés du paquet 0 (depuis 0)
Completely finished after 0.83 seconds.
```

gitleaks ne détecte plus aucin leaks:

```bash
~/Documents/Scripts/sonos main*                                                                                                                           15:40:22
$ gitleaks detect -v

    ○
    │╲
    │ ○
    ○ ░
    ░    gitleaks

3:40PM INF 60 commits scanned.
3:40PM INF scan completed in 29.8ms
3:40PM INF no leaks found
```

On pousse avec --force vers les remotes

```bash
~/Documents/Scripts/sonos main*                                                                                                                           15:51:51
$ git push dsm923 main --force
Énumération des objets: 186, fait.
Décompte des objets: 100% (186/186), fait.
Compression par delta en utilisant jusqu'à 8 fils d'exécution
Compression des objets: 100% (73/73), fait.
Écriture des objets: 100% (186/186), 150.65 Kio | 75.32 Mio/s, fait.
Total 186 (delta 111), réutilisés 186 (delta 111), réutilisés du paquet 0 (depuis 0)
remote: Resolving deltas: 100% (111/111), done.
To dsm923e:/volume1/Repositories/repos/sonos.git
 + 56bbfb1...0279b2d main -> main (forced update)
```

