<?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: Thibaut F. Batale</title>
    <description>The latest articles on DEV Community by Thibaut F. Batale (@freedisch_10).</description>
    <link>https://dev.to/freedisch_10</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%2F983420%2F2781bc2f-eb5c-4689-9628-83d428c05a35.png</url>
      <title>DEV Community: Thibaut F. Batale</title>
      <link>https://dev.to/freedisch_10</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/freedisch_10"/>
    <language>en</language>
    <item>
      <title>Streamlining Security Scans with secureCodeBox: My Google Summer of Code Journey</title>
      <dc:creator>Thibaut F. Batale</dc:creator>
      <pubDate>Sun, 25 Aug 2024 19:04:20 +0000</pubDate>
      <link>https://dev.to/freedisch_10/streamlining-security-scans-with-securecodebox-my-google-summer-of-code-journey-989</link>
      <guid>https://dev.to/freedisch_10/streamlining-security-scans-with-securecodebox-my-google-summer-of-code-journey-989</guid>
      <description>&lt;p&gt;Hey there, I’m Thibaut Batale, and I’m thrilled to share my experience as a Google Summer of Code contributor with OWASP secureCodeBox. Being selected to participate in this program was a unique opportunity, but what excited me the most was being chosen for the very first project I applied to. I wanted to spend this summer battling with Kubernetes, and I got exactly what I wished for—and more.&lt;/p&gt;

&lt;p&gt;If you’re curious about my contributions during GSoC 2024, you can check out my &lt;a href="https://github.com/secureCodeBox/secureCodeBox/pulls?q=is:pr+author:Freedisch+is:closed" rel="noopener noreferrer"&gt;Pull Requests&lt;/a&gt; on GitHub. You can also find more details about my project by visiting the &lt;a href="https://summerofcode.withgoogle.com/programs/2024/projects/vFuhwP9m" rel="noopener noreferrer"&gt;Project link&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  My Project:  Introducing the secureCodeBox CLI
&lt;/h3&gt;

&lt;p&gt;Imagine this scenario: You want to assess your security environment by testing for various vulnerabilities. With secureCodeBox, you can launch multiple security tests. However, traditionally, you would first need to create a YAML file defining the scan parameters and then use the &lt;code&gt;kubectl&lt;/code&gt; command to apply that file. This process can be tedious and time-consuming, especially if you’re managing multiple scans.&lt;/p&gt;

&lt;p&gt;This is where the &lt;code&gt;scbctl&lt;/code&gt; CLI comes in. By providing a set of commands that interact directly with the secureCodeBox operator, the CLI tool simplifies and streamlines the process of managing security scans, making it more efficient and user-friendly.&lt;/p&gt;

&lt;p&gt;During the summer, I focused on two main goals: implementing the new commands and adding unit tests to ensure their reliability.&lt;/p&gt;

&lt;h3&gt;
  
  
  Commands Technical Implementation
&lt;/h3&gt;

&lt;p&gt;The commands implementation essential follows this workflow&lt;/p&gt;

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

&lt;h4&gt;
  
  
  &lt;strong&gt;1. Create Scan Command (&lt;code&gt;scbctl scan&lt;/code&gt;)&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;scbctl scan&lt;/code&gt; command was designed to simplify the initiation of new security scans. Instead of manually creating a YAML file and applying it with &lt;code&gt;kubectl&lt;/code&gt;, users can now start a scan directly from their terminal. This command interacts with the secureCodeBox operator by creating a &lt;code&gt;Scan&lt;/code&gt; custom resource (CR) in the specified namespace. The operator then processes this CR, triggering the appropriate scanner to run the specified tests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;scbctl scan nmap &lt;span class="nt"&gt;--&lt;/span&gt; scanme.nmap.org
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command creates a new Nmap scan targeting &lt;code&gt;scanme.nmap.org&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;🆕 Creating a new scan with name &lt;span class="s1"&gt;'nmap'&lt;/span&gt; and parameters &lt;span class="s1"&gt;'scanme.nmap.org'&lt;/span&gt;
🚀 Successfully created a new Scan &lt;span class="s1"&gt;'nmap'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;2. Observe Scan Command (&lt;code&gt;scbctl scan --follow&lt;/code&gt;)&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;--follow&lt;/code&gt; flag enhances the &lt;code&gt;scbctl scan&lt;/code&gt; command by providing real-time feedback on the progress of a scan. Once a scan is initiated, users can observe its progress directly from their terminal. This feature interacts with the secureCodeBox operator by streaming logs from the Kubernetes Job and Pods associated with the scan, giving users visibility into the scan’s status and results as they happen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;scbctl scan nmap &lt;span class="nt"&gt;--follow&lt;/span&gt; &lt;span class="nt"&gt;--&lt;/span&gt; scanme.nmap.org
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command initiates a scan and follows its progress in real-time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Found 1 job&lt;span class="o"&gt;(&lt;/span&gt;s&lt;span class="o"&gt;)&lt;/span&gt;
Job: scan-nmap-jzmtq, Labels: map[securecodebox.io/job-type:scanner]
scan-nmap-jzmtq📡 Streaming logs &lt;span class="k"&gt;for &lt;/span&gt;job &lt;span class="s1"&gt;'scan-nmap-jzmtq'&lt;/span&gt; and container &lt;span class="s1"&gt;'nmap'&lt;/span&gt;
Starting Nmap 7.95 &lt;span class="o"&gt;(&lt;/span&gt; https://nmap.org &lt;span class="o"&gt;)&lt;/span&gt; at 2024-08-23 11:59 UTC
Nmap scan report &lt;span class="k"&gt;for &lt;/span&gt;scanme.nmap.org &lt;span class="o"&gt;(&lt;/span&gt;45.33.32.156&lt;span class="o"&gt;)&lt;/span&gt;
Host is up &lt;span class="o"&gt;(&lt;/span&gt;0.33s latency&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
Other addresses &lt;span class="k"&gt;for &lt;/span&gt;scanme.nmap.org &lt;span class="o"&gt;(&lt;/span&gt;not scanned&lt;span class="o"&gt;)&lt;/span&gt;: 2600:3c01::f03c:91ff:fe18:bb2f
Not shown: 996 closed tcp ports &lt;span class="o"&gt;(&lt;/span&gt;conn-refused&lt;span class="o"&gt;)&lt;/span&gt;
PORT      STATE    SERVICE
22/tcp    open     ssh
80/tcp    filtered http
9929/tcp  open     nping-echo
31337/tcp open     Elite

Nmap &lt;span class="k"&gt;done&lt;/span&gt;: 1 IP address &lt;span class="o"&gt;(&lt;/span&gt;1 host up&lt;span class="o"&gt;)&lt;/span&gt; scanned &lt;span class="k"&gt;in &lt;/span&gt;30.19 seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;3. Trigger Scan Command (&lt;code&gt;scbctl trigger&lt;/code&gt;)&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;scbctl trigger&lt;/code&gt; command allows users to manually trigger a &lt;code&gt;ScheduledScan&lt;/code&gt; resource. Scheduled scans are designed to run at predefined intervals, but there are times when an immediate execution is required. This command interacts with the secureCodeBox operator by invoking the &lt;code&gt;ScheduledScan&lt;/code&gt; resource and creating a new &lt;code&gt;Scan&lt;/code&gt; based on the schedule’s configuration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;scbctl trigger nmap &lt;span class="nt"&gt;--namespace&lt;/span&gt; foobar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command triggers the &lt;code&gt;nmap&lt;/code&gt; scheduled scan immediately.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;triggered new Scan &lt;span class="k"&gt;for &lt;/span&gt;ScheduledScan &lt;span class="s1"&gt;'nmap'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;4. Cascade Visualization Command (&lt;code&gt;scbctl cascade&lt;/code&gt;)&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;scbctl cascade&lt;/code&gt; command provides a visualization of cascading scans—scans that are automatically triggered based on the results of a previous scan. This command interacts with the secureCodeBox operator by querying all &lt;code&gt;Scan&lt;/code&gt; resources in a given namespace and identifying relationships based on the &lt;code&gt;ParentScanAnnotation&lt;/code&gt;. It then generates a hierarchical tree that visually represents these cascading relationships.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;scbctl cascade
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command visualizes the cascading relationships between scans in the current namespace.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Scans
├── initial-nmap-scan
│   ├── follow-up-vulnerability-scan
│   │   └── detailed-sql-injection-scan
└── another-initial-scan
    └── another-follow-up-scan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Test Coverage Implementation
&lt;/h3&gt;

&lt;p&gt;Testing was a crucial part of the development process, especially considering the complexity of the CLI commands and their interactions with the secureCodeBox (SCB) operator. Achieving an overall test coverage of 78% involved writing extensive unit tests that validated the behavior of each command and ensured they interacted correctly with the Kubernetes resources.&lt;/p&gt;

&lt;h4&gt;
  
  
  Mocking the Kubernetes Client
&lt;/h4&gt;

&lt;p&gt;To simulate the Kubernetes environment and test the SCB commands without deploying them on an actual cluster, I used the &lt;code&gt;fake.Client&lt;/code&gt; from the &lt;code&gt;controller-runtime&lt;/code&gt; library. This allowed me to create a mock client that mimicked the behavior of the Kubernetes API, enabling thorough testing of the command interactions.&lt;/p&gt;

&lt;p&gt;Here’s an example of a test case for the &lt;code&gt;scbctl scan&lt;/code&gt; command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;testcases&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;testcase&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;          &lt;span class="s"&gt;"Should create nmap scan with a single parameter"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;          &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"scan"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"nmap"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"--"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"scanme.nmap.org"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="n"&gt;expectedError&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;expectedScan&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;expectedScan&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;       &lt;span class="s"&gt;"nmap"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;scanType&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;   &lt;span class="s"&gt;"nmap"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;namespace&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;  &lt;span class="s"&gt;"default"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;parameters&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"scanme.nmap.org"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="c"&gt;// Additional test cases...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this test, I defined different scenarios to validate the command's behavior. Each test case included the expected arguments, any expected errors, and the expected state of the scan resource after execution.&lt;/p&gt;

&lt;h4&gt;
  
  
  Testing Command Behavior
&lt;/h4&gt;

&lt;p&gt;The tests focused on validating that the CLI commands correctly created the necessary Kubernetes resources, such as &lt;code&gt;Scan&lt;/code&gt; objects. For example, the &lt;code&gt;scbctl scan&lt;/code&gt; command was tested to ensure it created a scan with the correct type, parameters, and namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;tc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;expectedScan&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;scans&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ScanList&lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;
    &lt;span class="n"&gt;listErr&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Background&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;scans&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Nil&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;listErr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"failed to list scans"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scans&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Items&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"expected 1 scan to be created"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;scan&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;scans&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Items&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;expectedScan&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scan&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;expectedScan&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scan&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Namespace&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;expectedScan&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scanType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scan&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Spec&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ScanType&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;expectedScan&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parameters&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scan&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Spec&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Parameters&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code snippet checks that the correct &lt;code&gt;Scan&lt;/code&gt; object was created in the Kubernetes cluster, verifying that the CLI command worked as intended.&lt;/p&gt;

&lt;p&gt;By running these tests and implementing these scenarios, I ensured that the &lt;code&gt;scbctl&lt;/code&gt; tool behaved as expected under various conditions, contributing to the robustness of the secureCodeBox CLI tool.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenges
&lt;/h3&gt;

&lt;p&gt;This summer wasn’t without its challenges. Balancing time became difficult when my school resumed, and I encountered several technical hurdles along the way. The most notable was implementing the &lt;code&gt;--follow&lt;/code&gt; flag. Initially, we used the controller-runtime, but it lacked the necessary support for streaming logs. We considered switching to the &lt;code&gt;go-client&lt;/code&gt;, but it introduced inconsistencies that could delay the project. After extensive discussions with my mentor &lt;a href="https://github.com/J12934" rel="noopener noreferrer"&gt;Jannik Hollenbach&lt;/a&gt;, we decided to defer this feature for future implementation. This experience taught me the importance of thorough research and adaptability in problem-solving.&lt;/p&gt;

&lt;h3&gt;
  
  
  Overall Experience and Future Prospects
&lt;/h3&gt;

&lt;p&gt;One of the most rewarding aspects of working on this project was the continuous learning curve. Whether diving into the complexities of the codebase or exploring the broader capabilities of secureCodeBox, there was always something new to discover. This constant evolution is what made the project so fascinating for me.&lt;/p&gt;

&lt;p&gt;As the project reaches completion, maintaining and building upon these efforts is crucial. Looking ahead, I plan to focus on integrating monitoring features using the &lt;code&gt;controller-runtime&lt;/code&gt; whenever its available, which will enhance the tool's ability to provide real-time feedback. Additionally, I aim to refine existing commands, particularly the &lt;code&gt;cascade&lt;/code&gt; command, by adding flags to display the status of each scanner. This will provide users with more detailed insights into their scans. My commitment to improving and maintaining the project will ensure its continued success and relevance in the future.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>kubernetes</category>
      <category>devops</category>
    </item>
    <item>
      <title>Embarking on a Professional Growth Adventure: Insights from my LFX Mentorship Program at LitmusChaos</title>
      <dc:creator>Thibaut F. Batale</dc:creator>
      <pubDate>Sun, 03 Dec 2023 17:08:30 +0000</pubDate>
      <link>https://dev.to/freedisch_10/embarking-on-a-professional-growth-adventure-insights-from-my-lfx-mentorship-program-at-litmuschaos-5cbc</link>
      <guid>https://dev.to/freedisch_10/embarking-on-a-professional-growth-adventure-insights-from-my-lfx-mentorship-program-at-litmuschaos-5cbc</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Linux Foundation Mentorship Program offers a dynamic 12-week internship where participants engage in hands-on projects while receiving a stipend. When I first applied for the LFX mentorship program, I was a novice in the field and had no idea how this experience would impact my professional growth. Looking back now, I can confidently say that my journey within the LFX program has been transformative, teaching me the power of perseverance and learning.&lt;/p&gt;

&lt;p&gt;One of the main reasons I was drawn to the LFX mentorship program was the fact that the project on which the mentee will be working was already set before the beginning of the application process. This allowed me to choose a project that aligned with my interests and skill set.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Jjt7MYxt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5w65b0azk60ri95sj041.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Jjt7MYxt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5w65b0azk60ri95sj041.png" alt="Image description" width="800" height="454"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Early Challenges and Overcoming Them&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;My initial applications to the LFX program back in 2022 were unsuccessful, which served as a stark reminder of the competitive nature of this program. However, I refused to let the setbacks deter me and immersed myself in various open-source communities. This period was crucial for me as I honed my skills, expanded my understanding, and became more comfortable diving into any codebase quickly. This groundwork enabled me to craft a compelling proposal for the LFX program in Fall 2023, leading to my acceptance into my first-choice project – a perfect match for an area I was looking forward to improving.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZHsFQeH5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v25ecv1989sf5v58hazz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZHsFQeH5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v25ecv1989sf5v58hazz.png" alt="Image description" width="800" height="326"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Mentorship Experience&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;My mentors, &lt;a href="https://mentorship.lfx.linuxfoundation.org/mentor/21102070-974f-49fb-9a5c-08950670f081"&gt;Sayan Mondal&lt;/a&gt; and &lt;a href="https://mentorship.lfx.linuxfoundation.org/mentor/e967ae3d-e016-432e-b0df-bced2c38860f"&gt;Saranya Jena&lt;/a&gt;, were instrumental in my journey, providing guidance and support throughout the program. Our weekly meetings became a cornerstone of my learning process, where I shared progress, discussed challenges, and received tasks for the upcoming week. These tasks were primarily focused on adding unit tests for both the authentication server and unit, incorporating a new documentation for Chaoscenter API. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f9eaI6aV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vrcdwohuorwx2tfxhlta.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f9eaI6aV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vrcdwohuorwx2tfxhlta.png" alt="Image description" width="800" height="747"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After a quick adaptation, I got my first task in the second week: to modify the code architecture to interface model for the &lt;a href="https://github.com/litmuschaos/litmus/blob/master/chaoscenter/graphql/server/pkg/environment/handler/handler.go"&gt;environment service package&lt;/a&gt; and write test cases for it. Which I successfully accomplished. The satisfaction of having my first contributions merged was unparalleled.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cRkuBKar--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2hwowuow86olxpqsnf3e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cRkuBKar--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2hwowuow86olxpqsnf3e.png" alt="Image description" width="800" height="158"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Test Cases for Auth server&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;1. Modifying the code architecture to interface model:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The first step in implementing test cases for the authentication server was to modify the code architecture to interface model. This was done to ensure that the code was modular and easy to test. This made it easier to test each piece of code individually and ensure that it was working as expected.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;2. Creating a mock client of the services used by both GRPC and REST API:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The second step was to create a mock client of the services used by both GRPC and REST API. This was done to ensure that the test cases were isolated from the actual services. By creating a mock application service, I could simulate the behavior of the services without actually calling them.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;3. Writing test cases to improve test coverage:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The final step was to write test cases to improve test toward improving the coverage. For each test, I created a new instance of the &lt;strong&gt;MockApplicationService&lt;/strong&gt; and then passed a data test for different scenarios. One major issue I faced during this work was that the first scenario tested was directly impacting the new service instantiated from the mocked was affected by the first scenario that was run, so I was forced to use one scenario by test cases, but later on, I figured out that each scenario should have their one instance of the &lt;strong&gt;MockApplicationService&lt;/strong&gt;, from there I was able created more a test cases and improved the coverage. Here is that particular &lt;a href="https://github.com/litmuschaos/litmus/pull/4238"&gt;PR&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tests Cases for Frontend Views Components&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;LitmusChaos uses a &lt;a href="https://github.com/litmuschaos/litmus/blob/master/chaoscenter/web/src/utils/testUtils.tsx"&gt;TestWrapper&lt;/a&gt; to encapsulate most of the dependencies that need to be mocked. For the first tests I wrote, I had to mock 2 main dependencies, the &lt;strong&gt;ReactqueryProvider&lt;/strong&gt; and &lt;strong&gt;ApolloClient&lt;/strong&gt;, but in order to ensure consistency and simplicity across the test cases, I implemented them into the TestWrapper and used the TestWrapper to wrap each component I wanted to test.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fQqgRfPz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fzoa60czldvh2mj6qyhk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fQqgRfPz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fzoa60czldvh2mj6qyhk.png" alt="Image description" width="601" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Incorporating API documentation for ChaosCenter API&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For this, I decided to use an OPENAPI SPEC that will be used to automatically generate API documentation for each handler. For this work, I discovered a library called &lt;a href="https://github.com/swaggo/swag"&gt;swaggo&lt;/a&gt; that I used to define annotations, from the description of the handler to defining responses. I created a doc file that lists all responses and errors from each endpoint, and to finish, I used &lt;a href="https://goswagger.io/"&gt;go-swagger&lt;/a&gt; library to generate the API doc from the OPENAPI SPEC file generated by swaggo. &lt;a href="https://github.com/litmuschaos/litmus/blob/master/chaoscenter/authentication/DOC_SETUP.md"&gt;Click here&lt;/a&gt; to learn more about the new API documentation of Litmus Chaoscenter&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Achievements and Realizations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Throughout the program, I raised nine PRs, with &lt;a href="https://github.com/litmuschaos/litmus/pulls?q=is%3Apr+author%3AFreedisch+is%3Aclosed"&gt;eight successfully merged and one under review&lt;/a&gt;. My work not only increased the backend coverage from 0 to 25.48% and enhanced the frontend coverage from 0 to 14.56%. One of my essential suggestions was the implementation of a new workflow to track test coverage in the Chaoscenter auth server. My contributions laid a foundation for future enhancements by other contributors. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZDrD-c08--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ywkic66kt0spo4w2sqs5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZDrD-c08--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ywkic66kt0spo4w2sqs5.png" alt="Image description" width="800" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Moreover, I was able to register all 34 REST endpoints defining both Responses and the Return Error, which enables contributors to easily update the documentation page when a new endpoint is created just by modifying the annotations. This simplified the documentation process and made it more accessible for newcomers and existing contributors.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aMwhQ6aF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/72nu0ul4eeffamol0qir.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aMwhQ6aF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/72nu0ul4eeffamol0qir.png" alt="Image description" width="800" height="942"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Challenges Faced&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The journey was not without its challenges. One of the major issues I encountered during that time was writing positive test cases. I struggled to write positive tests for the GRPC and environment handler. I tried different approaches to mocking most of the services used by the handler, but after doing unsuccessful research on the internet, I asked for help from the community. I got referred to different resources on how to &lt;a href="https://semaphoreci.com/community/tutorials/test-driven-development-of-go-web-applications-with-gin"&gt;mock handlers using GIN&lt;/a&gt;. All these resources were super helpful and helped me write positive test cases and &lt;a href="https://github.com/litmuschaos/litmus/pull/4175"&gt;close this PR&lt;/a&gt;. That taught me that even though you have to figure out things on your own, it is OKAY to ask for help. It was my first time writing unit tests at this scale for a large project, but I learned, researched, and asked for help from my mentors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What's Next?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After spending the whole fall working on this project, I plan to continue contributing to the testing strategy of LimusChaoscenter by helping new contributors who want to contribute to the project. I currently have one PR pending and a testing strategies documentation for Chaoscenter frontend to add. After that, I will maintain existing test cases and work on new ones.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZIaTEFog--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/32a5ai2ehkislr45fpy5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZIaTEFog--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/32a5ai2ehkislr45fpy5.png" alt="Image description" width="800" height="115"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The LFX mentorship program has been the most rewarding experience of my year. It has transformed me from a beginner in open-source to a confident contributor capable of making meaningful improvements. This experience enhanced my technical understanding of writing test cases, improved my Golang skills, and helped me gain insights into my code. I have learned that anything is achievable with the right amount of energy and time. Don't hesitate to &lt;a href="https://mentorship.lfx.linuxfoundation.org/#projects_all"&gt;submit&lt;/a&gt; your proposal for next quarter.&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

&lt;p&gt;By Magnim Thibaut F. Batale&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/in/magnim-thibaut-batale-905843208/"&gt;Linkedin&lt;/a&gt; | &lt;a href="https://github.com/Freedisch"&gt;Github&lt;/a&gt;&lt;br&gt;
LFX'23 Mentee at &lt;a href="https://litmuschaos.io/"&gt;Litmus&lt;/a&gt;&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
