Skip to content

Instantly share code, notes, and snippets.

@rayyildiz
Last active July 29, 2024 16:19
Show Gist options
  • Select an option

  • Save rayyildiz/524ae758fa28ff8bc3f4473754102210 to your computer and use it in GitHub Desktop.

Select an option

Save rayyildiz/524ae758fa28ff8bc3f4473754102210 to your computer and use it in GitHub Desktop.
Find secrets and convert to CSV format

Detect Secrets

Install Detect Secrets. Run following command to detect the secrets:

detect-secrets scan --all-files  --disable-plugin Base64HighEntropyString --disable-plugin HexHighEntropyString   > secrets.json

Run scripts to convert to CSV format.

python main.py
import json
import pandas as pd
rows = []
with open('secrets.json') as json_data:
d = json.load(json_data)
result = d["results"]
for key,value in result.items():
for xs in value:
rows.append({
"file": xs["filename"],
"type": xs["type"],
"line": xs["line_number"],
"hashed_secrets": xs["hashed_secret"],
})
df = pd.DataFrame(rows)
df.to_csv("secrets.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment