Skip to content

NimTechnology

Trình bày các công nghệ CLOUD một cách dễ hiểu.

  • Kubernetes & Container
    • Docker
    • Kubernetes
      • Ingress
      • Pod
    • Helm Chart
    • OAuth2 Proxy
    • Isito-EnvoyFilter
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Vault
    • Longhorn – Storage
    • VictoriaMetrics
    • MetalLB
    • Kong Gateway
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Argo Events
    • Spinnaker
    • Jenkins
    • Harbor
    • TeamCity
    • Git
      • Bitbucket
  • Coding
    • DevSecOps
    • Terraform
      • GCP – Google Cloud
      • AWS – Amazon Web Service
      • Azure Cloud
    • Golang
    • Laravel
    • Python
    • Jquery & JavaScript
    • Selenium
  • Log, Monitor & Tracing
    • DataDog
    • Prometheus
    • Grafana
    • ELK
      • Kibana
      • Logstash
  • BareMetal
    • NextCloud
  • Toggle search form

[DevSecOps] Remove the secrets on Git.

Posted on June 18, 2023June 18, 2023 By nim No Comments on [DevSecOps] Remove the secrets on Git.

Contents

Toggle
  • 1) Look into the circumstance!
  • 2) Clear All secrets at anywhere.
    • 2.1) Using BFG Repo-Cleaner to clear all secret
      • 2.1.1) Delete files that contain secrets

1) Look into the circumstance!

Khi mình scan thì thấy là có secret github

Mặc dù người dụng đã có gắng delete file nhưng secret vẫn được lưu trong commit.

2) Clear All secrets at anywhere.

2.1) Using BFG Repo-Cleaner to clear all secret

https://rtyley.github.io/bfg-repo-cleaner/

Để sử dụng BFG Repo-Cleaner bạn cần cài đặt java.

sudo apt install default-jdk
wget https://repo1.maven.org/maven2/com/madgag/bfg/1.14.0/bfg-1.14.0.jar

Tiếp đến bạn git clone repo với option

git clone --mirror https://github.com/mrnim94/devsecops-laboratory.git

2.1.1) Delete files that contain secrets

Ở đây mình thực hiện delete file variable.

root@work-space-u20:~/github# java -jar bfg.jar --delete-files variables.tf devsecops-laboratory.git

Using repo : /root/github/devsecops-laboratory.git

Found 4 objects to protect
Found 5 commit-pointing refs : HEAD, refs/heads/master, refs/heads/renovate/configure, ...

Protected commits
-----------------

These are your protected commits, and so their contents will NOT be altered:

 * commit 7a3464f6 (protected by 'HEAD')

Cleaning
--------

Found 11 commits
Cleaning commits:       100% (11/11)
Cleaning commits completed in 95 ms.

Updating 4 Refs
---------------

        Ref                             Before     After   
        ---------------------------------------------------
        refs/heads/master             | 7a3464f6 | df965e7d
        refs/heads/renovate/configure | db056480 | a58e2e52
        refs/pull/1/head              | db056480 | a58e2e52
        refs/pull/1/merge             | 61fcce9d | f15715f6

Updating references:    100% (4/4)
...Ref update completed in 28 ms.

Commit Tree-Dirt History
------------------------

        Earliest      Latest
        |                  |
        . D D D DD D D D D m

        D = dirty commits (file tree fixed)
        m = modified commits (commit message or parents changed)
        . = clean commits (no changes to file tree)

                                Before     After   
        -------------------------------------------
        First modified commit | 1ebdfa0c | 6cdb5ce2
        Last dirty commit     | 65a05f45 | 6caa2f08

Deleted files
-------------

        Filename       Git id                              
        ---------------------------------------------------
        variables.tf | f47d61c7 (182 B ), e69a0f03 (176 B )


In total, 18 object ids were changed. Full details are logged here:

        /root/github/devsecops-laboratory.git.bfg-report/2023-06-18/08-19-11

BFG run is complete! When ready, run: git reflog expire --expire=now --all && git gc --prune=now --aggressive
>>>>>>>>>>>>>>>>>>>>

cd devsecops-laboratory.git
git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push --force

Nếu bạn có thấy lỗi trên thì cũng không sao cả.

trở lại với github bạn sẽ thấy điều lạ là không có commit nào mới cả

DevSecOps

Post navigation

Previous Post: [IP/EKS] Add new subnets into the eks on AWS
Next Post: [EKS/IPs] Increase most many IPs as possible on each Node of your EKS.

More Related Articles

[DevSevOps] How to Install OpenVAS DevSecOps
[OPA Conftest] general-purpose policy engine DevSecOps
[Trivy] Protect your application by Trivy DevSecOps
[DevSecOps] Scan Terraform DevSecOps
[Kubernetes Operations and Security] CIS Benchmarking and Kube-bench – Follow the best practice security recommendations for your Kubernetes. DevSecOps
[Talisman/DevSecOps] Discover the sensitive information in your code. DevSecOps

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Tham Gia Group DevOps nhé!
Để Nim có nhiều động lực ra nhiều bài viết.
Để nhận được những thông báo mới nhất.

Recent Posts

  • [Azure] The subscription is not registered to use namespace ‘Microsoft.ContainerService’ May 8, 2025
  • [Azure] Insufficient regional vcpu quota left May 8, 2025
  • [WordPress] How to add a Dynamic watermark on WordPress. May 6, 2025
  • [vnet/Azure] VNet provisioning via Terraform. April 28, 2025
  • [tracetcp] How to perform a tracert command using a specific port. April 3, 2025

Archives

  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Categories

  • BareMetal
    • NextCloud
  • CI/CD
    • Argo Events
    • ArgoCD
    • ArgoWorkflows
    • Git
      • Bitbucket
    • Harbor
    • Jenkins
    • Spinnaker
    • TeamCity
  • Coding
    • DevSecOps
    • Golang
    • Jquery & JavaScript
    • Laravel
    • NextJS 14 & ReactJS & Type Script
    • Python
    • Selenium
    • Terraform
      • AWS – Amazon Web Service
      • Azure Cloud
      • GCP – Google Cloud
  • Kubernetes & Container
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Docker
    • Helm Chart
    • Isito-EnvoyFilter
    • Kong Gateway
    • Kubernetes
      • Ingress
      • Pod
    • Longhorn – Storage
    • MetalLB
    • OAuth2 Proxy
    • Vault
    • VictoriaMetrics
  • Log, Monitor & Tracing
    • DataDog
    • ELK
      • Kibana
      • Logstash
    • Fluent
    • Grafana
    • Prometheus
  • Uncategorized
  • Admin

Copyright © 2025 NimTechnology.