<?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: Khai J. Thani</title>
    <description>The latest articles on DEV Community by Khai J. Thani (@khai-jt).</description>
    <link>https://dev.to/khai-jt</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%2F484382%2Fe5009ec8-6da6-4a77-8787-963b706385a9.jpg</url>
      <title>DEV Community: Khai J. Thani</title>
      <link>https://dev.to/khai-jt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/khai-jt"/>
    <language>en</language>
    <item>
      <title>Move hardcoded secrets to a Secrets Manager</title>
      <dc:creator>Khai J. Thani</dc:creator>
      <pubDate>Sun, 13 Oct 2024 14:23:07 +0000</pubDate>
      <link>https://dev.to/khai-jt/move-hardcoded-secrets-to-a-secrets-manager-2bmc</link>
      <guid>https://dev.to/khai-jt/move-hardcoded-secrets-to-a-secrets-manager-2bmc</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1b8hhfi0kiemhj4j0o2s.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1b8hhfi0kiemhj4j0o2s.jpg" alt="Photo by Amol Tyagi on Unsplash" width="640" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A secrets manager is a tool for storing and managing your passwords, API keys, database credentials and other types of sensitive data your application requires.&lt;/p&gt;

&lt;p&gt;Secrets hard-coded in application source codes or stored in plain text files for your codes to consume can be exploited by malicious entities who can inspect the applications or the components in your system. This risk can be mitigated with secrets managers.&lt;/p&gt;

&lt;h2&gt;
  
  
  dotenv-vault
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;dotenv-vault&lt;/strong&gt; is one such secrets manager that provides a safer alternative to putting your secrets in code.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;[!Note]&lt;br&gt;
This is not a tutorial on using &lt;strong&gt;dotenv-vault&lt;/strong&gt;. The aim of this document is to describe how a secrets manager can help developers avoid hard-coding secrets or storing them in plain text files. You can learn how to get started with &lt;strong&gt;dotenv-vault&lt;/strong&gt; &lt;a href="https://www.dotenv.org/docs#getting-started" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's say I have sensitive information about a particular character in the movie &lt;em&gt;Star Wars: Episode V&lt;/em&gt; and I want my program to use that information.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;spoiler&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;spoiler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Darth Vader is Luke Skywalker&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s father&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;spoiler&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;spoiler&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of hard-coding the information, I would write it as an &lt;a href="https://www.freecodecamp.org/news/python-env-vars-how-to-get-an-environment-variable-in-python/" rel="noopener noreferrer"&gt;environment variable&lt;/a&gt; in the &lt;code&gt;.env&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SPOILER="Darth Vader is Luke Skywalker's father"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;strong&gt;dotenv-vault&lt;/strong&gt;, my program is able to access the sensitive information by using the environment variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dotenv_vault&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;load_dotenv&lt;/span&gt;

&lt;span class="nf"&gt;load_dotenv&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# Take environment variables from .env
&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;spoiler&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;spoiler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SPOILER&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# Get the secret
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;spoiler&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;spoiler&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I encrypt the environment variable by &lt;a href="https://www.dotenv.org/docs/tutorials/sync" rel="noopener noreferrer"&gt;syncing the &lt;code&gt;.env&lt;/code&gt; file&lt;/a&gt;. Once the syncing is completed, a data known as &lt;code&gt;DOTENV_KEY&lt;/code&gt; can be generated. This output can be read by my program as an environment variable in production.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DOTENV_KEY='dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=production' python main.py

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

&lt;/div&gt;



&lt;p&gt;As a result, my production application is able to access the secret.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"spoiler"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Darth Vader is Luke Skywalker's father"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Choose the right Secrets Manager for you
&lt;/h2&gt;

&lt;p&gt;There is a variety of secrets management solutions available. Each secrets manager comes with its own set of pros and cons. Choose the option that best fits your organization's requirements.&lt;/p&gt;

&lt;p&gt;List of alternative Secrets Managers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://infisical.com" rel="noopener noreferrer"&gt;Infiscal&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.doppler.com" rel="noopener noreferrer"&gt;Doppler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.hashicorp.com/products/vault" rel="noopener noreferrer"&gt;HashiCorp Vault&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/secrets-manager/" rel="noopener noreferrer"&gt;AWS Secrets Manager&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://azure.microsoft.com/en-us/products/key-vault/" rel="noopener noreferrer"&gt;Azure Key Vault&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>python</category>
      <category>security</category>
      <category>programming</category>
      <category>learning</category>
    </item>
    <item>
      <title>Neo4j basics</title>
      <dc:creator>Khai J. Thani</dc:creator>
      <pubDate>Sat, 02 Apr 2022 02:32:35 +0000</pubDate>
      <link>https://dev.to/khai-jt/neo4j-basics-pg0</link>
      <guid>https://dev.to/khai-jt/neo4j-basics-pg0</guid>
      <description>&lt;h2&gt;
  
  
  What is a graph?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;graph&lt;/strong&gt; is a set of objects in which some pairs of the objects are connected. The objects are known as &lt;strong&gt;nodes&lt;/strong&gt; and the connections are known as &lt;strong&gt;relationships&lt;/strong&gt;. With these two elements, we can solve real-world problems by creating or inferring connections between objects. We can also create predictions given the strength of the connections.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsmnz6356og96gri7tc2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsmnz6356og96gri7tc2.png" alt="A set of connected circles" width="800" height="532"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How are graphs structured?
&lt;/h2&gt;

&lt;p&gt;In an &lt;strong&gt;undirected graph&lt;/strong&gt;, the relationships are bi-directional or symmetric; in a &lt;strong&gt;directed graph&lt;/strong&gt;, the relationships have one direction.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqeipleynitaoi4lcn3r2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqeipleynitaoi4lcn3r2.png" alt="Undirected graph vs directed graph" width="800" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a &lt;strong&gt;weighted graph&lt;/strong&gt;, the relationships carry measurable values such as cost, time, distance or priority.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhulgqkaaw30wqn7r8vwd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhulgqkaaw30wqn7r8vwd.png" alt="Weighted graph" width="800" height="674"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The structure of a graph enables &lt;strong&gt;traversal&lt;/strong&gt;. The process consists of following the relationships. With Neo4j's Cypher query language, relationships are not be followed multiple times.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some common use-cases for graphs
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;E-commerce and real-time recommendations&lt;/strong&gt;:&lt;br&gt;
Recommendations like "People who bought {Product X} also bought…" can be generated by having a proportion of the graph be traversed. In this example, you traverse from one Product node to the Persons nodes who have purchased that product and then to the subsequent Products nodes that they have bought.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Investigative journalism&lt;/strong&gt;:&lt;br&gt;
The graph known as &lt;strong&gt;Panana Papers&lt;/strong&gt; was created to identify possible corruption based upon the relationships between people, companies, and most importantly financial institutions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Network and IT operations&lt;/strong&gt;:&lt;br&gt;
A typical graph would describe how information flows through a system and how components of a network are related&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Transportation and logistics&lt;/strong&gt;:&lt;br&gt;
A typical graph would describe how locations are related and the distances between them&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>feynmantechnique</category>
      <category>todayilearned</category>
      <category>neo4j</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Access the full details of Delivery Status Notification (Failure) messages from Amazon SES</title>
      <dc:creator>Khai J. Thani</dc:creator>
      <pubDate>Wed, 20 Jan 2021 11:05:03 +0000</pubDate>
      <link>https://dev.to/khai-jt/access-the-full-information-of-delivery-status-notification-failure-message-from-amazon-ses-4b3</link>
      <guid>https://dev.to/khai-jt/access-the-full-information-of-delivery-status-notification-failure-message-from-amazon-ses-4b3</guid>
      <description>&lt;p&gt;We received a message from Amazon SES notifying us an error had occurred while trying to deliver an email to a recipient:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;From: &amp;lt;MAILER-DAEMON@amazonses.com&amp;gt;
Date: Tue, Dec 15, 2020, 3:33 PM
Subject: Delivery Status Notification (Failure)
To: My Company &amp;lt;abc@example.com&amp;gt;

An error occurred while trying to deliver the mail to the following recipients:
johndoe@****de.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first glance, it seems that no causes of the errors are specified in the email, but that is not the case. You can access hidden information by downloading the original message. You will get an .eml file, and it will contain info. such as the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Action: failed
Final-Recipient: ******; johndoe@****de.com
Diagnostic-Code: blah blah blah Message expired: unable to deliver in 840 minutes.&amp;lt;The email account that you tried to reach is over quota. blah blah blah
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, the recipient’s inbox was full it could not receive the email.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>ses</category>
    </item>
  </channel>
</rss>
