<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Dipcode - Medium]]></title>
        <description><![CDATA[Web Development according to the customer needs: WordPress and Django Applications. - Medium]]></description>
        <link>https://medium.com/dipcode?source=rss----4939569f5355---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Dipcode - Medium</title>
            <link>https://medium.com/dipcode?source=rss----4939569f5355---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 23:19:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/dipcode" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Static Code Analysis — A Personal Research Story]]></title>
            <link>https://medium.com/dipcode/static-code-analysis-a-personal-research-story-387323983419?source=rss----4939569f5355---4</link>
            <guid isPermaLink="false">https://medium.com/p/387323983419</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[static-code-analysis]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[sonarqube]]></category>
            <dc:creator><![CDATA[Mark Tey ]]></dc:creator>
            <pubDate>Wed, 22 May 2019 13:14:31 GMT</pubDate>
            <atom:updated>2021-04-11T20:48:37.436Z</atom:updated>
            <content:encoded><![CDATA[<h3>Static Code Analysis — A Personal Research Story</h3><h4>Whether you have never heard of this before, you don’t know enough about it, or you already know but care to hear different perspectives, in an informative and personal story kind of way, this is for you.</h4><p><strong>I had no idea what Static Code Analysis was until I was given the job to find an alternative software solution on that.</strong></p><p>It was the beginning of the last semester, a few months away from finishing my graduation in Information Systems Engineering. Before that, I was sure I wanted to work in the Cybersecurity area, but I didn’t know how vague of an idea that was.</p><p>Before continuing, to give you a general idea, here is a picture with some specific possibilities on the Cybersecurity area:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oy3nLcvaMyBmN3cPsFn5uA.png" /><figcaption>Figure from: <a href="https://cybersecuritydegrees.com/wp-content/uploads/2017/07/cyber_org_chart-01.png">https://cybersecuritydegrees.com/wp-content/uploads/2017/07/cyber_org_chart-01.png</a></figcaption></figure><p>Yes, it’s a lot, and I found out the importance of specifying that, only after being inquired a couple of times.</p><p>Then, I started working for the first time, for <a href="https://dipcode.com/"><strong>Dipcode</strong></a>, as a trainee.</p><p>My training in general, was to do some research in the Application Security field, work that I ended up with, after showing my interest in the area of Cybersecurity at one of the job interviews.</p><p>I didn’t choose, but that was perfect after all!</p><p>I would still be building my future on Cybersecurity, I would be exploring the area, and I would have the opportunity to grow in all aspects of my life.</p><p>Furthermore, I would also be working as a researcher, and I knew that is something I wanted to do.</p><p>This work became even more perfect when I found I would be writing an article about my research.</p><p><em>I am thankful for the opportunity that Dipcode gave me, and I can’t wait to tell you my research story.</em></p><h3>Introducing Static Code Analysis</h3><p>It all started with understanding Static Code Analysis, also known as <strong>Static Application Security Testing</strong> <strong>(SAST)</strong>, and if you allow me to describe its meaning in one sentence, I will say something like:</p><p><em>Static Code Analysis is a set of technologies that define specific programs, accountable for detecting early faults or errors on the program code and avoiding future problems and vulnerabilities.</em></p><p>It is essentially placed during the<strong> </strong>testing phases, and its main purpose is guaranteeing security on the Software Development Life Cycle (SDLC), but it can also be done during the coding.</p><p>I found out that there are two main types for this type of analysis:</p><ul><li><strong>BCA — Binary or Byte Code Analysis</strong></li><li><strong>SCA — Source Code Analysis</strong></li></ul><p>While BCA is responsible for analyzing code that was already compiled, SCA deals with the source code directly, which means: noncompiled code.</p><p>SCA is the leading type and the one that follows more thoroughly the purpose of early problem detection that associates with the static analysis. It was this one that I had to focus on.</p><p>Moreover, I found that static analysis can also have two distinguished purposes:</p><ul><li><strong>Quality</strong></li><li><strong>Security</strong></li></ul><p>Quality is related to the process of detecting language or industry-specific problems that can later bring unwanted faults (e.g. exceptions).</p><p>Security will be more focused on finding general problems that can become vulnerabilities, and bring risks of exploitation (e.g. code injection).</p><p>Later it came to my knowledge that: the majority of the market, focus solemnly on Quality Analysis. For the rest, some implement Security Analysis only, whereas others include both quality and security at the same time.</p><h4>How does it work?</h4><p>Don’t worry! I read some detailed explanation for different static analysis tools, but I will not give you the same tedious work. That can be your homework if you wish.</p><p>Instead, I will briefly explain the technical functioning in a nontechnical friendly way.</p><p>BCA analysis, since the code is already compiled, requires some steps that don’t exist on SCA.</p><p>They first need to do some form of reverse engineering of the code and format it to an intermediate language to be able to do its work. I searched and learned about that, but since that was not my final purpose, I will only tell you about SCA.</p><p>I learned that, not all the programs work the same way, and each one can have it’s particularity, but besides that, I believe I can resume this in a more general manner.</p><p>In 7 short points:</p><ul><li>It all starts with <strong>reading the code</strong>.</li><li>A <strong>lexical analysis</strong> follows, where tokens are created and compared to vulnerability libraries, in a similar way of compilers.</li><li>Then, they can create an abstract representation of the code, through the construction of <strong>Abstract Syntax Trees</strong> (AST).</li><li>To deepen the analysis, tools can analyze the flow of execution. Using an <strong>Intermediate Representation</strong> (IR).</li><li>The IR is the base for building a <strong>Control Flow Graph</strong> and a <strong>Symbol Table</strong>.</li><li>At this point, <strong>functions are analyzed</strong>. Independent, modular, and global analysis can be done.</li><li><strong>The code</strong> that is being analyzed, at all points, <strong>is compared with patterns</strong> that were created in conformity with standards: Specific to a language (e.g. <a href="https://www.drupal.org/docs/develop/standards">Drupal</a> for PHP), security-specific (e.g. <a href="https://nvd.nist.gov/">NVD</a> from NIST), or specific to an industry (e.g. <a href="https://www.iso.org/standard/68383.html">ISO 26226</a>) for the automotive industry.</li></ul><p><strong>Linters</strong>, are the tools that only go as far as the third point.</p><p>Only these tools keep faithful to the real meaning of the term “static code analysis”, but that doesn’t matter nowadays since the paradigm has changed<em>.</em></p><h3>Should You Be Using Static Code Analysis?</h3><p>Although it was not up to me to decide whether or not should Dipcode be using static analysis tools, I tend to question things a lot, so I had an urge to reflect on the effectiveness of this approach to security.</p><p>The question “<strong>to use or not to use</strong>”, probably concerns some of you too, and we will get to that point, but first, let me enumerate some of the main positive and negative aspects.</p><p><strong>After all, I’m just a learning researcher!</strong></p><p>Starting with the advantages…</p><ul><li>Increases programmer productivity.</li><li>Early error detection.</li><li>It helps to avoid some errors, before compiling or reaching the testing phase.</li><li>It gives more profound and exact results than human beings.</li><li>The reduction of costs, related to early problem handling.</li></ul><p>Now, for the disadvantages…</p><ul><li>It’s not always easy to understand programmer intention.</li><li>Possibility of reporting to false positives or negatives.</li><li>Some problems require more intelligence and cannot be detected.</li><li>Even after analyzing, human intervention is still required.</li><li>Dynamic aspects of the application are still difficult to model.</li></ul><p>You may have noticed that I tried to write some points that would contradict each other in some way.</p><p>That probably means that the negative aspects defeat the positive ones, and it is exactly what I was thinking at this point in my research, but not really…</p><p><strong>Don’t jump into conclusions yet.</strong></p><p>First, one should understand that, when I write about advantages, I am referring to advantages that are fulfilled by some of the top tools on this market.</p><p>In the same manner, when I talk about the negative side, only the worst tools will fall short on some points. The best tools, even though they can’t avoid all these limitations, they can be good enough to override the disadvantage.</p><p>Reading through the conclusions is not really enough to understand the advantages.</p><h4>Deeper analysis</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6At1vvDuYBL6BCnCPBMSLg.jpeg" /><figcaption>Figure from: <a href="https://w-dog.net/wallpaper/tree-crown-the-roots-rock-forest/id/303368/">https://w-dog.net/wallpaper/tree-crown-the-roots-rock-forest/id/303368/</a></figcaption></figure><p>Besides comparing the pros and cons, I believe it is also fundamental to uncover things in their business context.</p><p>This means that we must understand whether this methodology adds value to the process of creating software as a product, or not, and compare that value with others. Then, we should also analyze its value on the real competitive market.</p><p>So I had to dive into a deeper analysis…</p><p>I understood the importance of studying the impact this would bring to the organization in question, and balance the cost/benefit of adding static analysis to the daily processes of software development.</p><p><strong>For the simple fact that the analysis allows detecting early problems, it is worthy to use.</strong></p><p>This will help to avoid the accumulation of problems, that will lead to a reduction in costs related to problem-solving, and it will even avoid the appearance of some problems.</p><p><strong>Who wants to have new problems, if they are avoidable?</strong></p><p>Not me, and you shouldn’t too!</p><p>And perhaps, more important than the opportunity to avoid problems is knowing that <strong>the cost of adding static analysis to some tasks, is meaningless when compared to the cost of dealing with accumulated problems.</strong></p><p>As I continued my research, another problem arose:</p><p><strong>Static or Dynamic Analysis?</strong></p><p>Don’t blame me! If you did my research, you would certainly be crashing on the same problem.</p><p>I know that I didn’t talk about Dynamic Analysis before, and I won’t, because that is neither the purpose of this article nor was it the purpose of my work. But since this was something for which I found a lot of discussions on the Web, I saw myself forced to do my investigation, and in the end, I found that…</p><p><strong>There is no reason for choosing one over the other.</strong></p><p>The truth is, Static Analysis will bring a huge value on detecting problems that are easily found on the source code itself, even after having to compile the program, whereas Dynamic Analysis can add an extra value to the application in its interaction with other elements, that means, as a whole interactive system.</p><blockquote>A problem is just a way to help you get to a solution.</blockquote><p><strong>Now, I can’t avoid going through the cost/benefit, right?</strong></p><p>It is possible to say that Dipcode follows an <em>open source philosophy.</em></p><p>This means that we may and should analyze the costs of implementation, in terms of time spent on the learning process, the time of analyses, time spent on configuration, etc. But we can totally forget the cost of acquiring a free tool.</p><p>All I had to understand at this point was: <em>is the tool capable of offering us the value that we want?.</em></p><p>And this also means that I had to understand more about closed source tools.</p><p>During my research, I made a list of all the tools I could find and gathered all the information I could about them. And this included direct contact with some of the companies that were selling those products.</p><p>I concluded that, when talking about value quantity, the Closed Source Market can overcome the open source. But…</p><p><strong>It was still possible to find valuable open source tools.</strong></p><p>And that’s it! I think this was enough to prove the value of adding static analysis to your business, if not, you will have to research for yourself, and you will eventually reach similar conclusions.</p><h3>What Did I Choose?</h3><p>At last, I had to make my decision.</p><p>We all know that decisions can be daunting, but this one wasn’t, simply because I would not be making an intuitive decision, but a well fundamental.</p><h4>Deepening the understanding</h4><p>I had to direct all my investigation to understand what was the best program for our needs. Starting with <strong>Source Code Analysis</strong>,<strong> </strong>I had to know what particular technologies were we exactly looking for.</p><p>Then, although the best decision was to find a tool, priming for quality and security both, I had to focus primarily on security, so my priority was <strong>Security Analysis</strong>.</p><p>Dipcode also needed to implement security specifically for these languages and frameworks: <strong>Python</strong>, <strong>Django</strong>, <strong>PHP</strong>, <strong>WordPress</strong>, <strong>JavaScript, </strong>and <strong>TypeScript</strong>.</p><p>I also had to prioritize <strong>Open Source </strong>tools, and find something capable of analyzing on a <strong>Continuous Integration </strong>environment.</p><p>For PHP and WordPress specifically, I would also give priority to <strong>CLI </strong>tools.</p><h4>Ranking the tools</h4><blockquote>Information is only information when it’s organized in a way that can be used as knowledge.</blockquote><p>The best way I found to be able to choose a tool effectively, was ranking.</p><p>I didn’t rank every tool but only those that remained, after checking if they were options.</p><p>I created metrics through the requirements, with different weights. Followed by a score that was attributed to each tool. This allowed me to get a total score, and I was finally able to choose a tool.</p><p>There was a program that stood out. Not only did it get the best ranking once, but, for all the sets of technologies. And that was:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*DDh74aqxJ7CcETCi2HAsiA.png" /></figure><p>I swear I’m not advertising right now!</p><p>So, as much as I would love to keep writing, it is not my goal to write about SonarQube, and detail the reason to be our best choice. It was so because it excelled in the ranking for our specific needs.</p><h3>Tips to Use Static Code Analysis</h3><p>Thus far, I talked about the reason for my research and the steps that led to my conclusions, while sharing my opinion with you.</p><p>To end my research story, I will leave you with some tips, that will help you (I hope…) implement static analysis. Since everyone loves tips.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*EENvkUs6jA0CKkeNO_GGcQ.png" /></figure><p>Not that kind of tips, but if you want to do that for me instead…</p><p>Jokes aside, going for what matters…</p><p>First of all, remember:</p><p><strong>Every need is different, and you should choose a tool according to your own specific needs.</strong></p><p>We were able to adopt an open source alternative because it is enough for our needs.</p><p><strong>If you are working for a bigger team, organization or bigger projects, you may need to resort to proprietary software.</strong></p><p>You should always confirm that the program works for your projects, and always…</p><p><strong>Ask for a test or demonstration before paying for software.</strong></p><p>Although it would be much better to have a solution for all projects…</p><p><strong>Consider the possibility of using multiple tools.</strong></p><p>And there are some tools to help you manage all the information.</p><p>Most tools already integrate Linters, and they may be reasonable enough for quality, but they don’t get deep enough, and are not capable of helping on security vulnerabilities, so…</p><p><strong>Use Linters for quality only, and in the last resource.</strong></p><p>You should never take decisions or keep the conclusions to yourself.</p><p><strong>Understand the importance of “Team”.</strong></p><p>As for the last tip:</p><blockquote><strong>Read as many articles as you want, but know how to filter good from bad information. And ALWAYS, do your own research.</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MwQS-Pdh2EtZuGd4qFyKdg.jpeg" /><figcaption>Dipcode Team and Me</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=387323983419" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dipcode/static-code-analysis-a-personal-research-story-387323983419">Static Code Analysis — A Personal Research Story</a> was originally published in <a href="https://medium.com/dipcode">Dipcode</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>