<?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: Renjith Ravindranathan</title>
    <description>The latest articles on DEV Community by Renjith Ravindranathan (@mysticrenji).</description>
    <link>https://dev.to/mysticrenji</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%2F453432%2Fd9ac53d5-8bd7-414d-b613-0affe37b8b9e.jpeg</url>
      <title>DEV Community: Renjith Ravindranathan</title>
      <link>https://dev.to/mysticrenji</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mysticrenji"/>
    <language>en</language>
    <item>
      <title>Static Code Analysis using Semgrep App</title>
      <dc:creator>Renjith Ravindranathan</dc:creator>
      <pubDate>Thu, 20 Oct 2022 10:14:00 +0000</pubDate>
      <link>https://dev.to/mysticrenji/static-code-analysis-using-semgrep-app-2168</link>
      <guid>https://dev.to/mysticrenji/static-code-analysis-using-semgrep-app-2168</guid>
      <description>&lt;p&gt;In this short article, we will explore the static code analysis capability of Semgrep. Semgrep is a fast, open-source, static analysis tool that supports most modern languages. It works on a set of rules and rules are customizable as well according to your requirements. The tool is available in the CLI (OSS) version as well as in the SaaS version(Semgrep App). Also, it is very flexible to integrate with your CI pipelines. Let's look at integrating Semgrep with GitLab.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pre-requisites&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://gitlab.com/users/sign_up"&gt;Gitlab account&lt;/a&gt;&lt;br&gt;
&lt;a href="https://semgrep.dev/login"&gt;Semgrep App Account&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's build&lt;/strong&gt;&lt;br&gt;
Semgrep works in such a way that the whole code analysis is done in the agents aka build machines and no sensitive data is being sent to the cloud. The only requirement is to generate an API TOKEN from Semgrep App and pass it to your GitLab pipelines, so they can talk with each other.&lt;/p&gt;

&lt;p&gt;You can create an API token from this &lt;a href="https://semgrep.dev/orgs/mysticrenji/settings/tokens"&gt;link&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Once you have the token generated, the next step is to add the API TOKEN to the GitLab Variables — SEMGREP_APP_TOKEN in your project&lt;/p&gt;

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

&lt;p&gt;Let's look at the GitLab pipelines. The pipeline has been just to do the static code analysis for illustration purposes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stages:
  - build

# Semgrep static code analysis
semgrep:
  stage: build
  # A Docker image with Semgrep installed.
  image: returntocorp/semgrep
  # Run the "semgrep ci" command on the command line of the docker image.
  script: semgrep ci

  rules:
  # Scan changed files in MRs, (diff-aware scanning):
  - if: $CI_MERGE_REQUEST_IID

  # Scan mainline (default) branches and report all findings.
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

  variables:
    # Connect to Semgrep App through your SEMGREP_APP_TOKEN.
    # Generate a token from Semgrep App &amp;gt; Settings
    # and add it as a variable in your GitLab CI/CD project settings.
    SEMGREP_APP_TOKEN: $SEMGREP_APP_TOKEN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt;&lt;br&gt;
For scanning, I am utilizing an old repository hosted &lt;a href="https://gitlab.com/renjithvr11/flask-mysql-k8s"&gt;here&lt;/a&gt; that consists of Python scripts, Dockerfiles, and Kubernetes Manifests. The outcome is quite nice, as Semgrep was able to catch a few common mistakes in the development. The dashboard shows an overall summary of the findings.&lt;/p&gt;

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

&lt;p&gt;Let's zoom in on one of the findings run-as-non-root . Typically this message is raised when you have allowed your container to be run as root or in order words you have not specified the user by which the container is executed.&lt;/p&gt;

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

&lt;p&gt;There is a rule editor which shows the pre-defined rules, against which your code is compared. You may go around it to see, how it evaluates the condition.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Semgrep is a good tool to integrate with and it can be integrated with major CI/CD engines like GitLab, GitHub Actions, Azure DevOps, Jenkins, CircleCI, Bitbucket Pipelines, etc. It is worth checking out if it suits your organization's requirements. That’s all for now. Hope you find the article useful and feedbacks are always welcome. Cheers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;References&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://gitlab.com/renjithvr11/flask-mysql-k8s"&gt;GitLab Repo&lt;/a&gt;&lt;br&gt;
&lt;a href="https://semgrep.dev/docs/"&gt;Semgrep Docs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In case of any queries, please feel to connect me via the below links&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/in/rvr88/"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/mysticrenji"&gt;Twitter&lt;/a&gt;&lt;br&gt;
&lt;a href="https://renjithvr11.medium.com/"&gt;Medium&lt;/a&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>staticcodeanalysis</category>
      <category>programming</category>
      <category>devops</category>
    </item>
    <item>
      <title>Essential plugins for Kubectl CLI</title>
      <dc:creator>Renjith Ravindranathan</dc:creator>
      <pubDate>Thu, 20 Oct 2022 06:57:17 +0000</pubDate>
      <link>https://dev.to/mysticrenji/essential-plugins-for-kubectl-cli-5een</link>
      <guid>https://dev.to/mysticrenji/essential-plugins-for-kubectl-cli-5een</guid>
      <description>&lt;p&gt;This is a short article about handy plugins that can be used along with kubectl CLI , which helps you to can reduce a few of your operational tasks from an admin perspective. Basically, we can extend the capabilities kubectl with the power of plugins, like checking the deprecations of components in the cluster or SSHing to the nodes.&lt;/p&gt;

&lt;p&gt;We can install plugins using a plugin manager called krew and there are quite a few available on the website listed here as well. Let's look at how we can get started with plugins :)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setup&lt;/strong&gt;&lt;br&gt;
The plugins are added using krew and the primary requirement is to install krew them in the system. You can use the below code snippet in Mac/Linux to install it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(
  set -x; cd "$(mktemp -d)" &amp;amp;&amp;amp;
  OS="$(uname | tr '[:upper:]' '[:lower:]')" &amp;amp;&amp;amp;
  ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" &amp;amp;&amp;amp;
  KREW="krew-${OS}_${ARCH}" &amp;amp;&amp;amp;
  curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" &amp;amp;&amp;amp;
  tar zxvf "${KREW}.tar.gz" &amp;amp;&amp;amp;
  ./"${KREW}" install krew
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you have krew it in the system, now it is time to install the additional plugins.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Plugins&lt;/strong&gt;&lt;br&gt;
There are many plugins available in the OSS GitHub repos, but below are some of my personal favorites.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Kubepug&lt;/strong&gt;&lt;br&gt;
KubePug/Deprecations is intended to be a kubectl plugin, which:&lt;/p&gt;

&lt;p&gt;Downloads a swagger.json from a specific Kubernetes version&lt;br&gt;
Parses this Json finding deprecation notices&lt;br&gt;
Verifies the current kubernetes cluster or input files checking whether exists objects in this deprecated API Versions, allowing the user to check before migrating&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl krew install deprecations
#Usage
kubepug --k8s-version=v1.18.6 # Will verify the current context against v1.18.6 swagger.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. net-forward&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Simple plugin that lest you create a local port listener on your personal machine that redirects to an arbitrary TCP service that the Cluster can see. This is similar to kubectl port-forward without the restriction that forwarding can only use Pods or Services as destinations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl krew install net-forward

#Usage
kubectl net-forward -i 169.254.169.254 -p 3389 -l 3389
I personally use this a lot to debug issues related to environment specific inside the Windows/Linux nodes.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Please feel to try out the plugins on the krew website also, as there are other plugins that could be beneficial to your work.&lt;br&gt;
Hope this info was helpful and thanks for reading the article.!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;References&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/rikatz/kubepug"&gt;Kubepug&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/antitree/krew-net-forward"&gt;net-forward&lt;/a&gt;&lt;br&gt;
&lt;a href="https://krew.sigs.k8s.io/plugins/"&gt;Krew&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In case of any queries, please feel to connect me via the below links&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/in/rvr88/"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.tomysticrenji"&gt;Twitter&lt;/a&gt;&lt;br&gt;
&lt;a href="https://renjithvr11.medium.com/"&gt;Medium&lt;/a&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>maintainence</category>
      <category>technology</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
