<?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: Navee</title>
    <description>The latest articles on Forem by Navee (@lasatadevi).</description>
    <link>https://forem.com/lasatadevi</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%2F40593%2F7a175471-e599-41f2-9913-d9c9d3dee93b.png</url>
      <title>Forem: Navee</title>
      <link>https://forem.com/lasatadevi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/lasatadevi"/>
    <language>en</language>
    <item>
      <title>Shift Security Left: Be A Secure Developer</title>
      <dc:creator>Navee</dc:creator>
      <pubDate>Sun, 01 Dec 2019 17:38:41 +0000</pubDate>
      <link>https://forem.com/lasatadevi/shift-security-left-be-a-secure-developer-2ehk</link>
      <guid>https://forem.com/lasatadevi/shift-security-left-be-a-secure-developer-2ehk</guid>
      <description>&lt;p&gt;The concept of Shifting security left in software development life cycle(SDLC) is not new. As a software developer, all of us know, how important data security/ privacy is. Most of us must have known about it, in one way or another, even if in different words or phrases. In this post, I am going to talk about what does it mean by shifting security left(for those who haven't heard about it before) and what can we do, as developers to adopt this mindset.&lt;/p&gt;

&lt;p&gt;In the standard SDLC, you develop, test, put the application in cloud, iterate the process and when its ready to release for production, all security/ compliance checks come into picture. And we know that farther the cycle, more expensive it is to identify the problem and fix it. Expensive in terms of money and expensive in terms of time and of course in terms of our sanity.&lt;/p&gt;

&lt;p&gt;So, security should not be an afterthought. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QPDww0QI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/l5djmgv3vqc6ol8ywc4t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QPDww0QI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/l5djmgv3vqc6ol8ywc4t.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hence, came the concept of shifting security left. Which means that rather than checking for security at the very right of the process, shift it to the left. Start adopting security/ privacy measures from the very start of the development. This can be pushed further left, where we start to analyse this from requirement analysis and backlog grooming.&lt;/p&gt;

&lt;p&gt;Shifting left means adopting security by design. Possible issues later in the development cycle cannot be predicted. Hence it will be very helpful to be proactive and think about making the application more secure from beginning, rather than being reactive. &lt;/p&gt;

&lt;p&gt;Adopting this mindset means that we can reduce the security vulnerabilities in our application, saving us a lot of time, money and most essentially stress to ourselves. You must have heard about death by thousand paper cuts. Its not always one big blow which can lead to  malicious hacks but it can be 100s of vulnerabilities here and there.&lt;/p&gt;

&lt;p&gt;It all sounds very easy. But is it?&lt;/p&gt;

&lt;p&gt;As a developer, when writing code/tests or doing code reviews, there are so many things you have to focus on... Implementing the feature, writing clean/maintainable/testable code, writing tests and writing documentations. Without a doubt, we always want to embrace secure coding practices when coding and doing code reviews. But, with time constraint/ pressure, it is easy to miss this out. That can be because, it’s not imprinted hard enough in our minds as having to write unit tests/ making sure that code is maintainable. Adding this perspective proactively in your mental checklist, might take regular remainders and can become a habit with time.  &lt;/p&gt;

&lt;p&gt;Being familiar with the OWASP top 10 vulnerabilities, OWASP's ASVS( (Application security Verification Standard) and knowing good and bad practices for writing secure code helps a lot to remind ourselves about the measures we can take to be “The Secure Developer”. In addition, decisions we make as a developer, dictates how we can improve security of our applications. Decision about persisting data, using external libraries and using external code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vjC3C3NE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/94gq8inmc1jszk22kb8l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vjC3C3NE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/94gq8inmc1jszk22kb8l.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We know that most of the malicious hacks, leads to leak of User’s private data – their name, address, date of birth, email address, credit card details and Social Security number. So we need to make sure that those data are properly encrypted before sending it over the network and persisting them, so that they are secure. &lt;/p&gt;

&lt;p&gt;However, what is more secure than Secure data? Answer is, NO DATA&lt;br&gt;
If these private details were not saved in the first place, they would not be leaked and exploited. So, before persisting any data, we need to ask, WHY do we need to persist them. DO NOT persist any data, unless its absolutely required. If you have to persist them, make sure that, you take necessary measures to secure them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Open Source Libraries:
&lt;/h3&gt;

&lt;p&gt;Most of the applications today uses at least 1 open source library. Why? because there is no point in reinventing the wheel. But when using these external libraries, we need to make sure that they are reliable enough. Its really important to ask, if the library you are going to use is credible enough, if its regularly updated., What kind of issues are reported against it in github.&lt;/p&gt;

&lt;p&gt;Open source libraries are the most vulnerable ones which can be exploited. You never know, that the library you are using might be mining bitcoins in the cloud. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--i_1LSgR1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/kxtdharaj6xled9750nb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i_1LSgR1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/kxtdharaj6xled9750nb.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, in case of vulnerabilities in widely used libraries like openSSL and struts, you cannot do anything, except updating the library as soon as the fix comes along OR face the consequences as Equifax did. There are many commercial tools available for this purpose, that you can use.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stack Overflow Driven Development:
&lt;/h3&gt;

&lt;p&gt;Copying the code from Stack Overflow and pasting it without understanding what it's actually doing, is a common practice. All of us have done it at some phases of our career and we still do it. There was a &lt;a href="https://blog.acolyer.org/2018/06/27/secure-coding-practices-in-java-challenges-and-vulnerabilities/"&gt;research&lt;/a&gt; which researched about accepted answers in Stack Overflow and found out that there are many accepted answers which are out of date or insecure. It is really important to understand what the code is actually doing, before reusing it.&lt;/p&gt;

&lt;p&gt;All of these sounds very trivial and obvious. But sometimes we forget about them. As a developer, adopting this mindset is really important. You don’t need to be a doctor to know that you should wash your hands to prevent spreading germs. But sometime, those notes in the bathroom helps. So this post is just that remainder.&lt;/p&gt;

&lt;p&gt;There might be many other tips which you can adopt to embrace secure coding practices and make secure decisions. If you have any, please share it in the comments.&lt;/p&gt;

</description>
      <category>devsecops</category>
      <category>security</category>
      <category>softwaredevelopment</category>
      <category>goodpractices</category>
    </item>
    <item>
      <title>Docker: cmd VS entrypoint</title>
      <dc:creator>Navee</dc:creator>
      <pubDate>Sat, 28 Sep 2019 11:12:48 +0000</pubDate>
      <link>https://forem.com/lasatadevi/docker-cmd-vs-entrypoint-34e0</link>
      <guid>https://forem.com/lasatadevi/docker-cmd-vs-entrypoint-34e0</guid>
      <description>&lt;p&gt;Docker is widely used these days, but if you have not got any chance to work on it, then its high time to get familiar with it. This post is not going to be a tutorial about docker though, so it assumes that you have its basic understanding. If you know docker, you must know that to build a docker image, you need to create Dockerfile with several instructions in it. In this post, I am going to talk about two of those instructions: &lt;code&gt;CMD&lt;/code&gt; and &lt;code&gt;ENTRYPOINT&lt;/code&gt; which can be a bit confusing if you haven’t paid much attention to it. &lt;/p&gt;

&lt;p&gt;Both of these docker instructions are used to define command/executables which is executed during container invocation. These are very similar but different instructions which can be used independently or together to achieve better flexibility to define what a container should execute. There are two ways/syntaxes to define them:&lt;/p&gt;

&lt;p&gt;Exec form: (Preferred form)&lt;br&gt;
&lt;code&gt;CMD [“executable”, “arg1”, “arg2”]&lt;/code&gt;&lt;br&gt;
&lt;code&gt;ENTRYPOINT [“executable”, “arg1”, “arg2”]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Shell form: &lt;br&gt;
&lt;code&gt;CMD executable arg1 arg2&lt;/code&gt;&lt;br&gt;
&lt;code&gt;ENTRYPOINT executable arg1 arg2&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Use cases:&lt;/p&gt;
&lt;h3&gt;
  
  
  CMD
&lt;/h3&gt;

&lt;p&gt;Used to provide all the default scenarios which can be overridden. &lt;/p&gt;

&lt;p&gt;Cmd instruction is used to define:&lt;/p&gt;
&lt;h4&gt;
  
  
  Default executable
&lt;/h4&gt;

&lt;p&gt;This instructions is used to define a default executable for a container to execute. If you want to create a generic docker image, where users can pass any supported command to be executed on container invocation, then this instruction is the one to use. Entrypoint instruction should not be defined in Dockerfile for this use case.&lt;br&gt;
&lt;code&gt;CMD [“executable”, “arg1”, “arg2”]&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Default arguments
&lt;/h4&gt;

&lt;p&gt;This instruction can also be used to provide default arguments. For this use case, we don’t specify executable in this instruction at all, but simply define some arguments which are used as default/additional arguments for executable defined in the entrypoint instruction. Thus, entrypoint instruction is required in dockerfile for this use case to define an executable.&lt;br&gt;
&lt;code&gt;CMD [“arg1”, “arg2”]&lt;br&gt;
ENTRYPOINT [“executable”]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;P.S: Anything defined in CMD can be overridden by passing arguments in &lt;code&gt;docker run&lt;/code&gt; command.&lt;/p&gt;
&lt;h3&gt;
  
  
  ENTRYPOINT
&lt;/h3&gt;

&lt;p&gt;Used to define specific executable and arguments to be executed during container invocation which cannot be overridden. This is used to constraint the user to execute anything else. User can however define arguments to be passed in the executable by adding them in the docker run command.&lt;br&gt;
&lt;code&gt;ENTRYPOINT [“executable”, “arg1”, “arg2”]&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;For the demo, let's take the following dockerFile which fetches necessary cowsay and screenfetch libraries so that we can run these commands when running the container.&lt;/p&gt;
&lt;h4&gt;
  
  
  Demo 1 - Use of CMD to define Default executable
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM debian:jessie-slim

RUN apt-get update                                      &amp;amp;&amp;amp; \
    apt-get install -y --no-install-recommends             \
        cowsay                                             \
        screenfetch                                     &amp;amp;&amp;amp; \
    rm -rf /var/lib/apt/lists/*

ENV PATH "$PATH:/usr/games"
CMD ["cowsay", "Yo, CMD !!"]

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

&lt;/div&gt;


&lt;p&gt;Build the Image:&lt;br&gt;
&lt;code&gt;docker build -t demo .&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Run the container:&lt;br&gt;
&lt;code&gt;docker run demo&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will run the default executable specified in &lt;code&gt;CMD&lt;/code&gt; instruction and output following.&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fefvk90tjgs2zyd2u9zhe.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fefvk90tjgs2zyd2u9zhe.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, you can override this executable, when running the container as&lt;br&gt;
&lt;code&gt;docker run demo screenfetch -E&lt;/code&gt; which will output&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fm0b8ackf86d02ez1jede.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fm0b8ackf86d02ez1jede.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Demo 2 - Use of ENTRYPOINT
&lt;/h4&gt;

&lt;p&gt;If you want to restrict users from passing any other executable, you can specify 'ENTRYPOINT' instruction as :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM debian:jessie-slim

RUN apt-get update                                      &amp;amp;&amp;amp; \
    apt-get install -y --no-install-recommends          \
        cowsay                                          \
        screenfetch                             &amp;amp;&amp;amp;      \
    rm -rf /var/lib/apt/lists/*

ENV PATH "$PATH:/usr/games"

ENTRYPOINT ["cowsay", "Yo, Entrypoint!!"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Build the image again and run this container as:&lt;br&gt;
&lt;code&gt;docker run demo&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will run the executable specified in &lt;code&gt;ENTRYPOINT&lt;/code&gt; and output following.&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fiy10ctcmhdm3uuz2t3r6.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fiy10ctcmhdm3uuz2t3r6.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With entryPoint defined in the docker file, if you pass an executable in the docker run command, it will not take that as an executable, but, as an argument for the executable defined in the entryPoint instruction. So if you run following command,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker run demo screenfetch -E&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It will output: &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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fjr3tuyvunvelzwvpeew7.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fjr3tuyvunvelzwvpeew7.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As expected, the arguments passed in the docker run command, is appended in the executable and argument, set in the entryPoint instruction.&lt;/p&gt;
&lt;h4&gt;
  
  
  Demo 3 - Use of ENTRYPOINT and CMD together
&lt;/h4&gt;

&lt;p&gt;If Entrypoint is defined, anything defined in CMD will be taken as arguments for the executable defined in Entrypoint.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM debian:jessie-slim

RUN apt-get update                                      &amp;amp;&amp;amp; \
    apt-get install -y --no-install-recommends          \
        cowsay                                          \
        screenfetch                             &amp;amp;&amp;amp;      \
    rm -rf /var/lib/apt/lists/*

ENV PATH "$PATH:/usr/games"

CMD ["Yo, CMD!!"]
ENTRYPOINT ["cowsay", "Yo, Entrypoint!!"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Building the image from above docker file and running the container with &lt;code&gt;docker run demo&lt;/code&gt; will output:&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbx9o3dgxq8z2dgmmnbbo.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbx9o3dgxq8z2dgmmnbbo.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you now know, the argument defined in CMD can easily be overridden by passing other arguments in docker run command, if you execute &lt;code&gt;docker run demo Overriding arg passed in cmd&lt;/code&gt;, It will output:&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzigw72eyeqqmqqrqrti0.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzigw72eyeqqmqqrqrti0.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thus, the main point to remember is CMD is used to provide default executable and arguments, which can be overridden, while ENTRYPOINT is used to specify specific executable and arguments, to constraint the usage of image. &lt;/p&gt;

</description>
      <category>docker</category>
      <category>dockerinstructions</category>
      <category>cmd</category>
      <category>entrypoint</category>
    </item>
  </channel>
</rss>
