<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jean</title>
    <description>The latest articles on DEV Community by Jean (@cuireuncroco).</description>
    <link>https://dev.to/cuireuncroco</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F338256%2Ff1ab3939-7fbc-4941-b233-e8e6e5433fbe.jpg</url>
      <title>DEV Community: Jean</title>
      <link>https://dev.to/cuireuncroco</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cuireuncroco"/>
    <language>en</language>
    <item>
      <title>How to scan local files for secrets in python using the GitGuardian API</title>
      <dc:creator>Jean</dc:creator>
      <pubDate>Mon, 29 Jun 2020 15:54:49 +0000</pubDate>
      <link>https://dev.to/cuireuncroco/how-to-scan-local-files-for-secrets-in-python-using-the-gitguardian-api-190h</link>
      <guid>https://dev.to/cuireuncroco/how-to-scan-local-files-for-secrets-in-python-using-the-gitguardian-api-190h</guid>
      <description>&lt;p&gt;&lt;em&gt;Do you how many secrets, like API keys or credentials, are hidden in your local files? Today, we're going to show you how you can scan files and directories for sensitive information like secrets. To accomplish this, we'll use the GitGuardian API and python wrapper.  By the end of this tutorial you will understand how the API works so you can start building your own, custom secrets detections scripts.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What our script will do
&lt;/h2&gt;

&lt;p&gt;We will create a python script that will scan all files within a local directory for secrets. To do this we will be using the GitGuardian API and the API python wrapper, we recommend reviewing these resources before starting.&lt;/p&gt;

&lt;p&gt;Our script will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Detect secrets and other policy breaks from your file directory.&lt;/li&gt;
&lt;li&gt;Print the filename, policy break and matches for all policy breaks found.&lt;/li&gt;
&lt;li&gt;Output the result to a JSON format.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Getting setup
&lt;/h2&gt;

&lt;p&gt;Before we get started writing our script, let's get the necessary components setup.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing the GitGuardian python API client
&lt;/h3&gt;

&lt;p&gt;Install the GitGuardian python API client using de facto package manager ‘pip’.&lt;/p&gt;

&lt;p&gt;In your terminal or command line execute the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip3 install --upgrade pygitguardian
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Obtaining the GitGuardian API token
&lt;/h3&gt;

&lt;p&gt;Sign up for a free developer account from GitGuardian using your GitHub account or email at &lt;a href="https://dashboard.gitguardian.com/api/v1/auth/user/github_login/authorize?utm_source=blog&amp;amp;utm_medium=referral&amp;amp;utm_campaign=secrets-scan"&gt;https://dashboard.gitguardian.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;From the menu, navigate to the ‘API’ tab, scroll to ‘Generate new API key’ and select ‘Create new API key’. Make sure you give it an appropriate name.&lt;/p&gt;

&lt;p&gt;You will not be able to view the API key again so make sure you immediately copy it to your clipboard before navigating away.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting up the directory and files
&lt;/h3&gt;

&lt;p&gt;Open your terminal or command line.&lt;/p&gt;

&lt;p&gt;Create a new directory in the local you wish to save your script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir  directory-scan
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Enter into the directory using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd  directory-scan
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Setting environment variables
&lt;/h3&gt;

&lt;p&gt;As a stickler for good coding practices, this tutorial will use environment variables to store our API token (rule number one, never hardcode secrets in source code!).&lt;/p&gt;

&lt;p&gt;I recommend using a tool called &lt;a href="https://pypi.org/project/python-dotenv/"&gt;python-dotenv&lt;/a&gt; which will allow you to import environment variables, or you can set the API token in your console.&lt;/p&gt;

&lt;p&gt;Create a new file called .env:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch .env
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Open this file in your chosen text editor and create a variable to store our API:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;GG_API_KEY=**INSERT API TOKEN**&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing our script
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Importing the modules and setting up our client
&lt;/h3&gt;

&lt;p&gt;Next let's create a file called directory_scan.py:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch directory_scan.py
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Open this file with your chosen text editor.&lt;/p&gt;

&lt;p&gt;First we need to import the modules we need:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
import  glob
import  os
import  sys
import  traceback

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In addition to standard modules. We will also be importing and using ‘&lt;a href="https://docs.python.org/3/library/glob.html"&gt;glob&lt;/a&gt;’. This will allow us to get the path and file names of all the files within our directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Importing environment variables
&lt;/h3&gt;

&lt;p&gt;If you are using python-dotenv then we need to load in our API token from our .env file and use the API token within:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
from  dotenv import load_dotenv
load_dotenv()
API_KEY = os.getenv("GG_API_KEY")

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now, thanks to &lt;code&gt;load_dotenv()&lt;/code&gt;, you’ll be able to retrieve the &lt;code&gt;GG_API_KEY&lt;/code&gt; this way and store it in a variable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Importing our GitGuardian API client modules
&lt;/h3&gt;

&lt;p&gt;Next load the GitGuardian API client.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pygitguardian import GGClient
from pygitguardian.config import MULTI_DOCUMENT_LIMIT
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;‘GGClient’ is the core module for our API client, it will handle the data we are scanning, send it to the GitGuardian scanning engine and receive the results.&lt;/p&gt;

&lt;p&gt;The GitGuardian API only allows a maximum package of 20 files or a total size of 2mb for each request to allow for asynchronous scanning. Our &lt;code&gt;MULTI_DOCUMENT_LIMIT&lt;/code&gt; module imports these parameters so we don’t send invaild requests to the server.&lt;/p&gt;

&lt;p&gt;This does not mean you can only scan 20 files at a time. Our script will handle this by breaking the files into ‘chunks’ that meet the maximum API requirements and send multiple requests before collating the information at the end.&lt;/p&gt;

&lt;p&gt;Now we just need to initialize the GGClient by attaching our API key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Initializing GGClient
client = GGClient(api_key=API_KEY) 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Loading files into an array
&lt;/h3&gt;

&lt;p&gt;We now need to load in all the files and file paths within our current directory. Our script scans recursively from the working directory (the directory from which the script is called):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Create a list of dictionaries for scanning
to_scan = []
for name in glob.glob("**/*", recursive=True):
    if ".env" in name: or os.path.isdir(name):
        continue
    with open(name) as fn:
        to_scan.append({"document": fn.read(), "filename": os.path.basename(name)})) 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The ‘glob’ module allows us create a list of files and path names that we will add into an array called &lt;code&gt;to_scan&lt;/code&gt; so we can scan them.&lt;/p&gt;

&lt;p&gt;We are going to also add a &lt;code&gt;if&lt;/code&gt; statement that will exclude both our &lt;code&gt;.env&lt;/code&gt; file and also ignore any folders we are trying to add into our array which will create an error (the files within the folders will still be added).&lt;/p&gt;

&lt;p&gt;This will scan files recursively (from the working directory the script is within), but if you want to scan a different directory you can add the in the file path.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;for name in glob.glob("users\user\documents\**", recursive=True):&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you want to check your code is working so far. On a new line add ‘print(to_scan)’. You should get a list of all the files and their contents within your current directory. Comment out or remove before continuing.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  Process the files in ‘chunks’ and making the API request
&lt;/h3&gt;

&lt;p&gt;As previously mentioned the API will only accept 20 files per request with a maximum of 1MB per file. So we are going to break up our files into acceptable chunks to send as a request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Process in a chunked way to avoid passing the multi document limit
to_process = []
for i in range(0, len(to_scan), MULTI_DOCUMENT_LIMIT):
   chunk = to_scan[i : i + MULTI_DOCUMENT_LIMIT]
   try:
       scan = client.multi_content_scan(chunk)
   except Exception as exc:
       # Handle exceptions such as schema validation
       traceback.print_exc(2, file=sys.stderr)
       print(str(exc))
   if not scan.success:
       print("Error scanning some files. Results may be incomplete.")
       print(scan)
   to_process.extend(scan.scan_results)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;First, create an empty array to hold the scan results from the API, we call this array &lt;code&gt;to_process&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We are going to loop through our &lt;code&gt;to_scan&lt;/code&gt; array containing our file paths and break them into chunks. To do this we are using a ‘range’ function which we will pass a start value, end value and stepping value.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;range(start_value, end_value, step)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We are going to load the current values of our array into a variable called ‘chunk’.&lt;/p&gt;

&lt;p&gt;Using a try block, we will scan our current chunk using the &lt;a href="https://api.gitguardian.com/docs#operation/multiple_scan"&gt;multi content scan command&lt;/a&gt; of the GG API client.&lt;/p&gt;

&lt;p&gt;Of course we need to handle any expectations where the scan will fail, for example if the filename is too long for our schema.&lt;/p&gt;

&lt;p&gt;The traceback will show the exact line it failed.&lt;/p&gt;

&lt;p&gt;Let's add in a message in the scenario our scan fails.&lt;/p&gt;

&lt;p&gt;Finally we are going to append our scan results to our array ‘to_process’.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;FAQ: If I need to scan 200 files, will this count as 1 or 10 API requests in my dashboard? It will count as 10 but don’t worry you have 1,000 API requests a month.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Printing results
&lt;/h2&gt;

&lt;p&gt;Now we will loop through our results. If a policy break is detected it will be captured by the &lt;code&gt;.has_secrets tag&lt;/code&gt;, if this is true, we will print that result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Printing the results
for i, scan_result in enumerate(to_process):
   if scan_result.has_policy_breaks:
       print(f"{chunk[i]['filename']}: {scan_result.policy_break_count} break/s found")
Now we will loop through our results. If a policy break is detected it will be captured by the .has_policies_breaks tag, if this is true, we will print that result.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Code Checkpoint 1
&lt;/h2&gt;

&lt;p&gt;We are ready to run our first scan so let's quickly make sure our code is the same.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import  glob
import  os
import  sys
import  traceback
from  dotenv import load_dotenv
load_dotenv()
API_KEY = os.getenv("GG_API_KEY") 

from pygitguardian import GGClient
from pygitguardian.config import MULTI_DOCUMENT_LIMIT

# Initializing GGClient
client = GGClient(api_key=API_KEY) 

# Create a list of dictionaries for scanning
to_scan = []
for name in glob.glob("**/*", recursive=True):
    with open(name) as fn:
        to_scan.append({"document": fn.read(), "filename": os.path.basename(name)})) 

# Process in a chunked way to avoid passing the multi document limit
to_process = []
for i in range(0, len(to_scan), MULTI_DOCUMENT_LIMIT):
   chunk = to_scan[i : i + MULTI_DOCUMENT_LIMIT]
   try:
       scan = client.multi_content_scan(chunk)
   except Exception as exc:
       # Handle exceptions such as schema validation
       traceback.print_exc(2, file=sys.stderr)
       print(str(exc))
   if not scan.success:
       print("Error scanning some files. Results may be incomplete.")
       print(scan)
   to_process.extend(scan.scan_results)

# Printing the results
for i, scan_result in enumerate(to_process):
   if scan_result.has_secrets:
       print(f"{chunk[i]['filename']}: {scan_result.policy_break_count} break/s found")
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Running the script
&lt;/h2&gt;

&lt;p&gt;We are now ready to run our first directory scan.&lt;/p&gt;

&lt;p&gt;You can download some example files that contain expired secrets here so you can test your script.&lt;/p&gt;

&lt;p&gt;Move the directory_scan.py file into the directory you want to scan.&lt;/p&gt;

&lt;p&gt;Open your terminal, navigate to the directory and run the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3 directory_scan.py
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Congratulations you just scanned your directory for policy breaks!&lt;/p&gt;

&lt;p&gt;After your script has run, you will receive feedback with the amount of policy breaks that have been found.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main.py: 1 break/s found
sample.yaml: 1 break/s found
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now we know what files have policy breaks.&lt;/p&gt;

&lt;p&gt;But we don't know if the policy break is a secret and we don't know what kind of secret it is. So next we will add some additional detail into our results.&lt;/p&gt;

&lt;h2&gt;
  
  
  Displaying additional information
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Including policy break type and matches
&lt;/h3&gt;

&lt;p&gt;Now we have detected policy breaks, we may wish to know what policy breaks have been detected, for example was it a Slack token, an AWS key or a filename policy that was broken.&lt;/p&gt;

&lt;p&gt;Let's add a line in the output that tells us what policy breaks have been broken.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can find more information on policy breaks in the GitGuardian &lt;a href="https://dashboard.gitguardian.com/api/v1/auth/user/github_login/authorize?utm_source=blog&amp;amp;utm_medium=referral&amp;amp;utm_campaign=secrets-scan"&gt;dashboard&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; # Printing the results
for i, scan_result in enumerate(to_process):
   if scan_result.has_policy_breaks:
       print(f"{chunk[i]['filename']}: {scan_result.policy_break_count} break/s found")
       # Printing policy break type
       for  policy_break in scan_result.policy_breaks:
           print(f"\t{policy_break.break_type}:")
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now we are going to add a nested loop within our previous loop and for each policy break, we are going to use the break_type tag in the GG client to print the type of policy break that has occurred (in other words, the type of secret, filename or extension that has triggered the alert).&lt;/p&gt;

&lt;p&gt;Now if we run our function again, we will get the same results, but this time we will also get the name of the policy break next to each file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    main.py: 1 break/s found
        AWS Key: 
    sample.yaml: 1 break/s found
        Google API Key:
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Adding matches
&lt;/h2&gt;

&lt;p&gt;It is not always appropriate to print the matches we find, but in the case of this example we are going to do just that.&lt;/p&gt;

&lt;p&gt;We are going to create another for loop, again nested. We are now going to call the tag ‘match’ from the GG and print that. This will give us our policy break.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; # Printing the results
for i, scan_result in enumerate(to_process):
   if scan_result.has_policy_breaks:
       print(f"{chunk[i]['filename']}: {scan_result.policy_break_count} break/s found")
       # Printing policy break type
       for  policy_break in scan_result.policy_breaks:
           print(f"\t{policy_break.break_type}:")
           # Printing matches
           for match in policy_break.matches:
                print(f"\t\t{match.match_type}:{match.match}")
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Lets run this again and we should now get&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;File name and number of policy breaks.&lt;/li&gt;
&lt;li&gt;Policy break types (secrets if any).
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    main.py: 1 break/s found
        AWS Key: *********************************
    sample.yaml: 1 break/s found
        Google API Key: *****************************
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Retrieving the output as JSON
&lt;/h3&gt;

&lt;p&gt;Now let's say we need to output these results in JSON format.&lt;/p&gt;

&lt;p&gt;The API has built in functionality to convert results into JSON format.&lt;/p&gt;

&lt;p&gt;Let's loop through our files and if our scan results have policy breaks within them, we will print them in JSON.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  #Getting results in JSON format           
for i, scan_result in enumerate(to_process):
   if scan_result.has_policy_breaks:
       print(scan_result.to_json())
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Checkpoint 2
&lt;/h2&gt;

&lt;p&gt;You're done! Let's do a final code review to make sure your code is correct.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import  glob
import  os
import  sys
import  traceback
from  dotenv import load_dotenv
load_dotenv()
API_KEY = os.getenv("GG_API_KEY") 

from pygitguardian import GGClient
from pygitguardian.config import MULTI_DOCUMENT_LIMIT

# Initializing GGClient
client = GGClient(api_key=API_KEY) 

# Create a list of dictionaries for scanning
to_scan = []
for name in glob.glob("**/*", recursive=True):
    with open(name) as fn:
        to_scan.append({"document": fn.read(), "filename": os.path.basename(name)})) 

# Process in a chunked way to avoid passing the multi document limit
to_process = []
for i in range(0, len(to_scan), MULTI_DOCUMENT_LIMIT):
   chunk = to_scan[i : i + MULTI_DOCUMENT_LIMIT]
   try:
       scan = client.multi_content_scan(chunk)
   except Exception as exc:
       # Handle exceptions such as schema validation
       traceback.print_exc(2, file=sys.stderr)
       print(str(exc))
   if not scan.success:
       print("Error scanning some files. Results may be incomplete.")
       print(scan)
   to_process.extend(scan.scan_results)

# Printing the results
for i, scan_result in enumerate(to_process):
   if scan_result.has_secrets:
       print(f"{chunk[i]['filename']}: {scan_result.policy_break_count} break/s found")
       # Printing policy break type
       for  policy_break in scan_result.policy_breaks:
           print(f"\t{policy_break.break_type}:")
           # Printing matches
           for match in policy_break.matches:
                print(f"\t\t{match.match_type}:{match.match}")

#Getting results in JSON format    
for i, scan_result in enumerate(to_process):
   if scan_result.has_policy_breaks:
       print(scan_result.to_json())
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Warning
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Please note that you should only scan for secrets in places they should not exist and revoke any that are found. As a general rule, any secrets in that end up in remote locations not specifically designed to secure sensitive data should be considered compromised. This includes using the GitGuardian API.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;p&gt;Now that you have created your first script using the GitGuardian API and python wrapper you can create your own awesome scripts to scan files.&lt;/p&gt;

&lt;p&gt;The next tutorial will help you scan files pre-commit or in the CI.&lt;/p&gt;

&lt;p&gt;Any questions on the API please email us, &lt;a href="//mailto:mackenzie.jackson@gitguardian.com"&gt;mackenzie.jackson@gitguardian.com&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>python</category>
      <category>security</category>
    </item>
    <item>
      <title>What is secret sprawl, why it’s dangerous, and how developers can prevent it?</title>
      <dc:creator>Jean</dc:creator>
      <pubDate>Thu, 04 Jun 2020 14:07:07 +0000</pubDate>
      <link>https://dev.to/cuireuncroco/what-is-secret-sprawl-why-it-s-dangerous-and-how-developers-can-prevent-it-2596</link>
      <guid>https://dev.to/cuireuncroco/what-is-secret-sprawl-why-it-s-dangerous-and-how-developers-can-prevent-it-2596</guid>
      <description>&lt;h1&gt;
  
  
  When developers refer to secret sprawl they are typically referring to the unwanted distribution of secrets across multiple platforms, services and machines. Once a secret ‘sprawls’ into other systems it can often have a follow on effect allowing attackers to use secrets to move laterally between services and uncover additional secrets.
&lt;/h1&gt;

&lt;p&gt;To really understand how secrets sprawl, we need first to understand two key concepts, what is a secret and how we use secrets.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a secret?
&lt;/h2&gt;

&lt;p&gt;As the name suggests, a secret is really any data that is sensitive but when discussing secrets in the context of software development, developers are generally referring to anything that grants access to external services or data. These are most commonly API keys, credentials and security certificates.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rexRV8Eu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/06/developer-secret-cartoon.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rexRV8Eu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/06/developer-secret-cartoon.png" alt="What is a secret?"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How do developers use secrets?
&lt;/h3&gt;

&lt;p&gt;Software used to include everything needed to run internally, today as the world is much more reliant on the internet, this has allowed software architecture to fundamentally change with the introduction of new services such as Cloud Architecture, SaaS Platforms and Microservices.&lt;/p&gt;

&lt;p&gt;These services allow a lot of development work not related to the core of an application to be offloaded, this reduces the upfront development costs while simultaneously making applications more robust and scalable. As beneficial as this is, it does introduce a new challenge to overcome, how to establish a trusted and secure connection with each of these services. This is generally done through an exchange of secrets, namely API keys, security certificates and credentials.&lt;/p&gt;

&lt;h3&gt;
  
  
  The challenge
&lt;/h3&gt;

&lt;p&gt;Depending on the size and objective of an application, a project might need to connect to tens or even hundreds of services which all need individual secrets.&lt;/p&gt;

&lt;p&gt;Developers not only need to store these secrets safely, they also need to be able to distribute and use secrets during their development process. Adding an even greater level of complication, secrets will often get rotated and revoked over time, this means that the distribution of secrets is a challenge that will last throughout the entire software development lifecycle.&lt;/p&gt;

&lt;h2&gt;
  
  
  How secrets sprawl across the internet
&lt;/h2&gt;

&lt;p&gt;Secrets management requires a thoughtful understanding of what permissions to give secrets, who needs access to them, how to keep them in sync across multiple teams (often in different geographies), and what restrictions, tools and guidelines need to be in place when accessing and using them.&lt;/p&gt;

&lt;p&gt;Strict secret management creates added procedures that are both difficult to implement and tempting to circumvent. This is why developers and organizations alike often store secrets in unsecure locations, usually unintentionally. Secrets can be hardcoded into source code and included in a git repository which can get cloned onto multiple machines (professional and personal), get sent via Slack or emailed for convenience, saved to an internal Wiki and uploaded into a google drive…. So on and so forth.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eTFkqPUa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/06/secret-sprawl-net-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eTFkqPUa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/06/secret-sprawl-net-1.png" alt="Secret sprawl net"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Secrets sprawl increases the 'attackable area'
&lt;/h3&gt;

&lt;p&gt;Even if secrets don’t end up on public internet space (for example on a public git repository) they should still be considered compromised if they are sprawled. Having secrets on multiple services, email, Slack, git etc increases what is referred to as the 'attackable area’.&lt;/p&gt;

&lt;p&gt;The attackable area refers to the amount of systems that could be exploited to find secrets. In a situation where an organization has secrets sprawled over multiple locations, it only takes one compromised developer's git account, one compromised email or one compromised computer for an attacker to suddenly gain access to a trove of highly sensitive secrets.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--G3qVc8Nw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/06/secret-sprawl-attackable-area.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--G3qVc8Nw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/06/secret-sprawl-attackable-area.png" alt="Illustration of an Attackable Area"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Secrets can be used to travel laterally between systems too, for example a secret allowing an attacker access to Slack messages might lead him to discover secrets with access to a cloud drive which might uncover secrets to a database….. So on and so forth. &lt;strong&gt;Secrets should remain centralized and encrypted.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How do you prevent secret sprawl?
&lt;/h2&gt;

&lt;p&gt;Secrets management as stated previously, is difficult. But there are great tools available that can be implemented to help tackle the issue of secret sprawl.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;WATCH | How to avoid secrets sprawl in your organization?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=g9et-KV-dXo"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qAbzidp_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://img.youtube.com/vi/g9et-KV-dXo/hqdefault.jpg" alt="How to avoid secrets sprawl in your organization?"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Secrets Scanning
&lt;/h3&gt;

&lt;p&gt;To combat secret sprawl it is essential to have visibility inside the systems where secrets may be located. .git repositories can contain a trove of secrets buried in the history including inside old versions of source code, application logs and config files. It is important to consider also that even the best secrets management systems and policies do not prevent newly generated secrets entering the code base or old secrets being extracted and included again, therefore all organizations should implement secrets scanning into their workflow.&lt;/p&gt;

&lt;p&gt;GitGuardian offers a &lt;a href="https://gitguardian.com/developer?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=secrets_sprawl"&gt;free secrets scanning tool for .git repositories&lt;/a&gt; which scans, in real time, every commit you make so you can immediately identify if your secrets have sprawled. GitGuardian also has an API so all office systems like slack or email can be scanned for secrets too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Encrypting Secrets
&lt;/h2&gt;

&lt;p&gt;Git repositories offer unmatched collaboration features for developers, git not only acts as a complete historic record of a project but also offers a single point of truth for the latest version and files, hence why it is so common for secrets to be stored within them. The good news is that there are ways to store secrets securely within git repositories.&lt;/p&gt;

&lt;p&gt;Git-secret is a free open source tool that encrypts secrets within git repositories making them safe to distribute through git.&lt;/p&gt;

&lt;p&gt;While encrypting secrets and storing them within git does provide the benefit of preventing secrets sprawling through the git, it does not prevent secret sprawl on other services and developers will still need to manage the secrets to decrypt the secret file (Secret sprawl can be like inception, secrets for files that contain secrets inside, which give access to services with secrets inside them).&lt;/p&gt;

&lt;h2&gt;
  
  
  Using secrets management solutions
&lt;/h2&gt;

&lt;p&gt;One of the most popular secrets management tools on the market, &lt;a href="https://www.vaultproject.io/"&gt;Hashicorp Vault&lt;/a&gt;, offers both open-source and enterprise solutions to developers and organizations and provides the ability to tightly restrict and control access to secrets, enabling the easy rotation of secrets while also giving developers the ability to easily connect to external services.&lt;/p&gt;

&lt;p&gt;Hashicorp vault can be difficult to roll out and implement and might not be appropriate for all types of secrets.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;No organization big or small is immune from secret sprawl and the best policies and tools still won’t stop every possibility of secret sprawl. This is why to combat secret sprawl you need to combine a strategy to store secrets, manage secrets (rotate and distribute) with a strategy to gain visibility into your services and systems.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h2&gt;
  
  
  &lt;a href="https://gitguardian.com/contact?utm_source=blog&amp;amp;utm_medium=referral&amp;amp;utm_campaign=secrets_sprawl"&gt;Get visibilty over your systems now with GitGuardian&lt;/a&gt;
&lt;/h2&gt;
&lt;/blockquote&gt;

</description>
      <category>security</category>
      <category>devops</category>
      <category>git</category>
    </item>
    <item>
      <title>GitHub security: what does it take to protect your company from credentials leaking on GitHub?</title>
      <dc:creator>Jean</dc:creator>
      <pubDate>Wed, 20 May 2020 14:38:43 +0000</pubDate>
      <link>https://dev.to/cuireuncroco/github-security-what-does-it-take-to-protect-your-company-from-credentials-leaking-on-github-4l2e</link>
      <guid>https://dev.to/cuireuncroco/github-security-what-does-it-take-to-protect-your-company-from-credentials-leaking-on-github-4l2e</guid>
      <description>&lt;p&gt;&lt;strong&gt;This post was originally written by GitGuardian's CEO Jérémy Thomas. This guide is intended for CISOs, Application Security, Threat Response, and other security professionals who want to protect their companies from credentials leaking on GitHub.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Read this guide if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You are aware of the risks of corporate credentials leaking on public GitHub. If you still need convincing, we have 3 years of historical GitGuardian monitoring data that we can filter down to your company domain name, aggregate to remove sensitivity, and share with you upon request, without you taking any of your time to talk to our sales reps if you don’t want to:&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://gitguardian.com/contact?utm_source=blog&amp;amp;utm_medium=referral&amp;amp;utm_campaign=github_security"&gt;Get three years of historical GitGuardian monitoring data filtered down to your company domain name&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;You are in the market for a solution, and would like to investigate the requirements such a solution should have.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;: I am the CEO of GitGuardian, which offers solutions for detecting, alerting and remediating secrets leaked within GitHub, therefore this article may contain some biases. GitGuardian has been monitoring public GitHub for over 3 years which is why we are uniquely qualified to share our views on this important security issue. Security professionals are often overwhelmed by an army of vendors, many of which are equipped with disputable facts and figures, and favor the use of scare tactics. These professionals therefore prefer to leverage their network or peer recommendations to make buying decisions. I am confident that the information in this guide can be backed up by solid and objective evidence. If you’d like to share your comments on it, please email me directly at jeremy [dot] thomas [at] gitguardian [dot-com].&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Requirements for public GitHub monitoring and why they are important
&lt;/h1&gt;

&lt;p&gt;We’ve classified requirements in functional categories:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BTTU_0Kq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/200520-Feature-FormatChange-DRAFT.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BTTU_0Kq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/200520-Feature-FormatChange-DRAFT.png" alt="Requirements-for-public-GitHub-monitoring"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will go through these requirements one by one and explain why they are important.&lt;/p&gt;

&lt;h2&gt;
  
  
  Define &amp;amp; Monitor your perimeter
&lt;/h2&gt;

&lt;p&gt;Monitoring your perimeter requires the ability to automatically associate repositories, developers and published code with your organization. There are millions of commits per day on public GitHub, how can organizations look through the noise and focus exclusively on the information that is of direct interest to them?&lt;/p&gt;

&lt;h3&gt;
  
  
  Organization repositories monitoring
&lt;/h3&gt;

&lt;p&gt;These are the repositories that are listed under your company’s GitHub Organization, if your company has one. This only concerns companies which have open-source projects. Less than 20% of corporate leaks on GitHub occur within public repositories owned by organizations. The majority of the  remaining leaks occur on developers’ personal repositories, and a small portion also occurs on IT service providers' or other suppliers’ repositories.&lt;/p&gt;

&lt;h3&gt;
  
  
  Developers’ personal public repositories monitoring
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Around 80% of corporate leaks on GitHub occur on their developers’ personal public repositories. And yes, I’m really talking about corporate leaks, not personal ones.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In the vast majority of the cases, these leaks are unintentional, not malevolent. They happen for many reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Developers typically have one GitHub account that they use both for personal and professional purposes, sometimes mixing the repositories.&lt;/li&gt;
&lt;li&gt;It is easy to misconfigure git and push wrong data.&lt;/li&gt;
&lt;li&gt;It is easy to forget that the entire git history is still publicly visible even if sensitive data has since been deleted from the actual version of source code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Detect incidents
&lt;/h2&gt;

&lt;p&gt;Sensitive information that is leaked on the platform generally  falls under two categories:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What developers call “secrets”,&lt;/li&gt;
&lt;li&gt;Intellectual Property like proprietary source code.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Secret: anything that gives access to a system: API keys, database connection strings, private keys, usernames and passwords. Secrets can give access to cloud infrastructure, databases, payment systems, messaging systems, file sharing systems, CRMs, internal portals, ...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It is very rare, in our experience, to see valid PII leaked on the platform, although we often see secrets giving access to systems containing PII.&lt;/p&gt;

&lt;h3&gt;
  
  
  High precision
&lt;/h3&gt;

&lt;p&gt;Precision answers the question: “What is the percentage of sensitive information that you detect that is actually sensitive?”. This question is perfectly legitimate, especially in the context of SOCs being overwhelmed with too many false positive alerts.&lt;/p&gt;

&lt;p&gt;Precision is easily measurable: the vendor sends alerts, and users can give feedback through a “true alert” / “false alert” button. Your vendor should be able to present precision metrics, backed by strong evidence records and well-defined methodology.&lt;/p&gt;

&lt;h3&gt;
  
  
  High recall
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MmXMuyEZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/EOJow2y5KEHd6BJSKFT-v9qAVXmcPKikf-hqQWoFrIyFbjnA7W-u21QpMU14nJ8FviAzNojvmPfUtEktCPF6zoam3C__iBVnS-7xZlAT-qF3wzeEwSm2OyowJ5tYK1xuEbRXwgHb" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MmXMuyEZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/EOJow2y5KEHd6BJSKFT-v9qAVXmcPKikf-hqQWoFrIyFbjnA7W-u21QpMU14nJ8FviAzNojvmPfUtEktCPF6zoam3C__iBVnS-7xZlAT-qF3wzeEwSm2OyowJ5tYK1xuEbRXwgHb" alt="Concept-of-recall"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This one is a bit tougher than precision. Recall answers the question: "What is the percentage of sensitive information you failed to detect?". Having a high recall means having a small number of missed secrets. This question is also very important, considering the impact that a single undetected credential can have for an organization.&lt;/p&gt;

&lt;p&gt;Recall is more complicated to measure than precision. This is because finding sensitive information in source code is like finding needles in a haystack: there are a lot more sticks than there are needles. You need to manually go through thousands of sticks in order to realize that you’ve missed a needle or two. A decent proxy for recall is the number of individual  API keys and additional sensitive information supported by your vendor.&lt;/p&gt;

&lt;p&gt;A good algorithm is able to achieve excellence in precision AND recall.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ability to detect unprefixed credentials
&lt;/h3&gt;

&lt;p&gt;Some secrets are easier to find than others, especially prefixed credentials that are strictly defined by a distinctive, unambiguous pattern.&lt;/p&gt;

&lt;p&gt;The majority of published credentials however, don’t fall into this category. Therefore, any solution based entirely on prefix detection will miss a lot of leaked credentials. Your vendor must be able to detect Datadog keys or OAuth tokens for example, using techniques involving a combination of entropy statistics and sophisticated pattern matching applied not on the presumed key itself, but on its context.&lt;/p&gt;

&lt;h3&gt;
  
  
  Keyword monitoring
&lt;/h3&gt;

&lt;p&gt;When choosing keywords that you would like to be alerted on, make sure keywords are distinctive enough to be uniquely linked to your company. Good keywords are typically: internal project names (providing they are not common), internal URLs or a reserved IP address range (although not technically a keyword).  &lt;/p&gt;

&lt;p&gt;Do you want to know if a given keyword is distinctive enough? Try using the GitHub built-in search for an estimation of the results it would bring (this is just an estimation, as the GitHub search is rather limited).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VKlEug0j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/Docker_GitHub_search_GitGuardian.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VKlEug0j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/Docker_GitHub_search_GitGuardian.png" alt="Docker-search-GitHub"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A concrete example with “docker.com”. With over 597K source codes containing the keyword, it is not a good candidate for keyword matching.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Alert
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Real-time alerting
&lt;/h3&gt;

&lt;p&gt;When remediating GitHub leaks, you are in a race against time.&lt;/p&gt;

&lt;p&gt;This is especially true when discussing leaked credentials (as opposed to Intellectual Property):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You are not fighting against the information being more and more widely spread. Because the moment you invalidate the credential, it no longer creates a threat meaning you are no longer concerned if it is further disseminated (except for brand reputation considerations), since it does not give access to anything anymore.&lt;/li&gt;
&lt;li&gt;You are fighting against the credentials being exploited. Credentials are extremely easy to exploit by anyone, without any specific knowledge.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Any detection that involves human operators (typically filtering too many false positives) and is not fully automated is probably already too long to react. You must expect your vendor to come up with strong evidence that their reaction time is counted in minutes, not hours or days.&lt;/p&gt;

&lt;h3&gt;
  
  
  Developer alerting
&lt;/h3&gt;

&lt;p&gt;Facing a leak can be a tough process that requires speed, and knowledge from multiple people (typically Threat Response / Application Security / Developers).&lt;/p&gt;

&lt;p&gt;Since the developer responsible for the leak is at the forefront of the issue, they can be your first responders. This is especially the case if your solution raised the alert fast enough after the leak occurred, so that your developer is still in front of their computer.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The developer generally knows what the credential gives access to, services and applications that rely on it, other developers who use it, etc. But they often don’t have the right to revoke the credentials and redistribute them.&lt;/li&gt;
&lt;li&gt;Application Security or “DevOps” personnel have the ability to inspect logs generated during the time the key was exposed, evaluate the way a potential hacker could have moved to other systems from this entry point, revoke the credentials and redistribute them.&lt;/li&gt;
&lt;li&gt;Threat Response will make sure that procedures are followed, in terms of investigation, remediation, internal communications, public relations, legal, lessons learned and feedback loop.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Remediate
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Integration with your remediation workflow
&lt;/h3&gt;

&lt;p&gt;It is quite obvious that the solution should be integrated with your preferred SIEM, ITSM, ticketing system or chat.&lt;/p&gt;

&lt;p&gt;One thing to keep in mind: if your organization is spread over multiple geographies / time zones, automatically associating a GitHub leak with a geography for incident dispatching purposes might not be always possible without first providing additional information to your vendor . This means that you will either have to provide your vendor with a list of your developers and their geographies, or indicate a single entry point that has global responsibilities for your vendor to alert you.&lt;/p&gt;

&lt;h3&gt;
  
  
  Collaboration with developers
&lt;/h3&gt;

&lt;p&gt;Potential damage can rarely be estimated just by looking at the code surrounding the leaked credential, and sensitive corporate credentials are often leaked on developers’ personal projects. When alerted about a GitHub leak, your first remediation step will always be to check whether or not the developer is still working in your company, and to reach out to them with a questionnaire to gather input for impact assessment and incident prioritization.&lt;/p&gt;

&lt;h2&gt;
  
  
  Log &amp;amp; Analyze
&lt;/h2&gt;

&lt;p&gt;Logging can answer multiple needs, depending of course on the data that is logged: post-incident analysis, reporting to management, demonstrating compliance to customers or auditors, security (audit trail), or transparency in what the solution is really doing.&lt;/p&gt;

&lt;p&gt;I’d like to briefly insist on this last point: ask your vendor for proof points! An ideal solution would provide a detailed list of every monitored developer and repository, as well as logs of every single commit that was analyzed, and reproducible results of conducted scans.&lt;/p&gt;

&lt;h1&gt;
  
  
  About GitGuardian
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Aq901_P3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/image-8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Aq901_P3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/image-8.png" alt="Solomon-Hykes-GitGuardian"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As the CEO of GitGuardian, I’m always extremely grateful for the time and trust that security professionals give us. We’ve built a sales organization that is thoroughly trained to behave with extreme respect and professionalism. &lt;strong&gt;This is how we sell cybersecurity software at GitGuardian:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No scare tactics.&lt;/li&gt;
&lt;li&gt;Since we’ve been monitoring GitHub for 3 years now, we can provide you with personalized data from your company’s perimeter. We aggregate the data to remove any sensitive content and in order for you to evaluate whether or not it is worth dedicating time to evaluate our solution.&lt;/li&gt;
&lt;li&gt;Consultative approach: we’ll come up with questions to help you evaluate your needs, and are always keen on sharing the technical details of what we do with your tech teams.&lt;/li&gt;
&lt;li&gt;Later in the sales process, we’ll show your security team the GitGuardian dashboard populated with actual data from your company.&lt;/li&gt;
&lt;li&gt;If we feel we’re not a good fit for your needs, we’ll let you know early in the process.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://gitguardian.com/contact?utm_source=blog&amp;amp;utm_medium=referral&amp;amp;utm_campaign=github_security"&gt;Contact us to protect your company from credentials leaking on GitHub&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>github</category>
      <category>security</category>
    </item>
    <item>
      <title>8 free security tools every developer should know and use to Shift Left</title>
      <dc:creator>Jean</dc:creator>
      <pubDate>Fri, 15 May 2020 12:44:19 +0000</pubDate>
      <link>https://dev.to/cuireuncroco/8-free-security-tools-every-developer-should-know-and-use-to-shift-left-561</link>
      <guid>https://dev.to/cuireuncroco/8-free-security-tools-every-developer-should-know-and-use-to-shift-left-561</guid>
      <description>&lt;p&gt;&lt;strong&gt;Shifting left is a development principle which states that security should move from the right (or end) of the software development life cycle (SDLC) to the left (the beginning). In other words: security should be integrated and designed into all stages of the development process. This new shift requires developers to take more ownership of security and security principles. The good news is that there are lots of tools available to help developers in this process.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this blog we will break up Application Security into key areas and walk through some free and open-source solutions that will help developers and organizations make sure, at every stage of their SLDC, the incremental changes they make improve the overall quality and security of their software.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uy7ThktJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/cartoon-securitytools-3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uy7ThktJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/cartoon-securitytools-3.png" alt="Shift-left-comic"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Shifting left may feel like adding extra work to a developer's already full plate, but in reality, it empowers developers to learn more about great security practices which results in less time spent fixing bugs and more time spent building great applications.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Application Security
&lt;/h2&gt;

&lt;p&gt;It is important to realize that all application security vulnerabilities cannot be fixed by a single product. Successful security requires a layered approach with many lines of defence for different stages of the SDLC.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Tyzsj_ZA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/flaxsdlc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Tyzsj_ZA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/flaxsdlc.png" alt="software-development-life-cycle"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The tools we will investigate cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SAST - Static Application Security Testing&lt;/li&gt;
&lt;li&gt;DAST - Dynamic Application Security Testing&lt;/li&gt;
&lt;li&gt;IAST - Integrated Application Security Testing&lt;/li&gt;
&lt;li&gt;RASP - Run-time Application Self Protection&lt;/li&gt;
&lt;li&gt;Dependency Scanning&lt;/li&gt;
&lt;li&gt;Secrets Detection &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While it is true that vulnerabilities picked up early are easier - and cheaper - to remediate, you cannot rely on finding all vulnerabilities during the early stages of the development. Security needs to be a concern throughout the entire SDLC.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8mTaQ-D9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/cycle-line-graph-10.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8mTaQ-D9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/cycle-line-graph-10.png" alt="security-remediation-cost-over-time"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--unHb-NjJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/SAST-3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--unHb-NjJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/SAST-3.png" alt="SAST"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Static Application System Testing&lt;/strong&gt; - also known as “white box testing”, is the most common and earliest category of automatic application security. SAST scans an application's source code to discover any known vulnerabilities. Because SAST does not require an application to be compiled or running to start detecting vulnerabilities (unlike DAST) it can be implemented very early in the SDLC.&lt;br&gt;
It also enforces coding guidelines and standards without executing the underlying code. This category of application testing has a wide variety of solutions available, so when deciding on using one, make sure the solution is well supported and maintained and works within your technology stack. Here are some of the best free SAST tools.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ajinabraham/nodejsscan"&gt;NodeJsScan&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QvRtDw8_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/RsjmdbuNrE1dn6Uc9sL-0lLAXHZKpP4YtL4NxeNp6q-6Ue_ebsipkCRa8Euwk9vy0zy86qMXvRmhALs-kFetUYtaVBe2k9AqMfcjf264X6dhqk15x4i6S-HnGLg_-y4LdPjVbqbF" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QvRtDw8_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/RsjmdbuNrE1dn6Uc9sL-0lLAXHZKpP4YtL4NxeNp6q-6Ue_ebsipkCRa8Euwk9vy0zy86qMXvRmhALs-kFetUYtaVBe2k9AqMfcjf264X6dhqk15x4i6S-HnGLg_-y4LdPjVbqbF" alt="nodejs-scan"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;NodeJs Scan has a command line interface for easy integration with DevSecOps CI/CD pipelines and produces results in JSON.&lt;br&gt;
A configuration file is available for each language which can be modified for customized searches. Overviews of files, as well as an entire codebase, can be visualized through stats and pie charts. The program can detect buffer overflows and flaws in Java code that may contain OWASP security risks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.sonarqube.org/"&gt;SonarQube&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iKcnl6BD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/image.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iKcnl6BD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/image.png" alt="sonar-qube"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Widely regarded as one of the best automated code review tools available in the market. SonarQube has thousands of automated Static Code Analysis rules. SonarQube also supports 27 languages which are a mix of both modern and legacy so that SonarQube can cover your entire project and its continuous development.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6CGOvJ36--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/DAST-2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6CGOvJ36--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/DAST-2.png" alt="dast"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dynamic Application Security Testing&lt;/strong&gt; - also known as “black box” testing, doesn’t find vulnerabilities in source code like SAST, instead it finds vulnerabilities in running applications. It does this by employing fault injection techniques on an app. DAST can identify common security vulnerabilities, such as &lt;a href="https://www.softwaresecured.com/introduction-to-sql-injection-mitigation/"&gt;SQL injection&lt;/a&gt; and cross-­site scripting. DAST can also cast a spotlight on runtime problems that can’t be identified by static analysis, like authentication and server configuration issues, as well as flaws visible only when a known user logs in.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.zaproxy.org/zap-in-ten/"&gt;OWASP ZAP&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OM94miva--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/image-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OM94miva--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/image-1.png" alt="OWASP"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;OWASP ZAP is a full-featured, free and open source DAST tool that includes both automated scanning for vulnerabilities and tools to assist expert manual web app pen testing. ZAP has a large &lt;a href="https://www.zaproxy.org/docs/alerts/"&gt;list of vulnerabilities&lt;/a&gt; that it can exploit and identify.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hA3VS9UM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/IAST-2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hA3VS9UM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/IAST-2.png" alt="IAST"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interactive Application Security Testing&lt;/strong&gt; - Which is also sometimes known as "grey box" testing, is technology that combines elements of both SAST and DAST simultaneously. It is typically implemented as an agent within the test runtime environment (for example, instrumenting the Java Virtual Machine [JVM] or .NET CLR) that observes operation or attacks and identifies vulnerabilities.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.contrastsecurity.com/contrast-community-edition"&gt;Contrast Security - Community&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--evaS4wUE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/image-2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--evaS4wUE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/image-2.png" alt="constrast-security"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Contrast is another developer-first product that is able to go deeper into vulnerabilities when compared to other SAST and DAST tools which are blind to the runtime context of applications such as the controller, application logic, data layer, presentation view, user libraries, open-source components, and application server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m_wrejrS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/RAST-3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m_wrejrS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/RAST-3.png" alt="rasp"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Runtime Application Self Protection&lt;/strong&gt; - is configured on a server and kicks in when an application runs. It's designed to detect attacks on an application in real-time. When the application begins to run, RASP can protect it from malicious input or behavior by analyzing both the app's behavior and the context of that behavior. By using the app to continuously monitor its own behavior, attacks can be identified and mitigated immediately without human intervention.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.sqreen.com/"&gt;Sqreen&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1AzjQTJ1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/ezgif-4-7713b596ff24.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1AzjQTJ1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/ezgif-4-7713b596ff24.gif" alt="sqreen"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sqreen’s Runtime Application Self-Protection identifies attacks that exploit vulnerabilities in production by leveraging the full execution context of requests. &lt;/p&gt;

&lt;p&gt;Sqreen covers all of the &lt;a href="https://owasp.org/www-project-top-ten/"&gt;OWASP top 10&lt;/a&gt; security vulnerabilities such as SQL injection, XSS and SSRF. What makes Sqreen so powerful is its ability to leverage the execution logic of requests to block attacks with much lower false positives than other solutions available. Sqreen also is able to adapt to your applications specific stack so you do not need any redeployment and configuration within your application making setup simple and fast.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GG20Mtz5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/DEPENDANCYSCANNING-2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GG20Mtz5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/DEPENDANCYSCANNING-2.png" alt="Dependency scanning"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dependency Scanning&lt;/strong&gt; helps to automatically find security vulnerabilities in your &lt;strong&gt;dependencies&lt;/strong&gt; while you are developing and testing your applications, for example when your application is using an external (open source) library which is known to be vulnerable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://snyk.io/product/"&gt;Snyk&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7nwCBvhB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ytimg.com/vi/4ng5usM6fd8/maxresdefault.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7nwCBvhB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ytimg.com/vi/4ng5usM6fd8/maxresdefault.jpg" alt="Snyk"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Snyk is a developer first organization with well maintained open-source solutions for developers and effective enterprise solutions available for larger organizations.&lt;/p&gt;

&lt;p&gt;Snyk has a range of great features that help make security part of the development process from day one such as the ability to detect vulnerabilities from within your IDE and native git scanning to test projects within the repositories. Snyk also provides a security gate to prevent new vulnerabilities from passing through the build process and a production environment to test your running environment to verify there is no exposure to existing vulnerabilities.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/apps/whitesource-bolt-for-github"&gt;WhiteSource Bolt for GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kcUruFfM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/image-5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kcUruFfM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/image-5.png" alt="WhiteSource"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;WhiteSource like Snyk has some great free tools for developers as well as large enterprise solutions for larger organizations. WhiteSource Bolt for GitHub is a FREE app, which continuously scans all your repos, detects vulnerabilities in open source components and provides fixes. It supports both private and public repositories.&lt;/p&gt;

&lt;p&gt;Over 200 programming languages are supported with continuous tracking of multiple open source vulnerabilities databases like the NVD.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AYQ-vMmZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/secret-detection.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AYQ-vMmZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/secret-detection.png" alt="Secrets detection"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Secrets like API keys, database credentials and security certificates are the crown jewels of organizations and can provide access to sensitive systems. Secrets detection scans source code, logs and other files for hidden secrets. This is a specialist service as most secrets are usually always high entropy strings (strings designed to appear random), but most high entropy strings are not secrets, which makes them very hard to detect. It requires advanced classification algorithms to detect secrets with &lt;a href="https://blog.gitguardian.com/secrets-detection-accuracy-precision-recall-explained/"&gt;high precision and recall&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Secrets detection is often confused with SAST because both scan through source code. Unlike SAST, which is concerned only with the current version of an application, secrets detection is concerned with the entire history of the project. Version control systems such as git, keep track and store all changes to an project. If previous versions of source code contains hard-coded secrets within, that were removed in late stages, code reviews and SAST tools will miss these secrets which may end up in a git repository and become compromised. This is why secrets detection is a category on its own.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gitguardian.com/developer"&gt;GitGuardian&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1Lg6zvxC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/GitGuardian-for-Internal-Repositories-Monitoring-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1Lg6zvxC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/05/GitGuardian-for-Internal-Repositories-Monitoring-1.png" alt="GitGuardian-dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GitGuardian’s technology works by scanning developers repositories for evidence of secrets.&lt;/p&gt;

&lt;p&gt;GitGuardian covers more than 300 different types of secrets from keys to database connection strings, SSL certificates, usernames and passwords. These  secrets are detected through a combination of algorithms, including sophisticated pattern matching techniques. GitGuardian can be integrated with your GitHub account and configured within minutes and developers can use the GitGuardian API to detect secrets in any services including within directories, email clients or Slack channels.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://dashboard.gitguardian.com/api/v1/auth/user/github_login/authorize?utm_source=blog&amp;amp;utm_medium=referral&amp;amp;utm_campaign=securitytools"&gt;Try GitGuardian, the best free security tool to find secrets in your code&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Wrap up
&lt;/h2&gt;

&lt;p&gt;With so many solutions available it can feel daunting to decide what tool to select within each category. Always consider how each tool fits into your current workflow as even great tools can be rendered useless if they become too difficult to use.&lt;/p&gt;

&lt;p&gt;Each application is different and the tools outlined above should be considered a minimum level of protection, but you and your organization may need more detailed solutions. Security is one of the most highly valued skills in a developer, although shifting security "left" can seem like a daunting task, it is a worthwhile investment to understand and implement these systems within your entire development life cycle.&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>security</category>
      <category>career</category>
    </item>
    <item>
      <title>Assessing model performance in secrets detection: accuracy, precision &amp; recall explained</title>
      <dc:creator>Jean</dc:creator>
      <pubDate>Wed, 06 May 2020 13:12:35 +0000</pubDate>
      <link>https://dev.to/cuireuncroco/assessing-model-performance-in-secrets-detection-accuracy-precision-recall-explained-3c02</link>
      <guid>https://dev.to/cuireuncroco/assessing-model-performance-in-secrets-detection-accuracy-precision-recall-explained-3c02</guid>
      <description>&lt;h1&gt;
  
  
  Detecting secrets in source code is like finding needles in a haystack: there are a lot more sticks than there are needles, and you don’t know how many needles might be in the haystack. In the case of secrets detection, you don’t even know what all the needles look like!
&lt;/h1&gt;

&lt;p&gt;This is the issue we are presented with when trying to evaluate the performance of probabilistic classification algorithms like secrets detection. This blog will explain why the accuracy metric is not relevant in the context of secrets detection, and will introduce two other metrics to be considered together instead: precision and recall.&lt;/p&gt;

&lt;p&gt;Accuracy, precision and recall metrics answer three very different questions:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Accuracy&lt;/strong&gt;: What percentage of times did you take a stick for a needle, and a needle for a stick?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Precision&lt;/strong&gt;: Looking at all the needles that you were able to find, what percentage are actually needles?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recall&lt;/strong&gt;: Among all needles that were to be found, what percentage of needles did you find?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MmXMuyEZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/EOJow2y5KEHd6BJSKFT-v9qAVXmcPKikf-hqQWoFrIyFbjnA7W-u21QpMU14nJ8FviAzNojvmPfUtEktCPF6zoam3C__iBVnS-7xZlAT-qF3wzeEwSm2OyowJ5tYK1xuEbRXwgHb" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MmXMuyEZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/EOJow2y5KEHd6BJSKFT-v9qAVXmcPKikf-hqQWoFrIyFbjnA7W-u21QpMU14nJ8FviAzNojvmPfUtEktCPF6zoam3C__iBVnS-7xZlAT-qF3wzeEwSm2OyowJ5tYK1xuEbRXwgHb" alt="Illustrating needles in a haystack"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why is accuracy not a good measurement of success for secrets detection?
&lt;/h2&gt;

&lt;p&gt;The difference is subtle in their descriptions but can make a huge difference.&lt;/p&gt;

&lt;p&gt;Going back to the needle analogy, if we take a group of 100 objects, 98 sticks and 2 needles then we create an algorithm to detect all the needles. After running, the algorithm identified all sticks correctly but only 1 needle, then this algorithm failed 50% of the time at its core objective, yet because it detected the sticks correctly it still has a 99% accuracy rate.&lt;/p&gt;

&lt;p&gt;So, what happened? Accuracy is a common measurement used in model evaluation, but in this case, accuracy gives us the least usable data, this is because there are a lot more sticks than there are needles in our haystack, and equal weight is applied to both false positives (the algorithm took a stick for a needle) and false negatives (the algorithm took a needle for a stick).&lt;/p&gt;

&lt;p&gt;This is why accuracy is not a good measurement to determine success in secrets detection algorithms. Precision and recall look at the algorithm's primary objective and use this to evaluate its success, in this case, how many needles were identified correctly and how many needles were missed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;High Precision&lt;/strong&gt; = low number of false alerts &lt;br&gt;
&lt;strong&gt;High Recall&lt;/strong&gt; =  low number of secrets missed&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jNWhlJxc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/jdVBss5Nbf8hpvAMTt-7c7AOaYzM25UqUQR3S129yVg-YXbbjLXH4KMydHEh5TE9vpKOlOiIyX8Wi9yJqG7b9zqarGp85WsBjEysvUVAmOIKXbzK-Dv5pdhmmCZH1xoD39QloVxH" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jNWhlJxc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/jdVBss5Nbf8hpvAMTt-7c7AOaYzM25UqUQR3S129yVg-YXbbjLXH4KMydHEh5TE9vpKOlOiIyX8Wi9yJqG7b9zqarGp85WsBjEysvUVAmOIKXbzK-Dv5pdhmmCZH1xoD39QloVxH" alt="Illustrating precision and recall"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;It is really easy to create an algorithm with 100% recall: flag every commit as a secret. It is also really easy to create an algorithm with 100% precision as well: flag only one time, for the secret you are the most confident it is indeed a secret. These two naive algorithms are obviously useless. It is combining both precision and recall that lies the challenge.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  So how can we properly evaluate the performance of a secrets detection model?
&lt;/h2&gt;

&lt;p&gt;Let’s take a hypothetical algorithm that scans 1,000 source code files for potential secrets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In this example we will state:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;975&lt;/strong&gt; files contained no secrets within the source code&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;25&lt;/strong&gt; files contained secrets within the source code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The algorithm detected&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;950 True Negatives (TN):&lt;/strong&gt; No secrets detected where no secrets existed&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;25 False Positives (FP):&lt;/strong&gt; Detected secrets that were not true secrets&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;15 True Positives (TP):&lt;/strong&gt; Detected secrets where secrets exist&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;10 False Negatives (FN):&lt;/strong&gt; Detected no secrets where secrets did exist&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This can be displayed on a &lt;a href="https://towardsdatascience.com/understanding-confusion-matrix-a9ad42dcfd62"&gt;confusion matrix&lt;/a&gt; (below) which is a performance measurement tool for classification algorithms to help visualize data and calculate probabilities.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X3Q0f5N---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh6.googleusercontent.com/BiYn1H8L47yjCXykAgN3fBD5-LbeUbzL_d91fLZ6mz5-o-H0n5ZVU0PnDF5o6cziG8lW6TrdYOgg-nxGTbFB5AbG_Zqlr4nafKDWAF5dcTNpvkxh4bcn_Y3ek8aWHBB-Vb9X0Ioq" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X3Q0f5N---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh6.googleusercontent.com/BiYn1H8L47yjCXykAgN3fBD5-LbeUbzL_d91fLZ6mz5-o-H0n5ZVU0PnDF5o6cziG8lW6TrdYOgg-nxGTbFB5AbG_Zqlr4nafKDWAF5dcTNpvkxh4bcn_Y3ek8aWHBB-Vb9X0Ioq" alt="Confusion matrix"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can use this matrix to gather a range of different data including accuracy, precision and recall.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1OTjzpvX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh5.googleusercontent.com/S1l9RDgpX5uaCdQaoYIzr1t3d3T41Ezym3ennIWPWIZSs65Cv6KTEyE0ldC7uyepUbykebpoQkqCiAk1IQC15X2ZObttT8qyREcVyvzGRxQG07dxc5XJoFybIlGJ0_GOVPo_Fn5u" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1OTjzpvX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh5.googleusercontent.com/S1l9RDgpX5uaCdQaoYIzr1t3d3T41Ezym3ennIWPWIZSs65Cv6KTEyE0ldC7uyepUbykebpoQkqCiAk1IQC15X2ZObttT8qyREcVyvzGRxQG07dxc5XJoFybIlGJ0_GOVPo_Fn5u" alt="Illustrating true VS false positives"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So what do these results show? We can extrapolate that our model has a 96.5% accuracy rate, this seems pretty good, and you may think that it means it detects secrets 96.5% of the time.&lt;/p&gt;

&lt;p&gt;This would be incorrect because this hypothetical model is really only beneficial for not detecting secrets that aren’t there. This is similar to an algorithm that's great at predicting car accidents that don’t happen.&lt;/p&gt;

&lt;p&gt;If we look at  metrics other than accuracy, we can see how this model begins to fail.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Precision = 40%&lt;br&gt;
Recall = 60%&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;All of a sudden, the model doesn’t seem to be beneficial. It only returns 60% of the secrets and only 40% of total returned secrets are true positives!&lt;/p&gt;

&lt;h2&gt;
  
  
  Balancing the equation: achieving a high precision, high recall secrets detection algorithm
&lt;/h2&gt;

&lt;p&gt;Balancing the equation to ensure that the highest possible number of secrets are captured without flagging too many false results is an intricate and extremely difficult challenge. &lt;/p&gt;

&lt;p&gt;So difficult that &lt;a href="https://gitguardian.com/"&gt;GitGuardian&lt;/a&gt; dedicated an entire team to train secrets detection algorithms and find the correct balance of high recall and high detection. &lt;/p&gt;

&lt;p&gt;This is essential when a precision that is too high may lead to secret leaks to go undetected, while a low precision will create too many false alerts, rendering the tool useless.&lt;/p&gt;

&lt;p&gt;There are no shortcuts when building and refining an algorithm. They need to be extensively trained with huge amounts of data and constant supervision.&lt;/p&gt;

&lt;p&gt;When talking about why some models fail, Scott Robinson from Lucina healths talks of three core failures when training an AI algorithm:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“&lt;a href="https://searchenterpriseai.techtarget.com/feature/Supervise-data-and-open-the-black-box-to-avoid-AI-failures"&gt;No1: Insufficient data&lt;/a&gt;,&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://searchenterpriseai.techtarget.com/feature/Supervise-data-and-open-the-black-box-to-avoid-AI-failures"&gt;No2: Insufficient supervision&lt;/a&gt;,&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://searchenterpriseai.techtarget.com/feature/Supervise-data-and-open-the-black-box-to-avoid-AI-failures"&gt;No3: Black box failures&lt;/a&gt;“.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(black box systems are those that are so complex they become impenetrable)&lt;/p&gt;

&lt;p&gt;It is important also to realize that when building algorithms for probabilistic scenarios, they will change over time. There is no perfect solution that can remain the same, trends will change, secrets will change, data will change, formats will change and therefore, your algorithm will need to change.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;“&lt;a href="https://searchsecurity.techtarget.com/feature/AI-Security-Alliance-urges-clarity-for-buying-AI-security-tools?src=6087888&amp;amp;asrc=EM_ERU_125469407&amp;amp;utm_medium=EM&amp;amp;utm_source=ERU&amp;amp;utm_campaign=20200330_ERU%20Transmission%20for%2003/30/2020%20(UserUniverse:%20744648)&amp;amp;utm_content=eru-rd2-control%E2%80%9D"&gt;People can create an algorithm, but the data really makes it useful&lt;/a&gt;” Kapil Raina&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  GitGuardian as an example
&lt;/h2&gt;

&lt;p&gt;GitGuardian is the world leader in secrets detection, which has been achieved largely due to the vast amount of information that has gone through the algorithm.&lt;/p&gt;

&lt;p&gt;Over 1 billion commits scanned and evaluated every single year with over 500k alerts that have been sent to developers and security teams. We’ve collected a lot of explicit (alert marked as true or false) and implicit (commit or repository deleted after our alert) feedback. It is a great example of how effective retraining of data, particularly at this large scale, can be used to continuously improve an algorithm's precision and recall.&lt;/p&gt;

&lt;p&gt;At the start in 2017, GitGuardian was detecting 200 secrets per day on GitHub, a benchmark set by other offerings on the market. With extensive model training, GitGuardian now detects over 3,000 per day with a 91% precision.&lt;/p&gt;

&lt;p&gt;There are no shortcuts in building algorithms. We’ve battle-tested our algorithms on public GitHub with billions of commits (yes billions), and these algorithms can now be used to detect secrets in private repositories as well. It would have been impossible to launch detection in private repositories without doing so on public GitHub first.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://dashboard.gitguardian.com/api/v1/auth/user/github_login/authorize?utm_source=blog&amp;amp;utm_medium=referral&amp;amp;utm_campaign=precisionrecall"&gt;=&amp;gt; Test out GitGuardian's automated secrets detection&lt;/a&gt;
&lt;/h2&gt;

</description>
      <category>precision</category>
      <category>recall</category>
      <category>algorithms</category>
      <category>secrets</category>
    </item>
    <item>
      <title>Using Git hooks for automated secrets detection</title>
      <dc:creator>Jean</dc:creator>
      <pubDate>Thu, 16 Apr 2020 12:46:14 +0000</pubDate>
      <link>https://dev.to/cuireuncroco/using-git-hooks-for-automated-secrets-detection-1i88</link>
      <guid>https://dev.to/cuireuncroco/using-git-hooks-for-automated-secrets-detection-1i88</guid>
      <description>&lt;h1&gt;
  
  
  Git hooks are extremely useful in the journey to replace as much of the human factor in the process of secure development as possible.
&lt;/h1&gt;

&lt;h2&gt;
  
  
  What are git hooks?
&lt;/h2&gt;

&lt;p&gt;Git hooks are scripts that are triggered by certain actions in the software development process, like committing or pushing. By automatically pointing out issues in code, they allow reviewers not to waste time on mistakes that can be easily diagnosed by a machine.  &lt;/p&gt;

&lt;p&gt;There are client-side hooks, that execute locally on the developers’ workstation, and server-side hooks, that execute on the centralized version control system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BEvhj1g7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/04/hook-graphic-4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BEvhj1g7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/04/hook-graphic-4.png" alt="git-hooks-explanation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are interested to explore further git hooks, here is a curation of the &lt;a href="https://github.com/aitemr/awesome-git-hooks"&gt;most useful git hooks on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why implement secret detection in your SDLC?
&lt;/h2&gt;

&lt;p&gt;As a general security principle, where feasible, data should remain safe even if it leaves the devices, systems, infrastructure or networks that are under organization control, or if these are compromised. Assuming a breach helps prevent lateral movement after a hacker gains initial access.&lt;/p&gt;

&lt;p&gt;In their everyday life, developers handle a trove of sensitive information that hackers could leverage. They rely on hundreds of secrets like API keys, database connection strings, private keys, or certificates to interconnect payment systems, databases, CRMs, messaging and notification systems, internal services… Too often, these secrets are hardcoded in source code or shared over Slack or emails. All these systems are not designed to store and share secrets, nor are internal wikis a good place to expose usernames and passwords.&lt;/p&gt;

&lt;p&gt;Indeed, because of the very nature of software development, source code is made to be cloned on different workstations, deployed on multiple servers, distributed to customers, etc. In practice, you never know where your code is going to end up. If it contains secrets, it takes just one of these places to be compromised for all the secrets to be compromised as well. Same reasoning holds for all developers having access to source code: it takes one compromised developer account to compromise all the secrets they have access to.&lt;/p&gt;

&lt;p&gt;On top of that, API keys and other secrets that are used to programmatically authenticate or authorize ourselves are unlike traditional usernames and passwords: because they are made to be programmatically used, they aren’t further secured by MFA (most of the time).&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-commit, pre-push, pre-receive, post-receive: where to implement secret detection?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Here are some general principles about fitting security in the software development process:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The earlier a security vulnerability is uncovered, the less costly it is to correct.&lt;/strong&gt; Hardcoded secrets are no exceptions. If the secret is uncovered after the secret reaches centralized version control server-side, it must be considered compromised, which requires to rotate (revoke and redistribute) the exposed credential. This operation can be complex and can involve multiple stakeholders.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;People bend the rules, often in an effort to collaborate better together and do their job&lt;/strong&gt;. Security must not be a blocker. It should allow flexibility and foster information flows, yet enable visibility and control. Security measures will be bypassed, sometimes for the worst. But it is also good sometimes that the developer can take the responsibility to bypass them. Talking about secrets detection: algorithms achieve a tradeoff between not raising false alerts (high precision) and not missing keys (high recall). Secrets detection being probabilistic, even the best algorithms can fail and need human judgement.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  These principles advocate for the following:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Client-side secrets detection early in the software development process is a nice to have:&lt;/strong&gt; implement pre-commit or pre-push hooks when possible. The good thing with pre-commits is that the secret is never added to the local repository, which comes in handy since removing a secret from your git history &lt;a href="https://blog.gitguardian.com/leaking-secrets-on-github-what-to-do/"&gt;can be very tricky&lt;/a&gt;. Whereas the good thing with pre-push is that you’ve got an Internet connection there, allowing you to make API calls for example. This is not necessarily the case when committing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Server-side secrets detection is a must have:&lt;/strong&gt; take into account that depending on the size of your organization, enforcing client-side secrets detection might not be an easy task, as this requires access to your developers’ workstations. We’ve heard many times from Application Security professionals that this is not something they felt confident to do. In any case, keep in mind that client-side hooks can (and must, secret detection being probabilistic) be easy to bypass, hence the absolute necessity for server-side checks where the ultimate threat lies.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Secret detection has one extremely important peculiarity though: unlike cryptography weaknesses or SQL injection vulnerabilities that only express themselves the moment the code is deployed, any secret reaching version control system must be considered compromised thus requiring immediate attention, even if the code is not ready to be deployed yet. This implies that implementing secrets detection is not only about scanning the most actual version of your master branch before deployment. It is also about scanning through every single commit of your git history, covering every branch, even development ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementing GitGuardian
&lt;/h2&gt;

&lt;p&gt;GitGuardian comes in the form of a dashboard centralizing policy breaks across your organization’s repositories.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0IzNCvdI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/04/image.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0IzNCvdI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/04/image.png" alt="GitGuardian-Dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is natively integrated with your Version Control System in a post-receive fashion. When integrating a repository into your monitored perimeter, secret detection is enforced on every branch, without making any distinction between development and master branches. At every push, GitGuardian not only scans actual source code as would be the case if we were looking at other security vulnerabilities such as vulnerable dependencies, but on top of that, we also go through every incremental change that was made since the last push.&lt;/p&gt;

&lt;p&gt;We also encourage you to run security checks early and often by using our API. Our API allows you to use our secrets detection as a service in pre-commits, pre-push, or in your CI (although CI builds aren’t typically enforced on all branches to scan every incremental change that was made). This would complement native integration with your Version Control System.&lt;/p&gt;

&lt;p&gt;At GitGuardian, we are always keen to share the technical details of what we do, and all the subtleties we found in our journey to automate secrets detection. We are committed to doing so,  even if it is not directly related to the objectives that we are trying to reach as a company. We do this in the spirit of Open Source, knowing that sharing technical details allows us to get more feedback from developers and Application Security professionals around the world, and ultimately create more value.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  &lt;a href="https://dashboard.gitguardian.com/api/v1/auth/user/github_login/authorize?utm_source=blog&amp;amp;utm_medium=referral&amp;amp;utm_campaign=githooks"&gt;Try GitGuardian, sign up with GitHub&lt;/a&gt;
&lt;/h1&gt;
&lt;/blockquote&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>security</category>
    </item>
    <item>
      <title>8 Steps to keep remote development teams secure</title>
      <dc:creator>Jean</dc:creator>
      <pubDate>Tue, 07 Apr 2020 13:45:44 +0000</pubDate>
      <link>https://dev.to/cuireuncroco/8-steps-to-keep-remote-development-teams-secure-3do5</link>
      <guid>https://dev.to/cuireuncroco/8-steps-to-keep-remote-development-teams-secure-3do5</guid>
      <description>&lt;h1&gt;
  
  
  There is no doubt that the world's workforce is becoming more remote, particularly in tech as developers can now work from any location in the world. But there are a large number of new obstacles that come with this. The most pressing is security.
&lt;/h1&gt;

&lt;p&gt;Take the current COVID-19 health crisis. From one day to the next, countries are going into quarantine and forcing companies  and developers into working remotely. I for one am writing this from my home office in Paris, sipping filter coffee while looking onto the empty streets in a complete lock-down that started last week.&lt;/p&gt;

&lt;p&gt;We are all trying to rapidly adjust to a new workflow from our makeshift workstations. As this crisis unfolds, we are seeing a drastic change in the remote infrastructure as it is pushed to its limit. This is creating an unprecedented security challenge that may not be a priority for many companies.&lt;/p&gt;

&lt;p&gt;I recently got an alert to say that Microsoft Teams, a platform to help manage remote workers and collaboration, crashed under the new pressure of millions of users. Likewise the video streaming company Zoom, which is now facing serious security breaches, went from 10 million daily users in December to 200 million daily users in March! These are obvious signs of the strain we are putting on digital infrastructure as this crisis unfolds. Teams that are only  familiar with being centralized on a secure network, are now at home on a private WiFi network trying their best to keep websites, services, platforms and apps functioning.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--htPQIqBh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh5.googleusercontent.com/y86jjt40266rFgw3-oFSGHGG9nKVWKhchy0LQvlGQiJFAsrEPy3x9bi6dwfyaNkz8i6djJXRunVFEAVKOGwyYhC1eaCK-URusx6i6q_Q1aD97Isc2oCmDe_0QIvla1XOKQw3cby0" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--htPQIqBh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh5.googleusercontent.com/y86jjt40266rFgw3-oFSGHGG9nKVWKhchy0LQvlGQiJFAsrEPy3x9bi6dwfyaNkz8i6djJXRunVFEAVKOGwyYhC1eaCK-URusx6i6q_Q1aD97Isc2oCmDe_0QIvla1XOKQw3cby0" alt="Downdetecter"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Image taken from Downdetecter, 16 March 2020&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why does remote work present a security risk?
&lt;/h2&gt;

&lt;p&gt;Remote working is not necessarily less secure, if done right.  It is  extremely important for remote teams to have operational frameworks and tools in place to deal with the challenges that are unique to remote teams. Especially when it comes to issues as urgent as security.&lt;/p&gt;

&lt;p&gt;If you make secret management too painful for developers, it becomes all too tempting to circumvent the restrictions. Now let's add to this balancing act different geographies, time zones and unreachable co-workers. The temptation to send a secret over Slack, email or to quickly hardcode secrets into the source code becomes increasingly hard to resist.&lt;/p&gt;

&lt;p&gt;In addition to internal operational control, we must now also consider external factors, such as unsecured personal wifi-networks and personal machines. These all add to the potential of secrets being leaked into unsecured locations.&lt;/p&gt;

&lt;p&gt;The once clear delineation between personal and professional activity suddenly becomes blurred when you are sharing a single machine and mixing personal git repositories with professional repositories. You can easily find yourself in the worst case (yet common) scenario of mistakenly uploading secrets and corporate code into personal repositories. All these factors combined increases the attackable area of the organization, when secrets that were once secured to a central location are now sprawled across multiple platforms and tools.&lt;/p&gt;

&lt;p&gt;Unsecured messaging systems like Slack and email are known to be high-value targets for attackers through phishing campaigns. Once an attacker has admin access to your company's Slack, they are a simple search away from gaining access to your sensitive information. The normal conditions that could help identify an external threat also begin to unravel, as IP addresses of all developers can change daily. Currently, the number of reported phishing campaigns has drastically increased with the COVID-19 crisis unfolding as attackers piggy-back onto public panic.  &lt;/p&gt;

&lt;h2&gt;
  
  
  8 steps to making remote work more secure for development teams
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Get visibility over secrets shared in your repositories
&lt;/h3&gt;

&lt;p&gt;Repositories are not appropriate places to store secrets, it is important that you have complete visibility of not only public repositories but also of your private repositories. Having secrets in private repositories:;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;increases the chances of a secret ending up on a public repository.&lt;/li&gt;
&lt;li&gt;Perhaps more importantly though, now that employees are increasingly working from home, it is more likely company code will end up on unsecured personal workstations or be transiting through unsecured networks, meaning secrets within that source code could be accessible by a malevolent actor.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We recommend signing up to GitGuardians Internal Repository Monitoring to scan your repositories. The tool is free for small teams and will allow you to scan your git history for secrets while continuously scanning incremental changes as well.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Establish best practices sharing sensitive information
&lt;/h3&gt;

&lt;p&gt;For a helpful guide on best practices for securing and sharing API keys, you can check out a GitHub cheatsheet here. It’s a great document to share with your staff to make sure they are using the best practices.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Know how to remediate compromised credentials
&lt;/h3&gt;

&lt;p&gt;Make sure the steps on how to revoke a credential for each external service is documented along with the impact revoking each credentials will have. You can find here an article about revoking and removing compromised credentials&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Invest in multi-factor authentication on all services.
&lt;/h3&gt;

&lt;p&gt;2 factor authentication improves security drastically when it comes to services and assets you want to protect. Make sure 2FA is set up on all “Seed” accounts like company emails. (A seed account is an account that can grant access to other services. Email and social media accounts are examples of seed accounts, “log in with Gmail”).&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Work towards implementing a Zero Trust framework
&lt;/h3&gt;

&lt;p&gt;Depending on the organization it may be appropriate to implement a Zero Trust framework beyond multi-factor authentication. Complete implementation is always a process and a considerable investment but introducing additional Zero Trust measures like SSO and introducing policies to block/limit/approve access decisions to enterprise resources can strengthen security significantly, particularly for remote teams.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Encourage a culture of self education
&lt;/h3&gt;

&lt;p&gt;By providing clear and basic information, including how to protect their devices, will help you and employees stay ahead of threats.&lt;/p&gt;

&lt;p&gt;Remote workers have access to data, information, and your network. This increases the temptation for bad actors. Warn your employees to expect more phishing attempts, including targeted spear phishing aimed at high profile credentials. Now is a good time to be diligent, so watch out for urgent requests that break company policy, use emotive language and have details that are slightly wrong and provide guidance on where to report those suspicious messages.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Practice good security hygiene
&lt;/h3&gt;

&lt;p&gt;Good security practices always go back to basics. Practicing good security hygiene means to rotate vulnerable access credentials regularly and to restrict permissions associated with your keys with role-based access controls.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Be prepared for a breach
&lt;/h3&gt;

&lt;p&gt;Regardless of whether your team is working remotely or not, it is important to have an action plan in place in case secrets get shared. Make sure the whole team understands what that plan is and implement a culture of open, transparent communication.&lt;/p&gt;

&lt;p&gt;We are certainly facing difficult times that are bringing new challenges at record speeds. It is unfortunate that while we are adapting, there are people out there that are using this as an opportunity to exploit us. GitGuardian is, and always will be free for developers and small teams so if you are working with a remote team, consider implementing the free tools GirGuardian have to allow you to continue thriving during the times ahead.&lt;/p&gt;

&lt;h1&gt;
  
  
  👉&lt;a href="https://dashboard.gitguardian.com/api/v1/auth/user/github_login/authorize/?utm_source=dev.to&amp;amp;utm_medium=referral&amp;amp;utm_campaign=remote"&gt;Try GitGuardian | automated secret detection&lt;/a&gt;
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Free 0$/month&lt;br&gt;
Monitor your public activity anywhere on GitHub&lt;br&gt;
Real-time alerting by email&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;article originally published on GitGuardian's blog: &lt;a href="https://blog.gitguardian.com/8-steps-to-keep-remote-work-secure/"&gt;8 Steps to keep remote development teams secure&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Exposing secrets on GitHub: What to do after leaking credentials and API keys</title>
      <dc:creator>Jean</dc:creator>
      <pubDate>Wed, 25 Mar 2020 14:00:10 +0000</pubDate>
      <link>https://dev.to/cuireuncroco/exposing-secrets-on-github-what-to-do-after-leaking-credentials-and-api-keys-39ml</link>
      <guid>https://dev.to/cuireuncroco/exposing-secrets-on-github-what-to-do-after-leaking-credentials-and-api-keys-39ml</guid>
      <description>&lt;h1&gt;
  
  
  As a developer, if you have discovered that you have just exposed a sensitive file or secrets to a public git repository, there are some very important steps to follow.
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;What is a secret? In this document when we use the term secret, we are referring to anything that is used to authenticate or authorize ourselves, most common are API keys, database credentials or security certificates.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The first step, breathe: in most circumstances, if you follow this guide carefully, it will only take a few minutes for you to nullify most of the potential damage. This post will go through the four steps needed to remove the risk and make sure it doesn't happen in the future.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Revoke the secret or credentials&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;2. (Optional) Permanently delete all evidence of the leak&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;3. Check access logs for intruders&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;4. Implement future tools and best practices&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  If I delete the file or repository then I’m safe right?
&lt;/h2&gt;

&lt;p&gt;Unfortunately, no. If you make the repository private or delete the files you can reduce the risk of someone new discovering your leak but the reality is that it is very likely your files will still exist for those that know where to look. Git keeps a history of everything you do, so even if you delete the file, it will still exist in your git history. Even making the repository private, deleting your history or even deleting the entire repository, your secrets are still compromised.&lt;/p&gt;

&lt;p&gt;There are easy ways to monitor public git repositories, for instance, GitHub has a public API where you can monitor every single git commit that is made. That means that anyone can (and they do) monitor this API to find credentials and sensitive information within repositories. For this reason it is best to assume that if you have leaked a secret, it is compromised forever.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Leaking secrets onto GitHub and then removing them, is like accidentally posting an embarrassing tweet, deleting it and just hoping no one saw it or took a screenshot.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Step 1. Revoke the secret and remove the risk
&lt;/h2&gt;

&lt;p&gt;The first thing we need to do is make sure that the secret you have exposed is no longer active so no one can exploit it.&lt;/p&gt;

&lt;p&gt;If you need specific advice on how to revoke keys you can see instructions within our &lt;a href="https://github.com/GitGuardian/APISecurityBestPractices/blob/master/Leak%20Mitigation%20Checklist.md#2-advice-specific-to-a-key"&gt;API Best Practices Document&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If this key belongs to an organization you work for then it is important to speak to the senior developers at your organization. It can be scary to let your company know you have leaked sensitive information, particularly if it has happened on a personal repository. But honesty is the best approach, it is possible the company has already discovered the leak, mistakes can be forgiven if the problem is resolved and you genuinely care.&lt;/p&gt;

&lt;p&gt;Don’t hope that the problem will go away - mistakes happen and it is best to simply be honest and upfront.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Did you know?&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Slack keys are among the rare API tokens that have the ability to autorevoke themselves! As simple as using the auth.revoke endpoint!&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2. (Optional) Get rid of the evidence
&lt;/h2&gt;

&lt;p&gt;Once the secret has been revoked, it cannot be used anymore. Nonetheless, having any credential, even an expired one, could look unprofessional and raise concerns. Additionally, there are some secrets that cannot be revoked (for example database records), or credentials no one can guarantee were properly revoked (for example, SSH keys that can be used in many different places). So we will go through the steps of how to remove history of it, please note that this is not a trivial task and it is advised to seek the guidance of a senior developer.&lt;/p&gt;

&lt;h3&gt;
  
  
  a. Either delete your repository or make it private
&lt;/h3&gt;

&lt;p&gt;It is often a good idea to buy yourself some time first: navigate to your GitHub repository then click "&lt;strong&gt;Settings&lt;/strong&gt;".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cRuulWxT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/03/steps_data_breach_settings-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cRuulWxT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/03/steps_data_breach_settings-1.png" alt="GitHub-setting"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, all the way down to the "Danger Zone" and click "Make Private" to hide the repository from the public.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qjIlKUa5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/03/steps_data_breach_private.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qjIlKUa5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/03/steps_data_breach_private.png" alt="GitHub-Danger-Zone"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: if you may wish to make a backup then click on "Delete this repository". You will push it back later.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eUUjnI7O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/03/steps_data_breach_delete.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eUUjnI7O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.gitguardian.com/content/images/2020/03/steps_data_breach_delete.png" alt="GitHub-Delete-Repository"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can push the repository back later.&lt;/p&gt;

&lt;h3&gt;
  
  
  b. Rewrite git history
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ Warning Before jumping in, be advised that rewriting .git history is not a trivial act, especially if there are many developers contributing to your repository. You will either have to completely delete the repository then push the cleaned version back, or git push --force to your initial repository. In either cases, you’ll completely break other contributing developers’ workflow.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We are going to use the well-known &lt;a href="https://rtyley.github.io/bfg-repo-cleaner/"&gt;BFG Repo-Cleaner&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The BFG is a simpler, faster (10 - 720x faster) alternative to git-filter-branch for cleansing bad data out of your Git repository&lt;/p&gt;

&lt;p&gt;Let's suppose you committed a sensitive file called &lt;strong&gt;config.py&lt;/strong&gt; and this contains a secret key.&lt;/p&gt;

&lt;h4&gt;
  
  
  i. Make sure you have java installed.
&lt;/h4&gt;

&lt;h5&gt;
  
  
  ii. Clone your repository
&lt;/h5&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone &lt;a href="https://github.com/YOUR-USER-NAME/YOUR-REPOSITORY.git"&gt;https://github.com/YOUR-USER-NAME/YOUR-REPOSITORY.git&lt;/a&gt;&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  iii. Delete the Sensitive file&lt;br&gt;
&lt;/h4&gt;

&lt;p&gt;The very latest commit on your current branch is protected by BFG so you have to make sure it is clean. Delete "config.py" and commit your changes&lt;/p&gt;

&lt;p&gt;Branches different from the current one are not protected so if "config.py" can be found on other branches, it will be cleaned by BFG&lt;/p&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit -m "clean commit"&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  iv. Run BFG&lt;br&gt;
&lt;/h4&gt;

&lt;p&gt;Download the latest version of BFG from their website, move the java file into your repository and run the command below&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note:replace bfg-VERSION with the latest version (bfg-1.13.0)&lt;/em&gt;&lt;/p&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java -jar bfg-VERSION.jar YOUR-REPOSITORY/.git --delete-files "config.py"&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  vi. Check your history.&lt;br&gt;
&lt;/h4&gt;

&lt;p&gt;You can use the log - p command to show the difference (called a "patch") introduced in each commit. If you navigate through your different branches, you should see that everything is fine.&lt;/p&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git log -p &lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  vii. Push your repository back&lt;br&gt;
&lt;/h4&gt;

&lt;p&gt;Create a new repository and push it back. Make sure everybody deleted old clones and is using your new version.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Did you know?&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Even though git prevents you overwriting the central repository’s history by rejecting non-fast forward push requests, you can still push changes using the --force flag. This forces your remote branch to match your local one. Be careful though, this is a dangerous command!&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Check your access logs!
&lt;/h3&gt;

&lt;p&gt;This is very important depending on the keys that were leaked. Sometimes when one access key leaks it creates a domino effect and leads to exposing new secrets. For example, an access key to Slack may give a bad actor access to messages containing new credentials and access codes so very important to make sure that there is no suspicious data!&lt;/p&gt;

&lt;p&gt;Checking access logs really depends on the type of credential that was leaked. For example, AWS logs are sometimes centralized into Cloudwatch. Slack has a dedicated API endpoint  that allows access to audit logs. This is probably a good moment for you to get closer to your SRE or Application Security team to make sure everything’s fine!&lt;/p&gt;

&lt;h2&gt;
  
  
  What now?
&lt;/h2&gt;

&lt;p&gt;So the credential has been revoked, the repositories history has been cleaned. What should I do now? Now you have had a good scare, it is a good time to start to implement some good practices.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Get Protected with GitGuardian
&lt;/h3&gt;

&lt;p&gt;GitGuardian is a good guy service that scans every single GitHub commit in public repositories in real-time for leaks.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://dashboard.gitguardian.com/auth/signup"&gt;Sign up to GitGuardian&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  2. Review API Best Practices
&lt;/h3&gt;

&lt;p&gt;To better protect your secrets in the future we advise that you look at our &lt;a href="https://github.com/GitGuardian/APISecurityBestPractices/blob/master/Good%20development%20practices.md"&gt;API Best practice guide&lt;/a&gt;. It has lots of helpful tips on how to make sure you don't accidentally leak secrets in the future.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Author's note: this post was originally written on &lt;a href="https://blog.gitguardian.com/leaking-secrets-on-github-what-to-do/"&gt;GitGuardian's blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Automatically detect secrets in your internal repos</title>
      <dc:creator>Jean</dc:creator>
      <pubDate>Wed, 19 Feb 2020 10:44:19 +0000</pubDate>
      <link>https://dev.to/cuireuncroco/automatically-detect-secrets-in-your-internal-repos-48of</link>
      <guid>https://dev.to/cuireuncroco/automatically-detect-secrets-in-your-internal-repos-48of</guid>
      <description>&lt;h1&gt;
  
  
  At GitGuardian, we’ve been monitoring every single commit pushed to public GitHub since July 2017. 2.5 years later, we’ve sent over 500k alerts to developers.
&lt;/h1&gt;

&lt;p&gt;API keys, database connection strings, private keys, certificates, usernames and passwords, … As organizations embrace the power of cloud architectures, SaaS integrations and microservices, developers handle increasing amounts of sensitive information,  more than ever before.&lt;/p&gt;

&lt;p&gt;To add to that, companies are pushing for shorter release cycles to keep up with the competition, developers have many technologies to master, and the complexity of enforcing good security practices increases with the size of the organization, the number of repositories, the number of developer teams and their geographies…&lt;/p&gt;

&lt;p&gt;As a result, secrets are spreading across organizations, particularly  within the source code. This pain is so huge that it was even conceptualized under the name &lt;em&gt;“secret sprawl”.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;After months of product iteration with security teams and developers, we’re now proud to officially introduce GitGuardian for internal repositories!&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Credentials in private repositories: how much should you care?
&lt;/h2&gt;

&lt;p&gt;Secrets stored in Version Control Systems is the current state of the world, yet VCSs are not a suitable place to store secrets for the following reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Everyone who has access to the source code has access to the secrets it contains. This often includes too many developers. It would just take a single compromised developer’s account to compromise all the secrets they have access to!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You never know where your source code is going to end up. Because of the very nature of the git protocol, versioned code is made to be cloned in multiple places. It could end up on a compromised workstation, be inadvertently exposed on public GitHub, or released to customers.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Storing secrets in source code is a bit like storing unencrypted credit card numbers, or usernames and passwords in a Google Doc shared within the organization: good friends would not let you do this!&lt;/p&gt;

&lt;h2&gt;
  
  
  As a developer or security professional, what should I do after a secret was pushed to a centralized version control?
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Every time I see a secret pushed to the git server, I consider it compromised...From one developer to another :)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When a secret reaches centralized version control, it is always a good practice to revoke it. At this point, depending on the size of your organization, remediating is often a shared responsibility between Development, Operations and Application Security teams.&lt;/p&gt;

&lt;p&gt;Indeed, you might need some special rights and approval to revoke the secret, some secrets might be harder to revoke than others, plus you must make sure that the secret is properly rotated and redistributed without impacting your running systems.&lt;/p&gt;

&lt;p&gt;Apart from that, depending on your organization’s policies, you might want to clean your git history as well. This will require a ‘git push --force’, which comes with some risks as well, so there is definitely a tradeoff to consider, with no correct answer!&lt;/p&gt;

&lt;p&gt;(Hint: if your secret is buried deep in your code, &lt;a href="https://rtyley.github.io/bfg-repo-cleaner/"&gt;BFG Repo-Cleaner&lt;/a&gt; is a great Open Source project to help you get rid of it without having to use the intimidating ‘git-filter-branch’ command. Plus it is in Scala! We have &lt;a href="https://github.com/rtyley"&gt;Roberto Tyley&lt;/a&gt; to thank for this.)&lt;/p&gt;

&lt;h2&gt;
  
  
  When should I do secret detection?
&lt;/h2&gt;

&lt;p&gt;With the nature of git comes a unique challenge: whereas most security vulnerabilities only have the potential to express themselves in the actual (and deployed) version of your source code, old commits can contain valid secrets, including deleted secrets that subsequently went unnoticed during code reviews.&lt;/p&gt;

&lt;p&gt;First, you want to make sure that you start on a clean basis by scanning existing code repositories in depth.&lt;/p&gt;

&lt;p&gt;Then, you want to continuously scan all incremental changes, ie every new commit in every branch of every repository.&lt;/p&gt;

&lt;p&gt;When to do incremental scanning?&lt;/p&gt;

&lt;p&gt;In his presentation about &lt;a href="https://speakerdeck.com/sebsto/automatisez-la-securite-de-vos-architectures-cloud-avec-le-devsecops-99e065c2-256d-45d4-8d7d-5552204622b2?slide=2"&gt;“Improving your Security Posture with the Cloud”&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/sebastienstormacq/"&gt;Sébastien Stormacq&lt;/a&gt;, Developer Evangelist @ AWS, advocates to implement security checks post-event in every case, and pre-event when possible.&lt;/p&gt;

&lt;p&gt;We at GitGuardian share Sébastien's views. You should always implement automated secrets detection server side, in your CI/CD for example or via a native integration with GitHub / GitLab / Bitbucket repositories. Also, it is good to encourage your fellow developers to implement pre-commit hooks, but we  often hear that this is hardly scalable across an entire organization.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it out!
&lt;/h2&gt;

&lt;p&gt;Our product will allow you to scan existing code as well as incremental changes, and benefit from secrets detection algorithms that were battle-tested at scale on the whole public GitHub activity for over two years! GitGuardian has a native integration with GitHub (GitLab and Bitbucket coming soon), and there is an on prem version available.&lt;/p&gt;

&lt;p&gt;We offer a free version of our solution for individual developers and Open Source organizations, as well as a free trial for companies that you can access in SaaS here: &lt;br&gt;
&lt;a href="https://dashboard.gitguardian.com/auth/signup?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=prm_launch"&gt;https://dashboard.gitguardian.com/auth/signup&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>security</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
