<?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>Forem: Daniel Luque Quintana</title>
    <description>The latest articles on Forem by Daniel Luque Quintana (@drankolq).</description>
    <link>https://forem.com/drankolq</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%2F4477%2F8750071.jpeg</url>
      <title>Forem: Daniel Luque Quintana</title>
      <link>https://forem.com/drankolq</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/drankolq"/>
    <language>en</language>
    <item>
      <title>Improve code reviews using pull request templates </title>
      <dc:creator>Daniel Luque Quintana</dc:creator>
      <pubDate>Tue, 09 Jul 2019 10:12:55 +0000</pubDate>
      <link>https://forem.com/wealize/improve-code-reviews-using-pull-request-templates-10he</link>
      <guid>https://forem.com/wealize/improve-code-reviews-using-pull-request-templates-10he</guid>
      <description>&lt;p&gt;At The Neon Project we care about our internal processes: we believe they’re important, we design them meticulously, we use them, and we improve them as we learn from their performance in the real world. &lt;/p&gt;

&lt;p&gt;One of the most important processes when developing software is code review, where at least one teammate will review your code. This process improves the quality of the code since, many times, code that seems easy to understand for the author is not as clear for the rest of the team. Everyone involved in the code review learns: learn how to give feedback, learn how your partners think and write code &amp;amp; learn technical details.&lt;/p&gt;

&lt;p&gt;To make the code review process as easy and quick as possible, the more context we give our colleagues about what we have done and why, the better. After reviewing the &lt;a href="https://github.com/thepracticaldev/dev.to"&gt;Dev.to Github repository&lt;/a&gt; and seeing some pull requests, I thought there was a way to improve our code review process in The Neon Project: using templates for pull requests.&lt;/p&gt;

&lt;p&gt;A pull request template is, basically, a file containing markdown text that is added to your pull request description automatically when it is created.&lt;/p&gt;

&lt;p&gt;The file must have the name &lt;strong&gt;pull_request_template.md&lt;/strong&gt;. In our case, this file is in a hidden folder named .github, but you can put it wherever you want (more information about Github pull request templates &lt;a href="https://help.github.com/en/articles/creating-a-pull-request-template-for-your-repository" rel="noopener noreferrer"&gt;here&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Our template consists of the following parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A reminder&lt;/strong&gt;: as we use Jira for project management, a very useful feature is to link a PR to a Jira issue by adding the issue code to the PR title. This way we can see its status from Jira&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Type of PR&lt;/strong&gt;: consists of 3 checkboxes, indicating whether the pull request is a bugfix, a new feature or a refactor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Description&lt;/strong&gt;: a brief description of what we can expect from PR. This part is essential for the person who reviews the code to know, in one pass and briefly, what to expect in the code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Screenshots (if there are changes of UI)&lt;/strong&gt;: one of the problems of the PR that have visual changes is to know what has changed or what is the final result. In general, the process to execute the code locally and see it won't be fast, the person will have to download the code changes in their machine, have the environment configured, etc. A few simple photos and/or videos will save a lot of time to see what's new. Personally, I use &lt;a href="https://support.apple.com/en-us/HT201361" rel="noopener noreferrer"&gt;macOS screenshots&lt;/a&gt; and &lt;a href="http://imgur.com" rel="noopener noreferrer"&gt;Imgur&lt;/a&gt; to upload them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;(optional) a gif that describes how it makes you feel&lt;/strong&gt;: because there's always a good reason to put gifs, right? 🤓&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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%2Fimgur.com%2FhGh0RGD.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%2Fimgur.com%2FhGh0RGD.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this simple way, we improve the code review process: more information and context so that code reviewers can understand quickly what they are going to review and thus are able to deploy code more often 🚀&lt;/p&gt;

&lt;h3&gt;
  
  
  One more thing...
&lt;/h3&gt;

&lt;p&gt;After the announcement that &lt;a href="https://github.blog/2019-06-17-github-acquires-pull-panda/" rel="noopener noreferrer"&gt;Github has acquired Pull Panda&lt;/a&gt;, we have integrated it into our process and we are very satisfied! For those who don't know it, Pull Panda allows you to remember through Slack when a contributor needs to have a PR checked, can assign a reviewer automatically and offers a series of very interesting analytics to know, for example, the average time needed to make reviews or how many took more than 8 hours. And it's free!&lt;/p&gt;

&lt;p&gt;That's it, folks. So, how's your code review process? Any advice on how to improve ours?&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>codequality</category>
    </item>
    <item>
      <title>Certificate Pinning your Android and iOS apps.</title>
      <dc:creator>Daniel Luque Quintana</dc:creator>
      <pubDate>Thu, 30 Mar 2017 21:51:17 +0000</pubDate>
      <link>https://forem.com/drankolq/certificate-pinning-your-android-and-ios-apps</link>
      <guid>https://forem.com/drankolq/certificate-pinning-your-android-and-ios-apps</guid>
      <description>&lt;p&gt;When we, developers, are working in the development of any kind of software, we can't forget about security ðŸ”. The minimum security measure we should use is HTTPS as the protocol to share information between a client (in this case, an Android/iOS app) and a server, followed by an updated cryptographic protocol like TLS 1.2 (SSL 3.0 is vulnerable!)&lt;br&gt;
You may think that using an HTTPS is enough but in some cases like banking applications, where sensitive data may be send between our client and our server, could be risky.&lt;br&gt;
By default, when making a TLS connection, the client check two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The server's certificate matches the requested hostname.&lt;/li&gt;
&lt;li&gt;The server's certificate has a chain of truth back to a trusted root certificate.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What it doesn't do is check if the certificate is the specific certificate you know your server is using, and that's a possible security vulnerability: if the client is compromised and a unsafe certificate is installed, someone could do a man-in-the-middle attack.&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%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2A6H-NohaUwM_V3scd8tdjxw.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%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2A6H-NohaUwM_V3scd8tdjxw.png" title="Root CA, intermediate CA and Medium certificate"&gt;&lt;/a&gt;&lt;br&gt;
The solution to this problem is certificate pinning: storing a certificate on our client to ensure that any SSL request made matches the one our server has. Let me explain you how to do it on both Android and iOS apps.&lt;/p&gt;
&lt;h3&gt;
  
  
  Â Android
&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://square.github.io/okhttp" rel="noopener noreferrer"&gt;OkHttp&lt;/a&gt; lib provide a CertificatePinner class to be added to an OkHttpClient instance. The easiest way to pin a host is turn on pinning with a broken configuration and read the expected configuration when the connection fails.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CertificatePinner certificatePinner = new CertificatePinner.Builder()
         .add("mydomain.com", "sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=")
         .build();
     OkHttpClient client = OkHttpClient.Builder()
         .certificatePinner(certificatePinner)
         .build();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After a request is executed, you'll see this message on the console:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;javax.net.ssl.SSLPeerUnverifiedException: Certificate pinning failure!
   Peer certificate chain:
     sha256/afwiKY3RxoMmLkuRW1l7QsPZTJPwDS2pdDROQjXw8ig=: CN=mydomain.com, OU=PositiveSSL
     sha256/klO23nT2ehFDXCfx3eHTDRESMz3asj1muO+4aIdjiuY=: CN=COMODO RSA Secure Server CA
     sha256/grX4Ta9HpZx6tSHkmCrvpApTQGo67CYDnvprLg5yRME=: CN=COMODO RSA Certification Authority
     sha256/lCppFqbkrlJ3EcVFAkeip0+44VaoJUymbnOaEUk7tEU=: CN=AddTrust External CA Root
   Pinned certificates for mydomain.com:
     sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
   at okhttp3.CertificatePinner.check(CertificatePinner.java)
   at okhttp3.Connection.upgradeToTls(Connection.java)
   at okhttp3.Connection.connect(Connection.java)
   at okhttp3.Connection.connectAndSetOwner(Connection.java)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The exception will provide you the server's certificate public key hashes. Paste them on the CertifinatePinner and done! âœ”&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CertificatePinner certificatePinner = new CertificatePinner.Builder()
       .add("mydomain.com", "sha256/afwiKY3RxoMmLkuRW1l7QsPZTJPwDS2pdDROQjXw8ig=")
       .add("mydomain.com", "sha256/klO23nT2ehFDXCfx3eHTDRESMz3asj1muO+4aIdjiuY=")
       .add("mydomain.com", "sha256/grX4Ta9HpZx6tSHkmCrvpApTQGo67CYDnvprLg5yRME=")
       .add("mydomain.com", "sha256/lCppFqbkrlJ3EcVFAkeip0+44VaoJUymbnOaEUk7tEU=")
       .build();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  iOS
&lt;/h3&gt;

&lt;p&gt;The iOS solution is not so straightforward because you need to store the certificate itself inside your app. In my case, I've used Alamofire as HTTP client lib for Swift.&lt;br&gt;
First, you need to get the server's certificate in &lt;strong&gt;.der&lt;/strong&gt; format and add it to your iOS project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;openssl s_client -showcerts -servername mydomain.com -connect mydomain.com:443
 &amp;lt;/dev/null | openssl x509 -outform DER &amp;gt; mydomainCert.der
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now, lets enable certificate pinning: to do it we need both ServerTrustPolicy and SessionManager objects. The first one will define the hostname and certificates that will be used in the process:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var serverTrustPolicies = [
    "mydomain.com": .pinCertificates(
    certificates: ServerTrustPolicy.certificates(),
    validateCertificateChain: true,
    validateHost: true
  ),
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ServerTrustPolicy.certificates() will return all stored certificates and the booleans will validate the certificate chain and the hostname.&lt;br&gt;
Lastly, create a SessionManager object using this trust policies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var sessionManager = SessionManager(serverTrustPolicyManager: ServerTrustPolicyManager(policies: serverTrustPolicies!))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Done! âœ”. Just use this &lt;em&gt;sessionManager&lt;/em&gt; object to execute request&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sessionManager.request("https://mydomain.com/api", method: .get, headers: headers)...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Feedback is welcome! Hope it's useful â˜ºï¸&lt;/p&gt;

&lt;h4&gt;
  
  
  Sources
&lt;/h4&gt;

&lt;p&gt;OkHttp: &lt;a href="https://github.com/square/okhttp/wiki/HTTPS" rel="noopener noreferrer"&gt;https://github.com/square/okhttp/wiki/HTTPS&lt;/a&gt;&lt;br&gt;
Alamofire: &lt;a href="https://github.com/Alamofire/Alamofire#security" rel="noopener noreferrer"&gt;https://github.com/Alamofire/Alamofire#security&lt;/a&gt;&lt;/p&gt;

</description>
      <category>android</category>
      <category>ios</category>
      <category>java</category>
      <category>swift</category>
    </item>
  </channel>
</rss>
