<?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: Cisco DevNet</title>
    <description>The latest articles on DEV Community by Cisco DevNet (@cisco-devnet).</description>
    <link>https://dev.to/cisco-devnet</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%2Forganization%2Fprofile_image%2F7660%2F9ecc7ff2-c123-4401-b271-ec8f2b27160e.png</url>
      <title>DEV Community: Cisco DevNet</title>
      <link>https://dev.to/cisco-devnet</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cisco-devnet"/>
    <language>en</language>
    <item>
      <title>Automate identification of uncommon DNS requests with Cisco Umbrella API</title>
      <dc:creator>Erika Dietrick</dc:creator>
      <pubDate>Fri, 22 Mar 2024 18:25:37 +0000</pubDate>
      <link>https://dev.to/cisco-devnet/automate-identification-of-uncommon-dns-requests-with-cisco-umbrella-api-gm7</link>
      <guid>https://dev.to/cisco-devnet/automate-identification-of-uncommon-dns-requests-with-cisco-umbrella-api-gm7</guid>
      <description>&lt;p&gt;Many corporate networks are processing massive amounts of internet traffic, which poses a monitoring and security challenge:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;With so much activity, how do we know what should be investigated?&lt;/li&gt;
&lt;li&gt;Better yet... how can we &lt;em&gt;proactively&lt;/em&gt; identify internet traffic that is worth investigation &lt;em&gt;before&lt;/em&gt; there's a security incident?&lt;/li&gt;
&lt;li&gt;And most importantly... &lt;em&gt;can we automate this?&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We answer all of these questions for Cisco Umbrella users in this article. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Not an Umbrella customer? Check out our &lt;a href="https://devnetsandbox.cisco.com/DevNet/catalog/umbrella-secure-internet-gateway"&gt;always-on sandbox&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;What is Cisco Umbrella?&lt;/li&gt;
&lt;li&gt;
Generating an Umbrella Admin API Key
&lt;ul&gt;
&lt;li&gt;Securely using the API Key and Key Secret&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
Planning our script

&lt;ul&gt;
&lt;li&gt;Authenticating with Umbrella API&lt;/li&gt;
&lt;li&gt;Umbrella Reports API&lt;/li&gt;
&lt;li&gt;Leveraging Umbrella's global usage data&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
Filtering and formatting files for comparison

&lt;ul&gt;
&lt;li&gt;Cleaning up our top_destinations.csv file&lt;/li&gt;
&lt;li&gt;Cleaning up the Top 1-Million CSV file&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Finding uncommon domains&lt;/li&gt;
&lt;li&gt;Removing old files&lt;/li&gt;
&lt;li&gt;Running the script&lt;/li&gt;
&lt;li&gt;Cisco DevNet sample code&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What is Cisco Umbrella? &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fews3l4oap7k26howhmvg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fews3l4oap7k26howhmvg.png" alt="A portion of the Umbrella dashboard displaying Activity Search" width="800" height="525"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're unfamiliar with Umbrella, we colloquially refer to it as "internet security" or DNS security. While all Umbrella packages allow you to create DNS policies and access a variety of reports on your network's internet activity, other packages have additional features ranging from web policy to data loss prevention (DLP) policy to the Investigate API (proactive threat research).&lt;/p&gt;

&lt;p&gt;The image above shows a small snippet of the Umbrella interface, in which I navigated to the Activity Search. (This is because I had just configured Umbrella, so my dashboard of the past 24 hours was empty.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Generating an Umbrella Admin API Key &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;In the leftside menu, navigate to Admin &amp;gt; API Keys.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqd2u8k29k7oomgefbcdm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqd2u8k29k7oomgefbcdm.png" alt="The Umbrella navigation menu with API Keys highlighted" width="279" height="628"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the top right corner of the screen, you should then see a circular Add button. Click that, then fill out the information for creating a new Admin API Key.&lt;/p&gt;

&lt;p&gt;The photo below provides an example of how to fill this out. What's important is that you can choose the correct scope (Reports &amp;gt; Aggregations: Read-Only) and that you choose an expiration date that isn't today.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffrahbp9vqx8nrxfc3bca.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffrahbp9vqx8nrxfc3bca.png" alt="Admin API Key creation form" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you've filled out the form above, click the Create Key button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyz88r3qk7ypnrso81djb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyz88r3qk7ypnrso81djb.png" alt="Generated Admin API Key and Key Secret" width="800" height="192"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You'll now see an API Key and Key Secret, as shown above. Copy both of these -- they will only be displayed once.&lt;/p&gt;

&lt;h3&gt;
  
  
  Securely using the API Key and Key Secret &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;We'll need the API Key and Key Secret we just generated in order to communicate with Umbrella; but if we're using a version-controlled repository, hardcoding those credentials into the script and pushing them to the repository will expose our sensitive credentials to others.&lt;/p&gt;

&lt;p&gt;While you can secure credentials in multiple ways, we'll create a .env file to store them in.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;API_KEY=apikeygoeshere
KEY_SECRET=keysecretgoeshere
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, to ensure this .env file is not pushed to our repository, we'll create a .gitignore file using this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch .gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the .gitignore file is created, we'll add the name of any files we want to be ignored inside the file -- in this case, only .env.&lt;/p&gt;

&lt;p&gt;Finally, our script will need to access these credentials despite the fact that they aren't hardcoded into the script. &lt;/p&gt;

&lt;p&gt;In Python, we'll include the following import statements to accomplish this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os
from dotenv import load_dotenv 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, we'll load the credentials into the script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;load_dotenv()

# Environmental variables should contain your org's values in .env file.
client_key = os.environ['API_KEY']
client_secret = os.environ['KEY_SECRET']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Planning our script &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Okay, so now we have an API Key and Key Secret from which we can retrieve DNS traffic from Umbrella. Now, we have 3 questions to answer: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What's required to authenticate with the Umbrella API? &lt;/li&gt;
&lt;li&gt;Which API call should we be making to Umbrella?&lt;/li&gt;
&lt;li&gt;How can we sift through the DNS traffic to determine what is "uncommon"?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Authenticating with Umbrella API &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Authentication with any Umbrella API requires not just an API Key and Key Secret (which we generated earlier), but an &lt;a href="https://developer.cisco.com/docs/cloud-security/#!authentication/generate-an-api-access-token"&gt;access token&lt;/a&gt;, which expires after 1 hour. &lt;/p&gt;

&lt;p&gt;In Python, we'll first need to import the requests library to make an API call:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import requests
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, we write a function that generates an access token using the correct API endpoint. Because we'll run this script on a weekly basis, but the access token only lasts an hour, we'll make sure we call this function first each time the script runs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Relevant v2 Umbrella API endpoints
base_url = "https://api.umbrella.com"
access_token_endpoint = f"{base_url}/auth/v2/token"

# Generate new access token as these expire after 1 hour. Requires a valid and unexpired Umbrella API Key and Key Secret.
def generate_access_token():

    response = requests.post(url=access_token_endpoint,auth=(client_key,client_secret))
    access_token = response.json()['access_token']

    return access_token
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Umbrella Reports API &lt;a&gt;
&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;By reviewing the &lt;a href="https://developer.cisco.com/docs/cloud-security/#!authentication"&gt;Umbrella API documentation&lt;/a&gt;, we see that using the &lt;a href="https://developer.cisco.com/docs/cloud-security/#!reporting-overview/reporting"&gt;Reports API&lt;/a&gt; will retrieve information about the traffic coming through the Umbrella network; specifically, the &lt;a href="https://developer.cisco.com/docs/cloud-security/#!reporting-api-reference-api-top-destinations-top-destinations"&gt;getTopDestinations&lt;/a&gt; endpoint.&lt;/p&gt;

&lt;p&gt;We'll first create a variable for the Top Destinations endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Relevant v2 Umbrella API endpoints
base_url = "https://api.umbrella.com"
access_token_endpoint = f"{base_url}/auth/v2/token"
top_destinations_endpoint = f"{base_url}/reports/v2/top-destinations"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we define the headers and parameters (as defined in the API documentation) before making the Top Destinations API call:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Get the Top Destinations visited from 7 days ago until now. Top 1000 domains are returned.
def get_top_destinations(access_token):  

    headers = {
    "Authorization": "Bearer " + access_token,
    "Content-Type": "application/json",
    "Accept": "application/json"
    } 

    params = {
        "from": "-7days",
        "to": "now",
        "offset": "0",
        "limit": 1000
    }

    top_destinations_request = requests.get(top_destinations_endpoint, headers=headers,params=params)
    top_destinations = top_destinations_request.json()

    return top_destinations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll notice that we've set parameters to pull Top Destinations from 7 days ago until now. (Specifying &lt;em&gt;now&lt;/em&gt; is a supported option based on documentation.)&lt;/p&gt;

&lt;h3&gt;
  
  
  Leveraging Umbrella's global usage data &lt;a&gt;
&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The best way to determine what is abnormal or uncommon? Find a way to establish a baseline or "normal." &lt;/p&gt;

&lt;p&gt;Fortunately, Umbrella posts a &lt;a href="https://s3-us-west-1.amazonaws.com/umbrella-static/index.html"&gt;Popularity List&lt;/a&gt; daily. According to Cisco Umbrella, this list "contains our most queried domains based on passive DNS usage across our Umbrella global network of more than 100 Billion requests per day with 65 million unique active users, in more than 165 countries."&lt;/p&gt;

&lt;p&gt;1-million of the most commonly queried domains should be a sufficient baseline of "normal." &lt;/p&gt;

&lt;p&gt;We'll make a GET API call to retrieve the Umbrella Top 1-Million. (Yes, I'm realizing now I should have stored the URL in a variable to be consistent.)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Download the Umbrella top 1 million destinations, unzip file, format file. 
def get_top_million():

    # API call to get Umbrella Top 1 Million as a zip file
    get_top_1million_zip = requests.get("http://s3-us-west-1.amazonaws.com/umbrella-static/top-1m.csv.zip")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function isn't yet complete. Let's discuss what else needs to be considered before we finish this function. &lt;/p&gt;

&lt;h2&gt;
  
  
  Filtering and formatting files for comparison &lt;a&gt;
&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;We've now made two API calls: one to retrieve the top 1000 destinations seen by our Umbrella network over the past week, and one to retrieve the Top 1-Million domains seen by the Umbrella network globally.&lt;/p&gt;

&lt;p&gt;We'll want to clean up these files so that they're easier to compare and the resulting file is meaningful. &lt;/p&gt;

&lt;h3&gt;
  
  
  Cleaning up our top_destinations.csv file &lt;a&gt;
&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Our CSV file successfully returns our network's top destinations, but not all of those destinations are domains -- we'll also see IP addresses. &lt;/p&gt;

&lt;p&gt;While those IP addresses may be worth investigating, they cannot be compared to Umbrella's Top 1-Million, which is a list of domains only. For this reason, we'll want to filter out IP addresses.&lt;/p&gt;

&lt;p&gt;First we'll import Python libraries that will help us check for IP addresses and handle CSV files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from IPy import IP
import csv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we'll add logic that checks if something is an IP address.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def isIP(str):
    try:
        IP(str)
    except ValueError:
        return False
    return True 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll then incorporate our logic in a new function that takes our csv file as a parameter. For each line of the csv, if the content &lt;em&gt;isn't&lt;/em&gt; an IP address, we'll add it to a list called destinations_list.&lt;/p&gt;

&lt;p&gt;After that, we'll write that "domains only" list to a new csv.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# If destination in Top Destinations is a domain, write it as a new line in a CSV called top_destinations.csv.
def top_destinations_to_csv(top_destinations):

    destinations_list = []

    for destination in top_destinations['data']:
        if not isIP(destination['domain']):
            destinations_list.append(destination['domain'])

    top_destinations_csvfile = open('top_destinations.csv', 'w')

    with open('top_destinations.csv', 'w', newline='') as top_destinations_csvfile: 
        filewriter = csv.writer(top_destinations_csvfile, delimiter=',',
            quotechar='|', quoting=csv.QUOTE_MINIMAL)
        for destination in destinations_list: 
            filewriter.writerow([destination])
        top_destinations_csvfile.close()

    return top_destinations_csvfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Cleaning up the Top 1-Million CSV file &lt;a&gt;
&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Our top destinations file is now just rows upon rows of domains, but how about our Top 1-Million file?&lt;/p&gt;

&lt;p&gt;When we made our GET API call, we received a zipfile in return. We'll first import a library to work with that zipfile:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import zipfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We then need to write that zip file to disk, create a fresh csv file to save the cleaned up version to, and unzip the file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Download the Umbrella top 1 million destinations, unzip file, format file. 
def get_top_million():

    # API call to get Umbrella Top 1 Million as a zip file
    get_top_1million_zip = requests.get("http://s3-us-west-1.amazonaws.com/umbrella-static/top-1m.csv.zip")

    # Write the zip file to disk
    open('top-1m.csv.zip', 'wb').write(get_top_1million_zip.content)

    # Create a new CSV file to write the cleaned up Top 1 Million to
    top_1million_csv = 'top-1m.csv'

    # Unzip the file
    with zipfile.ZipFile('top-1m.csv.zip', 'r') as zip_ref: 
        zip_ref.extractall('.')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The unzipped Top 1-Million file looks something like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F70l5nusx4v3prb1zb6k8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F70l5nusx4v3prb1zb6k8.png" alt="Abbreviated example of Umbrella Top 1-Million output" width="258" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We need to remove that rank order so that we can just compare domains. To do this, we import a Python library to help us format the csv:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pandas
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, we drop that rank order column:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    # Removing rank order in first column so that we can compare domains to Top Destinations. 
    top_1million_csv = pandas.read_csv('top-1m.csv')
    first_column = top_1million_csv.columns[0]
    top_1million_csv = top_1million_csv.drop([first_column], axis=1)
    top_1million_csv.to_csv('top_1million_csv', index=False)

    return top_1million_csv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Finding uncommon domains &lt;a&gt;
&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;We're finally ready to find those uncommon domains! To do this, we compare both CSVs by opening and reading each line of the files. For each domain in our network's top destinations that does &lt;em&gt;not&lt;/em&gt; appear in the Umbrella Top-1 Million, we write that domain as a line in our final CSV named uncommon_domains.csv.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Compares each domain in top_destinations.csv to top-1m.csv (Umbrella's Top 1 Million) and returns any domains that are not in the Top 1 Million.
def find_uncommon_domains():

    top_destinations_file_path = "./top_destinations.csv"
    top_1million_file_path = "./top_1million_csv"

    uncommon_domains_file_path = "./uncommon_domains.csv"

    with open(uncommon_domains_file_path, 'w') as uncommon_domains_csv:

        top_destinations = open(top_destinations_file_path).readlines()
        top_1million = open(top_1million_file_path).readlines()

        for domain in top_destinations:
            if domain not in top_1million: 
                uncommon_domains_csv.write(domain)

    print(f"Uncommon domains have been written to uncommon_domains.csv in your current directory.")

    return uncommon_domains_csv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Removing old files &lt;a&gt;
&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;This part is a nicety, but let's remove all of the CSV files besides the resulting uncommon_domains.py to avoid confusion:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Clean up files used to determine uncommon domains.
def clean_up_files():
    os.remove('top-1m.csv.zip')
    os.remove('top-1m.csv')
    os.remove('top_destinations.csv')
    os.remove('top_1million_csv')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;We'll write a main function that runs when the script runs, calling the relevant functions in order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Main function
def main():

    access_token = generate_access_token()
    top_destinations = get_top_destinations(access_token)
    top_destinations_csvfile = top_destinations_to_csv(top_destinations)
    cleaned_top_1million_csv = get_top_million()
    uncommon_domains_csv = find_uncommon_domains()
    clean_up_files()

    return uncommon_domains_csv

if __name__ == "__main__":
    main()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can find an example of the output provided in the resulting uncommon_domains.csv below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjtimd6mfdyt317fg0tfg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjtimd6mfdyt317fg0tfg.png" alt="Example output of uncommon_domains.csv" width="291" height="212"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cisco DevNet sample code &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;This is an official submission in Cisco Code Exchange, including a suggested use case, available &lt;a href="https://developer.cisco.com/codeexchange/github/repo/erdietri/UmbrellaUncommonDomains/"&gt;here&lt;/a&gt;. You can also access the sample code directly on &lt;a href="https://github.com/erdietri/UmbrellaUncommonDomains"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>cisco</category>
      <category>api</category>
      <category>automation</category>
    </item>
    <item>
      <title>DevNet: 10 years of community building and education</title>
      <dc:creator>Jeff Bull</dc:creator>
      <pubDate>Wed, 13 Mar 2024 18:54:50 +0000</pubDate>
      <link>https://dev.to/cisco-devnet/a-decade-of-innovation-and-community-growth-2fb</link>
      <guid>https://dev.to/cisco-devnet/a-decade-of-innovation-and-community-growth-2fb</guid>
      <description>&lt;p&gt;Since its launch in 2014, &lt;a href="https://developer.cisco.com/" rel="noopener noreferrer"&gt;Cisco DevNet&lt;/a&gt; has been more than just a platform for developers and IT professionals. It has been a thriving community of like-minded individuals driven by their passion for technology and their desire to collaborate on best practices and discover most efficient tools and techniques for building solutions, solving problems.&lt;/p&gt;

&lt;p&gt;DevNet has been a playground for application developers and network automation professionals, helping them to solve issues and build solutions across &lt;a href="https://developer.cisco.com/site/networking/" rel="noopener noreferrer"&gt;networking&lt;/a&gt;, &lt;a href="https://developer.cisco.com/site/security/" rel="noopener noreferrer"&gt;security&lt;/a&gt;, &lt;a href="https://developer.cisco.com/iot/" rel="noopener noreferrer"&gt;IoT&lt;/a&gt;, &lt;a href="https://developer.cisco.com/site/full-stack-observability/" rel="noopener noreferrer"&gt;full-stack observability&lt;/a&gt;, and more. Providing tools and resources such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.cisco.com/docs/" rel="noopener noreferrer"&gt;API, SDK, and data model documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.cisco.com/learning/" rel="noopener noreferrer"&gt;Learning labs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.cisco.com/codeexchange/" rel="noopener noreferrer"&gt;Sample code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.cisco.com/site/sandbox/" rel="noopener noreferrer"&gt;Sandboxes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Celebrating Innovation: The Big Events
&lt;/h2&gt;

&lt;p&gt;Signature events like the DevNet Zone at Cisco Live! and DevNet Create (which began in 2017) have always “trended” across social media platforms. These aren’t your average tech meets; they’re where people from all backgrounds and experiences come to play, share, and learn.&lt;/p&gt;

&lt;p&gt;DevNet Create for instance, successfully blended DevOps, SecOps, and more, drawing widespread participation.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Heart of DevNet: Our Community
&lt;/h2&gt;

&lt;p&gt;At its core, DevNet’s essence lies in its community. We’re enhancing our community experience, starting with a an updated name: the “DevNet Hub.” This new name better reflects our identity and offers the same excellent experience. Check out the revamped platform at &lt;a href="https://developer.cisco.com/community" rel="noopener noreferrer"&gt;DevNet Hub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We’ve also renamed each item in the DevNet Hub menu to make the experience feel seamless.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Next Chapter of DevNet
&lt;/h2&gt;

&lt;p&gt;Please keep an eye out for more updates coming over the next few months, because we’re always looking for your input! &lt;a href="https://community.cisco.com/t5/the-break-room/bd-p/Dev_Off_Topic" rel="noopener noreferrer"&gt;Drop a thread to us here&lt;/a&gt; if you see a change that doesn’t make sense, if you have a suggestion, or spot an issue. Also, be on the lookout for polls as we test out ideas. Your input is always welcome.&lt;/p&gt;

&lt;p&gt;DevNet’s story isn’t just about tech evolution – it’s about connections, growth, and a shared passion for innovation. All to help you meet the demands of your ever changing workloads.&lt;/p&gt;

&lt;p&gt;Want to be part of this journey? Join the &lt;a href="https://developer.cisco.com/community" rel="noopener noreferrer"&gt;community discussions&lt;/a&gt;, share your ideas, and get involved. And for the latest insights, make sure to say hello to &lt;a href="https://www.threads.net/@jeffbulltech" rel="noopener noreferrer"&gt;@JeffBullTech on Threads&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ciscodevnet</category>
      <category>devnetcreators</category>
      <category>developercommunity</category>
    </item>
  </channel>
</rss>
