<?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[Stories by Hema Deepika on Medium]]></title>
        <description><![CDATA[Stories by Hema Deepika on Medium]]></description>
        <link>https://medium.com/@hemadeepikagorre?source=rss-e3cff15f4fec------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hvTQ1PZDSa2mVrLdgP2iCA@2x.jpeg</url>
            <title>Stories by Hema Deepika on Medium</title>
            <link>https://medium.com/@hemadeepikagorre?source=rss-e3cff15f4fec------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:27:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hemadeepikagorre/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building Secure Software: Continuous Library Monitoring with WhiteSource (Mend)]]></title>
            <link>https://medium.com/@hemadeepikagorre/building-secure-software-continuous-library-monitoring-with-whitesource-mend-9c830d96756e?source=rss-e3cff15f4fec------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c830d96756e</guid>
            <category><![CDATA[whitesource]]></category>
            <category><![CDATA[vulnerability-management]]></category>
            <category><![CDATA[security-analysis]]></category>
            <category><![CDATA[golang-tools]]></category>
            <category><![CDATA[scanning-tool]]></category>
            <dc:creator><![CDATA[Hema Deepika]]></dc:creator>
            <pubDate>Fri, 05 Jul 2024 15:17:37 GMT</pubDate>
            <atom:updated>2024-07-05T15:27:11.747Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Scenario:</strong></p><p>You’re developer building a new e-commerce app in any language (ex- Golang). You have decided to use any popular open-source library called &lt;<em>validator</em>&gt; for use input validation. This library seems well maintained and has great features.</p><p><strong>Potential Vulnerability:</strong></p><p>Unfortunately, the latest version of this library has a critical vulnerability. This allows attackers to bypass the validator check and potentially inject malicious code into your application. This code could lead to stealing data.</p><p><strong>The problem :</strong></p><p>You might not be aware of this vulnerability, especially if you haven’t recently checked for updates on &lt;<em>validator</em>&gt; library. Even if you do a manual check, staying updated on vulnerabilities across all your dependencies can be time-consuming.</p><p><strong>Whitesource (Mend) comes to rescue:</strong></p><blockquote><strong>Automatic vulnerability detection</strong>: During the development process whitesource can scan the dependencies and identifies the vulnerabilities.</blockquote><blockquote><strong>Vulnerability Alert:</strong> It then checks its vulnerability database and discovers the critical vulnerability in version. WhiteSource (Mend) promptly alerts you about this security risk.</blockquote><blockquote><strong>Remediation Steps</strong>: WhiteSource (Mend) recommends immediate action. It suggests upgrading to new version which patches the vulnerability. It provides the solution on how to fix this.</blockquote><blockquote><strong>Continuous Monitoring:</strong> WhiteSource (Mend) continues to monitor your dependencies for new vulnerabilities. This proactive approach ensures your application stays secure.</blockquote><p><strong>The outcome:</strong></p><p>By using the whitesource with your application , you are aware of these vulnerabilities and security risks before it can exploit. You can therefore upgrade,safeguard your application from potential risks.</p><p><strong>How to integrate Whitesource with your application</strong></p><p>There are many ways of integrating this with your app. In this blog we talk about integrating with CI/CD pipelines.</p><p><strong>Steps to follow:</strong></p><ol><li>create account on mend.io</li><li>During account setup, you will get the api keys /tokens needed for integration</li><li>Within your ci/cd pipeline of your application, whitesource can be used as a resource (docker image)</li><li>configuration parameters : You need to configure settings within Mend.io to define which projects to scan, how to handle vulnerabilities, and what policies to enforce.</li></ol><p><strong>Some key configuration parameters include -</strong></p><blockquote>“apiKey, userkey” : White setting up your mend.io account, you will receive the keys. This is used to configure whitesource (mend) from your pipeline</blockquote><blockquote>“updateInventory: true” — Once the mend scans the libraries, this will update the results in the UI.</blockquote><blockquote>“productName:” — you have to provide the productName. This could be anything</blockquote><blockquote>“wss.url:” — This is the whitesource agent url to communicate with the mend.io server.</blockquote><blockquote>“archiveExtractionDepth: “ — This controls how deeply the Mend.io agent delves into nested archive files during the scanning process.If your app have app/dir1/dir2/file1.txt. Then your archiveExtractionDepth is 3.</blockquote><blockquote>If you app have app/dir11/dir12/file1.txt and app/dir22/dir3/dir4/file1.txt then the archiveExtractionDepth is 4. You will have to check the highest nested directories.</blockquote><blockquote>“go.modules.resolveDependencies:true” — This will ensure accurate and efficient dependency resoultion during security scans especially for Go project that use Go modules</blockquote><blockquote>“go.modules.removeDuplicateDependencies:true” — This will remove if there are any dependency that is using multiple times</blockquote><blockquote>“go.modules.resolveTestDependencies:true” — It includes the dependencies that are used in unit tests.</blockquote><blockquote>“Incudes” — This will ensure what files to be included in scan.</blockquote><blockquote>“Excludes” — This will exclude the files to scan</blockquote><p>The above three configuration parameters are used mainly for Go projects that is using Go modules. Based on the language you have chosen for your application some of these settings may vary.</p><p>Please refer the below page for more parameters</p><p><a href="https://docs.mend.io/bundle/unified_agent/page/unified_agent_configuration_parameters.html">https://docs.mend.io/bundle/unified_agent/page/unified_agent_configuration_parameters.html</a></p><p>Example on where and how to use the whitesource in pipeline</p><pre>- name: whitesource<br>    type: docker-image<br>    source:<br>      repository: whitesource-image<br><br>- name: whitesource<br>    type: whitesource<br>    source:<br>      apiKey: <br>      userKey: <br>      updateInventory: <br>      productName: <br>      wss.url: <br>      archiveExtractionDepth: <br>      updateEmptyProject: <br>      go.modules.resolveDependencies: <br>      go.modules.removeDuplicateDependencies: <br>      go.modules.includeTestDependencies: <br>      includes:<br>      excludes:<br></pre><p>You have to fill with the necessary values and you could change the parameters based on your application.</p><p>Once the configuration is done, you have to add the put step to the existing job or create a new</p><pre> put: whitesource<br>    params:<br>       dir: <br>       config:<br>           projectName: </pre><p>The above lines should be added when the code is available</p><p><strong>example</strong>- after running unit-tests or get the code in the job.</p><p>For more details on how to configure, please refer the official documentation. This is customized based on your application language. You will have to pass the github token of your application incase of any issues in scanning dependency.</p><p><a href="https://www.mend.io/">Mend.io (formerly WhiteSource) - Start Managing Application Risk</a></p><p><a href="https://docs.mend.io/bundle/unified_agent/page/unified_agent_configuration_parameters.html">https://docs.mend.io/bundle/unified_agent/page/unified_agent_configuration_parameters.html</a></p><p><strong>Conclusion</strong> -</p><p>This highlights the importance of using tools like WhiteSource (Mend) to manage open-source dependencies securely. It automates vulnerability detection, saving you time and effort. More importantly, it helps you proactively address security risks before they can exploit.</p><p><strong>In short , instead of manually checking for security patches on libraries and updating it. This tool will scan for you and let you know on updates before it is too late.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c830d96756e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Go Unit Tests vs Go Fuzz Tests]]></title>
            <link>https://medium.com/@hemadeepikagorre/go-unit-tests-vs-go-fuzz-tests-1bea1063c245?source=rss-e3cff15f4fec------2</link>
            <guid isPermaLink="false">https://medium.com/p/1bea1063c245</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[go-testing]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <dc:creator><![CDATA[Hema Deepika]]></dc:creator>
            <pubDate>Sun, 02 Jun 2024 10:51:58 GMT</pubDate>
            <atom:updated>2024-06-02T11:00:25.408Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>Imagine, you are building a car toy. Unit tests are like checking each part of the car functioning separately e.g. wheels, engine, etc.</p><p>By testing each part individually, you can detect problems early and make sure the whole car works as expected.</p><p>That’s what go tests does to your code. They check each function or piece of code to make sure it does what it supposed to do, before you put everything together</p><p>In this blog, we will see how to write sample unit tests step-by-step and run series of tests on the sample code.</p><p>create a file in your project directory name of your choice that ends with .go</p><p>e.g- emptyString.go</p><pre>package main<br>import &quot;fmt&quot;<br>func isEmpty(str string) bool {<br>        return len(str) == 0  <br>}<br>func main(){<br>      var input string<br>        fmt.Print(&quot;Enter a string: &quot;)<br>        fmt.Scanln(&amp;input) <br>       if isEmpty(input) {<br>                fmt.Println(&quot;The string is empty.&quot;)<br>        } else {<br>                fmt.Println(&quot;The string is not empty.&quot;)<br>        }  <br>}</pre><p>Now, we will write a unit tests for the above program or function</p><p>create a file that ends with “ _test.go”</p><pre>package main<br>import (<br>        &quot;testing&quot;<br>)<br><br>func TestIsEmpty(t *testing.T) {<br>        tests := []struct {  //1<br>                str string<br>                expected bool<br>        }{<br>                {&quot;&quot;, true},  // Empty string<br>                {&quot; &quot;, true}, // String with only whitespace<br>                {&quot;hello&quot;, false}, // Non-empty string<br>        }<br>        for _, test := range tests {<br>                result := IsEmpty(test.str) //2<br>                if result != test.expected {  //3<br>                        t.Errorf(&quot;IsEmpty(%q) expected %t, got %t&quot;, test.str, test.expected, result)<br>                }<br>        }<br>}</pre><p>The function name should starts with Test that takes *testing.T argument</p><p>In comment 1 , we are defining input and also the expected result</p><p>In comment 2, we are calling the actual function with the input string and get the result</p><p>In comment 3, compare the result with expected result that is declared in comment 1</p><p>If both are different then there’s likely a bug in your code. Fix the code to ensure it produces the actual results</p><p>useful commands -</p><ol><li>go test :Compile all the test files, Runs test binaries, provides summary in console whether it’s PASS or FAIL.</li><li>go test -v: Runs all tests and provides verbose output, including the names of each test and their individual results.</li><li>go test -count=n : Runs each test n times</li><li>go test -timeout=duration : Sets a timeout for each duration</li><li>go test -cover : Generate code coverage reports</li><li>go test -v -run &lt;TestFunc&gt; : Will run only specified TestFunc</li></ol><p><strong>Disadvantages of unit tests :</strong></p><blockquote><em>1. Primarly focuses on induvidual parts of code and may not catch issues</em></blockquote><blockquote><em>2. Maintaining and updating unit tests as your code evolves over time can be a challenge</em></blockquote><h3>Fuzz Testing</h3><p><strong>Introduction</strong></p><p>Fuzz testing is a way to find any code vulnerabilities, unexpected behavior of your code. It works by feeding your code many randomly generated ,malformed inputs to cover the edge cases, potential causes that might not get caught using traditional go unit tests.</p><p>Basic terminologies to understand fuzz tests</p><ol><li>Fuzzing : The general term for the technique of feeding a program with unexpected or invalid inputs to identify potential issues.</li><li>Fuzzer : The program or tool that generates and delivers these unexpected inputs.</li><li>Corpus : A collection of initial test cases used to seed the fuzzer.</li><li>Seed : A initial test cases in the corpus</li></ol><pre>package main<br>import (<br>        &quot;testing&quot;<br>)<br>func IsEmpty(str string) bool {<br>        return len(str) == 0<br>}<br>func FuzzIsEmpty(f *testing.F) { //1<br>        f.Add([]byte{})  //2<br>        f.Add([]byte(&quot; &quot;)) <br>        f.Add([]byte(&quot;hello&quot;)) <br>        for i := 0; i &lt; 100; i++ {<br>                // Generate random string<br>                data := make([]byte, i) <br>                for j := range data {<br>                        data[j] = byte(f.Rand.Intn(256)) // 3 Random byte value<br>                }<br>                f.Add(data) //5<br>        }<br>        f.Fuzz(func(t *testing.T, data []byte) { //6<br>                str := string(data)<br>                if IsEmpty(str) != (len(str) == 0) {  //7<br>                        t.Errorf(&quot;IsEmpty(%q) expected %t, got %t&quot;, str, len(str) == 0, IsEmpty(str))<br>                }<br>        })<br>}</pre><p>comment 1 : Function starts with Fuzz just instead of Test</p><p>comment 2 : Initial test cases that seed to corpus</p><p>comment 3 : For loop runs 100 types to generate random byte value</p><p>comment 4 : adding these random generated inputs to fuzzer.</p><p>comment 5 : This function is called Fuzz target and the arguments are called as fuzzing arguments expect t. These arguments will be same as a seed to corpus (comment 2).</p><p>f.Fuzz will iterate all the generated data and call the IsEmpty function and get the result.</p><p>Comment 7 : Checks if the expected result matches with actual result that is returned and report error if there is a mismatch</p><p><strong>Commands</strong> —</p><ol><li>go test -fuzz=FuzzIsEmpty : This is the primary command for running fuzz tests</li><li>go test -fuzz=FuzzIsEmpty -v -fuzztime=60 : To set the duration. -v gives the detailed output on running test case</li></ol><p><strong>Advantages of Fuzz tests</strong></p><blockquote><em>Finds edge cases and unexpected behavior that might be missed by traditional unit tests.</em></blockquote><blockquote><em>Requires minimal upfront effort to set up and can run continuously for extended periods</em></blockquote><p><strong>Conclusion</strong> :</p><p>Both unit testing and fuzz testing are crucial for ensuring the quality and security of your Go code. Unit testing provides a solid foundation for verifying the correctness of individual code units, while fuzz testing helps uncover unexpected behavior and potential vulnerabilities. The best approach is to use a combination of both techniques to achieve comprehensive testing coverage.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1bea1063c245" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>