<?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 Herman Milton Maleiane on Medium]]></title>
        <description><![CDATA[Stories by Herman Milton Maleiane on Medium]]></description>
        <link>https://medium.com/@hermanmaleiane?source=rss-417121f70746------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uYzZlsbfkWHdvm9-9r15Nw@2x.jpeg</url>
            <title>Stories by Herman Milton Maleiane on Medium</title>
            <link>https://medium.com/@hermanmaleiane?source=rss-417121f70746------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 14:32:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hermanmaleiane/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[Integrating SBOM into Your CI/CD Pipeline: Software Security and Compliance]]></title>
            <link>https://medium.com/@hermanmaleiane/integrating-sbom-into-your-ci-cd-pipeline-software-security-and-compliance-be629d96fbd7?source=rss-417121f70746------2</link>
            <guid isPermaLink="false">https://medium.com/p/be629d96fbd7</guid>
            <category><![CDATA[dependency-track]]></category>
            <category><![CDATA[container-security]]></category>
            <category><![CDATA[devsecops]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[trivy]]></category>
            <dc:creator><![CDATA[Herman Milton Maleiane]]></dc:creator>
            <pubDate>Fri, 16 Aug 2024 13:35:17 GMT</pubDate>
            <atom:updated>2024-08-16T13:35:17.334Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Integrating SBOM into Your CI/CD Pipeline: Software Security and Compliance</strong></p><p>With the increasing of cyber-attacks and the growing complexity of software supply chains, organizations are under pressure to ensure that their software is not only functional but also secure.</p><p>In this article, we’ll explore how to scan Docker images for vulnerabilities and integrate the results with an SBOM tool. This process will help you enhance container security by providing detailed visibility into the components in your Docker images and automatically track any identified vulnerabilities.</p><h4>What is SBOM?</h4><blockquote>A Software Bill of Materials (SBOM) is a comprehensive inventory of all components, libraries, and dependencies within a software application. It’s a list of ingredients in a recipe, detailing every piece of software that has been integrated into the final product. SBOMs are crucial because they provide visibility into the components used, enabling organizations to track and manage vulnerabilities associated with third-party libraries or open-source components.</blockquote><h4>The Role of SBOM in CI/CD Pipelines</h4><p>In a CI/CD pipeline, where code changes are continuously integrated and deployed, the integration of SBOMs offers several significant benefits:</p><ol><li>Automated Vulnerability Detection;</li></ol><p>2. Ensuring Compliance;<br>3. Automated Compliance Checks;<br>4. Improved Software Quality;<br>5. Dependency Management;<br>6. Faster Incident Response;<br>7. Supply Chain Security.</p><h3>SBOM formats and standards</h3><p>Standardized formats facilitate the sharing of SBOM data across the software supply chain, promoting transparency and collaboration among different stakeholders. Some of the most widely recognized formats include:</p><ul><li><a href="https://spdx.dev/">Software Package Data Exchange (SPDX)</a>;</li><li><a href="https://cyclonedx.org/">CycloneDX</a>;</li><li><a href="https://nvd.nist.gov/products/swid">Software Identification Tags (SWID)</a>.</li></ul><p><strong>Trivy</strong></p><blockquote>Trivy is the most popular open source security scanner, reliable, fast, and easy to use. Use Trivy to find vulnerabilities &amp; IaC misconfigurations, SBOM discovery, Cloud scanning, Kubernetes security risks,and more.</blockquote><p>Using Trivy you can efficiently identify vulnerabilities in your Docker images, ensuring that potential security issues are detected early in the development process.</p><p><strong>Dependency-Track</strong></p><blockquote>Dependency-Track is an intelligent <a href="https://owasp.org/www-community/Component_Analysis">Component Analysis</a> platform that allows organizations to identify and reduce risk in the software supply chain. Dependency-Track takes a unique and highly beneficial approach by leveraging the capabilities of <a href="https://owasp.org/www-community/Component_Analysis#software-bill-of-materials-sbom">Software Bill of Materials</a> (SBOM). This approach provides capabilities that traditional Software Composition Analysis (SCA) solutions cannot achieve.</blockquote><p>Dependency Track is an interesting open-source project supported by OWASP that consumes SBOMs via API and dedicated CLI tools and also has a pretty good-looking UI, which is not common for open-source projects.</p><ol><li><strong>Scan Docker Image With Trivy</strong></li></ol><p>In this stage, we perform the scan and convert the results into the CycloneDX SBOM format.</p><pre>trivy image --severity HIGH,CRITICAL,MEDIUM --security-checks vuln --format cyclonedx --output result.json nginx:latest</pre><p>2. <strong>Push the Scan Result to Dependency-Track</strong></p><p>In this stage, we push the generated file with scan result to Dependency-Track. Dependency-Track offers an API that allows you to upload SBOM files directly, enabling automated and seamless integration into your security workflow.</p><pre>curl -X &quot;POST&quot; &quot;http://your_host:8080/api/v1/bom&quot; \<br>     -H &#39;Content-Type: multipart/form-data&#39; \<br>     -H &#39;X-Api-Key: odt_2Xkepd4gUD6tyVFJ45zi4dFsvuTRf4z1&#39; \<br>     -F &quot;project=8bc20ed4-6784-4c69-bd75-6477d6397b32&quot; \<br>     -F &quot;bom=@result.json&quot;</pre><p><strong>2.1 Output</strong></p><pre>{&quot;token&quot;:&quot;bb952b99-55de-4343-b394-7453d505891b&quot;}</pre><p>If you receive the above output, it indicates that your command was executed successfully.</p><p><strong>3. Dependency-Track</strong></p><p><strong>3.1 Dashboard</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FWyY6NpaQVj_ohHcGP--1Q.png" /><figcaption>Dashboard</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CWEVGcnBHA9FV1-2JKKzeg.png" /><figcaption>Audit Vulnerabilities</figcaption></figure><p>You can integrate these steps into your existing CI/CD pipelines after building your Docker image. By doing it, you’ll be able to automatically track and manage all vulnerable components in your image, ensuring continuous security monitoring over the software development lifecycle. This integration not only enhances your pipeline’s security but also provides ongoing visibility into potential risks, helping you to address vulnerabilities proactively.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be629d96fbd7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Expose Kubernetes Workloads on Premise]]></title>
            <link>https://medium.com/@hermanmaleiane/how-to-access-kubernetes-workloads-on-premise-45d416c99b57?source=rss-417121f70746------2</link>
            <guid isPermaLink="false">https://medium.com/p/45d416c99b57</guid>
            <category><![CDATA[metallb]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[nginx-ingress]]></category>
            <dc:creator><![CDATA[Herman Milton Maleiane]]></dc:creator>
            <pubDate>Thu, 21 Sep 2023 10:20:10 GMT</pubDate>
            <atom:updated>2023-09-25T09:14:46.731Z</atom:updated>
            <content:encoded><![CDATA[<p>How to Expose Kubernetes Workloads on Premise</p><p>Some organizations cannot take advantage of cloud technology because of laws that exist to protect sensitive information. These laws are especially important for places like government, hospitals and financial institutions, where they deal with private data like medical records and financial information. Consequently, these organizations are forced to maintain on-premises infrastructure to maintain greater control over their data.</p><p>But the point is, things are evolving so quickly, and you need to take advantages of containerization and orchestrations tools.</p><p>In this case, you want to use Kubernetes, so you can take advantages of auto-scaling and service discovery to respond in time to your business needs.</p><p><strong>How it normally works in cloud environment?</strong></p><p>When you create a service of type LoadBalancer for which you want to open a service in your Kubernetes cluster in cloud environments (AWS, Azure, and Google Cloud), an IP is automatically assigned, and you can access that service pod using the external IP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*PXFR75kuiV3ul0jHBp5azQ.png" /></figure><p>You don’t have this behavior when you are working on premises.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*IckSb9Byolqpy5QkRKjxRg.png" /></figure><p>If you create a service of type LoadBalancer on premise, you will see your service with <strong>pending </strong>status, and you will not be able to access your applications from outside the cluster.</p><p>Let&#39;s deploy <strong>nginx-ingress</strong> and see what&#39;s happening</p><p>Run this command to apply the manifest into your cluster</p><pre>kubectl apply -f https://github.com/kubernetes/ingress-nginx/blob/main/deploy/static/provider/baremetal/deploy.yaml</pre><p>Now check the services</p><pre>kubectl get svc -A</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mLYSMKxCN-G61ifZU5q8ow.png" /></figure><p>As you see, your service is not getting any IP.</p><p><strong>How to fix it?</strong></p><p>You need a solution like Metallb.</p><blockquote><a href="https://metallb.universe.tf/">MetalLB</a> provides a network load-balancer implementation for Kubernetes clusters that do not run on a supported cloud provider, effectively allowing the usage of LoadBalancer Services within any cluster.</blockquote><p>MetalLB operates in two modes, <strong>Layer 2</strong> and <strong>BGP</strong>. In Layer 2 mode, MetalLB assigns IP addresses from a defined pool to services in a local network.<br>In <strong>BGP </strong>mode uses the Border Gateway Protocol to announce and manage IP addresses.</p><p>In this section, we will demonstrate how to use the <a href="https://metallb.universe.tf/concepts/layer2/">Layer 2 configuration mode</a> of MetalLB together with the NGINX Ingress controller. In this mode, one node attracts all the traffic for the ingress-nginx Service IP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*vzPCzF6abxUaUYjaPjWpaA.png" /></figure><ol><li><strong>Download MetalLb manifest and apply in your cluster</strong></li></ol><pre>kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.9/config/manifests/metallb-native.yaml</pre><p>2. <strong>Setup IpAdressPool</strong></p><p>Create the below file and apply in your cluster</p><pre>apiVersion: metallb.io/v1beta1<br>kind: IPAddressPool<br>metadata:<br>  name: medium-pool<br>  namespace: metallb-system<br>spec:<br>  addresses:<br>  - X.X.X.180-X.X.X.182<br>  autoAssign: true</pre><pre>kubectl apply -f metallb-pool.yaml</pre><p>3. Set L2Advertisement</p><pre>apiVersion: metallb.io/v1beta1<br>kind: L2Advertisement<br>metadata:<br>  name: default<br>  namespace: metallb-system<br>spec:<br>  ipAddressPools:<br>  - medium-pool</pre><pre>kubectl apply -f advertisement.yaml</pre><p>Now apply again the nginx-ingress manifest</p><pre>kubectl get svc -A</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*VTTPgS3EOJCXqNM2p6Sacw.png" /></figure><p>Now you can see that the service of type Loadbalancer has an external IP assigned. Notice that the external IP is from the pool we defined in MetalLB configuration.</p><p>In this way, we managed to configure MetalLb on premise and your applications are now accessible outside the cluster.</p><p>Ingress and Loadbalancers are the recommend way of exposing apps outside the K8s cluster. You can use Nodeport, but it comes with his downsides.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45d416c99b57" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Implement Autoscaling In Kubernetes]]></title>
            <link>https://medium.com/@hermanmaleiane/how-to-implement-autoscaling-in-kubernetes-b26eb037205b?source=rss-417121f70746------2</link>
            <guid isPermaLink="false">https://medium.com/p/b26eb037205b</guid>
            <category><![CDATA[autoscaling]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Herman Milton Maleiane]]></dc:creator>
            <pubDate>Tue, 18 Apr 2023 14:02:41 GMT</pubDate>
            <atom:updated>2023-04-18T14:53:56.275Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>How to Implement Autoscaling In Kubernetes</strong></p><blockquote><strong>Kubernetes </strong>is a portable, extensible, open source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation.</blockquote><p>Kubernetes is commonly referred as K8s, which is as an abbreviation that results from counting the eight letters between the “K” and the “s”.</p><p>Kubernetes have many features but today I want to talk about Autoscaling. This is a real great feature in container orchestration world.</p><p>My motivation to write this article resides in the gains of using this feature and how kubernetes implements it in an easily and natively way.</p><p>As your business grow there are many challenges that you will face. Questions like, how can you handle sudden spikes in traffic without impacting the performance of the application and consequently not leaving your customers in pain in case of critical application for example Internet Banking.</p><p>Auto Scaling will automatically adjust the number of application instances running based on the current traffic load. The goal is to ensure that they have enough resources to handle high traffic while avoiding unnecessary expenses during low traffic periods.</p><p>You can define your policies based on the metrics that are most important, such as CPU usage, memory usage, and incoming requests per second and you can set a minimum and maximum number of application instances that could be running at any given time.</p><p>As traffic increases, Kubernetes will automatically spin up additional instances of the application to handle the load, and as traffic decreased, Kubernetes will scale down the number of instances to save on resources and costs.</p><p>You will no longer need to manually adjust the number of application instances based on traffic spikes. The autoscaling feature will do it for you and you can focus on other critical aspects while Kubernetes take care of managing the workloads.</p><p><strong>Types of Autoscaling in Kubernetes</strong></p><blockquote><strong>Horizontal Pod Autoscaler</strong> (HPA): The HPA scales the number of replicas of a Deployment or ReplicaSet based on CPU utilization, memory utilization, or custom metrics. HPA increases or decreases the number of replicas based on the current resource utilization of the pods.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*l9eSWepPsa-w3z2lEcCt2Q.png" /><figcaption><em>A visual explanation of the HPA functionality.</em></figcaption></figure><blockquote><strong>Vertical Pod Autoscaler</strong> (VPA): The VPA automatically adjusts the resource limits of containers based on their actual usage. It can increase or decrease CPU and memory limits for individual containers, and can also set limits based on historical usage patterns.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YEjlcHuGutdhxfPvZy3Dxw.png" /><figcaption><em>A visual explanation of the VPA functionality.</em></figcaption></figure><p>For this article we will focus on Horizontal Pod Autoscaler (HPA).</p><ol><li><strong>Create a file</strong> <a href="https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/application/php-apache.yaml">php-apache.yam</a>l</li></ol><p>This file uses a image <strong>registry.k8s.io/hpa-example</strong> and creates a deployment that results in a pod that exposes the application with ClusterIP service on port 80.</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: php-apache<br>spec:<br>  selector:<br>    matchLabels:<br>      run: php-apache<br>  template:<br>    metadata:<br>      labels:<br>        run: php-apache<br>    spec:<br>      containers:<br>      - name: php-apache<br>        image: registry.k8s.io/hpa-example<br>        ports:<br>        - containerPort: 80<br>        resources:<br>          limits:<br>            cpu: 500m<br>          requests:<br>            cpu: 200m<br>---<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: php-apache<br>  labels:<br>    run: php-apache<br>spec:<br>  ports:<br>  - port: 80<br>  selector:<br>    run: php-apache</pre><pre>kubectl appy -f php-apache.yaml<br>kubectl get pods</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*STro5vASxOIwRY5vz-iolA.png" /></figure><pre>kubectl get svc</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*3KBPZquzWObjIIipxZfnHg.png" /></figure><p>2. <strong>Create a file</strong> <a href="https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/application/hpa/php-apache.yaml">php-apache.yaml</a></p><p>The parameter targetCPUUtilizationPercentage set the value to 50 and in short terms it says that when the Pod reach 50% of usage of cpu it will create increase the number od pods to handle all requests.</p><pre>apiVersion: autoscaling/v1<br>kind: HorizontalPodAutoscaler<br>metadata:<br>  name: php-apache<br>spec:<br>  scaleTargetRef:<br>    apiVersion: apps/v1<br>    kind: Deployment<br>    name: php-apache<br>  minReplicas: 1<br>  maxReplicas: 10<br>  targetCPUUtilizationPercentage: 50</pre><pre>Kubectl appy -f php-apache.yaml<br>kubectl get hpa<br>kubectl get hpa php-apache - watch</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*gic5z_aG9dVVgVEFruGBew.png" /></figure><p>In the above command you can that we only have one replica and the value we defined in deployment manifest is 10 to max pods and 1 to min pods. Let´s create a load generator pod now.</p><p>3. <strong>Create a Load Generator Pod</strong></p><pre>kubectl run -i --tty load-generator --rm --image=busybox:1.28 --restart=Never -- /bin/sh -c &quot;while sleep 0.01; do wget -q -O- http://php-apache; done&quot;</pre><p>You will see this output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vcZonQ3c9LVoOD4kcskkzA.png" /></figure><p>Now if you execute the watch command you will see how many pods were created to handle all the traffic.</p><pre>kubectl get hpa php-apache - watch</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*80gU9r0Z64sdaZFnlSVkmA.png" /></figure><pre>kubectl get pods</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*xiEEPK4cKAaSqN1FfKilZg.png" /></figure><p>As you can see 4 more pods were created to handle the traffic. I stopped the execution using ctrl+c. And now if you execute again the watch command you will notice that we currently have 1 replica.</p><pre>kubectl get hpa php-apache - watch</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*emkmjwgUbT799wchtJ2cpA.png" /></figure><p>In <strong>conclusion</strong>, Kubernetes auto scaling is a game-changer. It handles sudden spikes in traffic without sacrificing performance, and it helps to optimize resource usage and costs. As a result, you will be able to provide a better user experience to your customers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b26eb037205b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How reliable can we build a system?]]></title>
            <link>https://medium.com/@hermanmaleiane/how-reliable-can-we-build-a-system-994cf5ca5350?source=rss-417121f70746------2</link>
            <guid isPermaLink="false">https://medium.com/p/994cf5ca5350</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Herman Milton Maleiane]]></dc:creator>
            <pubDate>Mon, 12 Dec 2022 16:31:42 GMT</pubDate>
            <atom:updated>2022-12-12T16:31:42.031Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/523/0*iCuI1P0tER5HoX1X.png" /></figure><p>As you progress through your career as a developer, you will be required to think more about software architecture and system design.</p><p>A fundamental concept in system design is the CAP theorem. Understanding the CAP theorem is a key to understand how to design strong distributed systems. Today we are going to talk about CAP theorem and how to use it to choose the right databases to your project.</p><p><strong>Distributed Systems</strong></p><blockquote>A distributed system is a system whose components are located on different networked computers, which communicate and coordinate their actions by passing messages to one another from any system. Wikipedia</blockquote><p><strong>Let’s consider a very simple distributed system.</strong></p><p>The system is composed of two servers, G1 and G2. Both of these servers are keeping track of the same variable, v, whose value is initially v0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*fQUM37uxM446-tUc2GionA.png" /></figure><p>G1 and G2 can communicate with each other and can also communicate with external clients.</p><p><strong>What is CAP Theorem?</strong></p><p>CAP Theorem is a fundamental theorem in distributed systems that states any distributed system can have at most two of the following three properties.</p><p>&gt; Consistency</p><p>&gt; Availability</p><p>&gt; Partition tolerance</p><p>The CAP theorem states that it’s not possible to guarantee all three of the desirable properties, consistency, availability and partition tolerance at the same time in a distributed system with data replication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*SmJn8Ems4FdDLUPKWE3GHA.png" /><figcaption>CAP Theorem</figcaption></figure><p><strong>Consistency</strong></p><p>Consistency means that the nodes will have the same copies of a replicated data item visible for various transactions.</p><p>Consistency is important when is required that all clients or users view the same data. This is important in places that deal with financial or personal information. For example, your bank account should reflect the same balance whether you view it from your PC, tablet, or smartphone.</p><p><strong>Availability</strong></p><p>Availability means that each read or write request for a data item will either be processed successfully or will receive a message that the operation cannot be completed. Every non-failing node returns a response for all the read and write requests in a reasonable amount of time.</p><p>For example, when you visit your bank’s ATM, you are able to access your account and its related information. Now even if you go to some other ATM, you should still be able to access your account. If you are only able to access your account from one ATM and not another, this means that the information is not available with all the ATMs.</p><p><strong>Partition Tolerance</strong></p><p>Partition tolerance means that the system should still be able to work even if there is a partition in the system. Meaning if a node fails to communicate, then one of the replicas of the node should be able to retrieve the data required by the user.</p><p>This is handled by keeping replicas of the records in multiple different nodes. So, even if a partition occurs, we are able to retrieve the data from its replica. As you must have guessed already, partition tolerance is a must for any distributed database system.</p><h3><strong>Some examples of CAP theorem</strong></h3><p><strong>CA Systems</strong></p><p><strong>Examples</strong>: Single node RBMS (MYSQL, Oracle, Postgresql)</p><p><strong>Uses Cases</strong>: Single Node.</p><p><strong>Sacrifice</strong>: No sacrifice.</p><p><strong>CP Systems</strong></p><p><strong>Examples</strong>: Zookeper, Big Table,MongoDB</p><p><strong>Uses Cases</strong>: Strong consistency. Banks and financial systems.</p><p><strong>Sacrifice</strong>: Avaliability</p><p><strong>AP Systems</strong></p><p><strong>Examples</strong>:Cassandra, CouchDB.</p><p><strong>Uses Cases</strong>: Low latency. Consistency requirement is not high.</p><p><strong>Sacrifice</strong>: Consistency</p><p>Picking a database is not easy and justifying our choice purely based on the CAP theorem is not enough. Don’t take the CAP theorem as an absolute. But rather as a spectrum where you can compromise on either Consistency or Availability rather than completely losing out both.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=994cf5ca5350" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Seamless Integration between IBM Qradar SIEM and TheHive using Python]]></title>
            <link>https://medium.com/@hermanmaleiane/seamless-integration-between-ibm-qradar-siem-and-thehive-using-python-bf480ebd361e?source=rss-417121f70746------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf480ebd361e</guid>
            <category><![CDATA[siem]]></category>
            <category><![CDATA[soc]]></category>
            <category><![CDATA[qradar]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[the-hive]]></category>
            <dc:creator><![CDATA[Herman Milton Maleiane]]></dc:creator>
            <pubDate>Wed, 14 Jul 2021 09:30:13 GMT</pubDate>
            <atom:updated>2021-07-14T10:32:17.244Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iRzo0pk71DilXS6ohndSbA.png" /><figcaption>Security Operations Center</figcaption></figure><p>Hi gents,<br> <br>After a long journey working as software developer i have decided to make some changes and move to security and honestly it’s being a funny journey and lot of challegens.<br>As a CyberSecurity guy i’m focused on application security but i work with SOC as well and today i want to share with you a simple integration with a popular SIEM (IBM Qradar), with one of the most used security case management tool (TheHive).</p><p>I have been working with some automation tools N8N and Shuffle that has many applications on security field and many other fields.<br>N8N is perfect and fit on all my needs but i found out that there is no integration with SIEM, IBM Qradar even Splunk. Then i found out Shuffle, that has the same approach as n8n but with integration with SIEM.<br>I was able to connect with Qradar and get some data, offenses and etc, but some things are realy hard to do with shuffle thats why i decided to use my programming skills to handle this limation.<br>Being honest, these tools are really cool but the documentation is really hard to understand and in some cases it’s much easier to build your own automation strategy.<br>There are some integration but they are outdated and many people ask for this integration. So if you are in the same scenario as me feel free to use.</p><p>For those ones that are not familiar with some concepts i will make some basic context.</p><blockquote>A Security Operation Center (SOC) is a centralized function within an organization employing people, processes, and technology to continuously monitor and improve an organization’s security posture while preventing,<br>detecting, analyzing, and responding to cybersecurity incidents.</blockquote><p>Essentially, the SOC is the correlation point for every event logged within the organization that is being monitored,<br>including its networks, devices, appliances, and information stores, wherever those assets reside. <br>For each of these events, the SOC must decide how they will be managed and acted upon.</p><blockquote>SIEM- Security Information and Event Management is a set of tools and services offering a holistic view of an organization’s information security.</blockquote><p>SIEM tools provide:<br> <br>Real-time visibility across an organization’s information security systems.<br>Event log management that consolidates data from numerous sources.<br>A correlation of events gathered from different logs or security sources, using if-then rules that add intelligence to raw data.<br>Automatic security event notifications. Most SIEM systems provide dashboards for security issues and other methods of direct notification.</p><blockquote><strong>IBM QRadar</strong></blockquote><blockquote>collects log data from sources in an enterprise’s information system, including network devices, operating systems, applications and user activities.<br>The QRadar SIEM analyzes log data in real-time, enabling users to quickly identify and stop attacks. QRadar can also collect log events and network flow data from cloud-based applications. This SIEM also supports threat intelligence feeds.</blockquote><p>Basicaly the communication to Qradar was perfomerd based on their API, you can have a look to the docs and get more information about the endpoints and what you need.<br>To create cases or alerts on thehive case management system you need to communicate with TheHive throught TheHive4py.<br>I have one instance of thehive installed on my linux OS based on docker image.</p><p>As some of you know i have a affection with JAVA. But JAVA will not fit all your needs. So the point is to focus on the problem and not the language.<br>And for this case python has seamless aproach to deal with many security stuffs.</p><p>First you need to have python installed on your machine. (<a href="https://www.python.org/downloads">https://www.python.org/downloads</a>).<br>To get the data from Qradar you need to install the library <a href="https://pypi.org/project/qradar4py/">https://pypi.org/project/qradar4py/</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZvPQB2ON3Ylx-P5fD2fvng.png" /></figure><p>The file qradar.py is the main file and is where we perform the communication to Qradar and retrieve the data. For this scenario i’m looking for all opened offenses in the last 15 minutes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f82514beab3cd9e6e90c569ee852e3e/href">https://medium.com/media/5f82514beab3cd9e6e90c569ee852e3e/href</a></iframe><p>The file thehive.py is where we establish the communication with thehive. You can create alerts with artifacts or cases with observables and so on.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c2876bdefbd76015746a98040c6bc09/href">https://medium.com/media/4c2876bdefbd76015746a98040c6bc09/href</a></iframe><p>You can find the scripts in this github repository.</p><p><a href="https://github.com/hermanmaleiane/qradar_thehive">https://github.com/hermanmaleiane/qradar_thehive</a></p><p>Make sure to have a look at README.md file before starting.</p><p>Thanks and i hope it helps you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf480ebd361e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microservices + DevOps]]></title>
            <link>https://medium.com/@hermanmaleiane/microservices-devops-a7968cee47cd?source=rss-417121f70746------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7968cee47cd</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Herman Milton Maleiane]]></dc:creator>
            <pubDate>Sun, 31 May 2020 13:26:35 GMT</pubDate>
            <atom:updated>2020-06-03T06:39:37.453Z</atom:updated>
            <content:encoded><![CDATA[<h3>Micro Serviços usando Spring boot+Vue Js+Docker</h3><blockquote>We can’t make the horse faster anymore; we need cars for where we are going. Henry Ford</blockquote><p>Se calhar seja a hora de fazer descansar<strong> </strong>a arquitectura Monólitica e optar por <strong>Micro servi</strong>ç<strong>os</strong> que permitem decompor o sistema em serviços discretos que podem ser escalados individualmente. Podem falhar, podem ser feitos rollbacks e podem ser actualizados isoladamente.</p><p>Jonas Bonér, criador do Akka e CTO no Lightbend, autor do livro Reactive <em>microsystems</em>, afirma que se você estiver a construir um produto mínimo viável (MVP) ou um protótipo, um item descartável que você precisa para chegar rapidamente ao mercado para testar uma ideia, é melhor começar com um CRUD numa arquitectura monólitica, passando para um modelo mais sustentável depois de provar seu valor no mercado.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kAWXqX663tFvl-JWIcpMlg.png" /><figcaption>Arquitectura Monólitica vs Micro Serviços</figcaption></figure><p>Este artigo tem como objetivo mostrar de que forma podemos criar uma arquitectura de <strong>Micro Servi</strong>ç<strong>os</strong>. Neste âmbito achei interessante falar sobre a evolução do desenvolvimento de <em>Software </em>e <strong>DevOps</strong>. A proposta para a primeira serie é criar o cliente usando o <strong>Vue Js</strong> e no backend <strong>Spring Boot</strong>. Depois disso mostrar a usabalidade do <strong>Docker </strong>como um container. Nos proximos artigos mostrar como podemos usar o <strong>Jenkins </strong>para integração continua e provavelmente sobre <strong>Kubernetes</strong>.</p><h4>Metodologia <strong>de Desenvolvimento de Software</strong></h4><p><strong>Waterfall</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*X6SF1JfkJx6HTFH9h0chsQ.png" /></figure><p><em>Para uma fase iniciar, a anterior deve estar totalmente finalizada e o resultado de cada etapa é a aprovação de um ou mais documentos.</em></p><p><strong>Desvatangens</strong></p><ul><li>Muito tempo é gasto para garantir que as fases sejam executadas corretamente;</li><li>Demora muito para o cliente ver algum resultado;</li><li>O cliente se decepciona quando recebe o produto;</li><li>A equipe de desenvolvimento está sempre “quase acabando”;</li><li>Esconde os riscos por muito tempo, retardando sua resolução;</li></ul><p>Por sua vez, as <strong>metodologias ágeis</strong> são aquelas que permitem adaptar o modo de trabalhar às condições do projecto, alcançando flexibilidade e rapidez na resposta para adaptar o projecto e seu desenvolvimento às circunstâncias específicas do ambiente.</p><p>O Agile tornou possivel trazer a área de negócio e desenvolvimento em apenas uma equipa.</p><p><strong>Vantagens: Comunicação || Automação || Feedback rápidos</strong></p><p>Um dos dos grandes ganhos do Agile é a automação visto que tem em vista detectar os defeitos (Funcionais e técnicos) quanto mais cedo possivel. A parte do negócio não precisa esperar por meses para ver o produto final.</p><p>E de acordo com a formação das equipas começaram a surgir necessididades especificas, o que deu surgimento dos Microserviços, onde basicamente deixousse de adoptar uma solução Monólitica para fazer pequenas APIS o que trouxe mais responsabilidade a área de operações e neste âmbito surge DevOps.</p><blockquote>O DevOps é a combinação de filosofias culturais, práticas e ferramentas que aumentam a capacidade de uma empresa de distribuir aplicativos e serviços em alta velocidade: optimizando e aperfeiçoando produtos em um ritmo mais rápido do que o das empresas que usam processos tradicionais de desenvolvimento de software e gestão de infraestrutura. Wikipedia</blockquote><p>O grande foco do DevOps é garantir uma maior comunicação entre a area de desenvolvimento e a de operações com vista a automatizar as operações de gestão de servidores, instalação de <em>softwares</em>, configuração de <em>softwares </em>e deploy de apps (<strong><em>Continuos Integration/Continuos Deployment</em> </strong>).</p><p>Neste contexto iremos usar o <strong>Docker </strong>que é uma ferramenta de conteirnização e que é usada para conter ambientes, além de dependências específicas, que são usadas em várias máquinas, e tem em vista resolver aquele famoso dilema dos dos programadores (“Mas na minha máquina corre”).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*SJ7cjnZp5Mb1wtlYalfrdQ.png" /></figure><p>Neste artigo usaremos o docker para agrupar os serviços criados, o frontend desenvolvido e a base de dados.</p><p>É necessário que tenha algum conhecimento de <strong>Java,</strong> <strong>REST, JavaScript.</strong></p><p>O cliente foi desenvolvido usando o framework JavaScript de código-aberto Vue Js, que e focado no desenvolvimento de interfaces e aplicativos de página única (SPA).</p><p>Foram desenvolvidos dois serviços. O primeiro para registo e autenticação de utilizadores (<strong>Spring Security+ MYSQL</strong>), e outro serviço para um CRUD de cursos. O Principal objetivo neste ponto é mostrar como aceder a varios serviços a partir de um unico cliente.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*dujGpI54GN_YcA4PcOVHWQ.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5031c7844e70a95ddfae5d4555bf2cc2/href">https://medium.com/media/5031c7844e70a95ddfae5d4555bf2cc2/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad146f957a4c42834bfaeb4c123cd0cc/href">https://medium.com/media/ad146f957a4c42834bfaeb4c123cd0cc/href</a></iframe><p>1. baixar e instalar o docker pelo link <a href="https://www.docker.com/products/docker-desktop">https://www.docker.com/products/docker-desktop</a></p><p>2. Na raiz de cada projecto criar um ficheiro Dockerfile</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef3d1923d7e81ff7c73bc34b1b9a20a8/href">https://medium.com/media/ef3d1923d7e81ff7c73bc34b1b9a20a8/href</a></iframe><p>3. Criar o ficheiro docker-compose.yml</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d7f8e230471e0d16e301ec06e1d3d841/href">https://medium.com/media/d7f8e230471e0d16e301ec06e1d3d841/href</a></iframe><p>4. Correr os seguintes comandos no terminal.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9de303237f6576e94cc15cd332105372/href">https://medium.com/media/9de303237f6576e94cc15cd332105372/href</a></iframe><p>Uma vez criados os containers no passo acima aceda o browser pelo link <a href="http://localhost:8080/">http://localhost:</a>4000</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DsF2aYwL3YWbZ95UoVBkfA.png" /><figcaption>Login</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fxPw8ivTq7DALvWEQyN2yw.png" /><figcaption>Cursos</figcaption></figure><p>Por hoje é tudo, até o próximo espisódio desta série !!Espero que tenhas gostado desta pequena aventura com Micro Serviços e Docker.</p><p>Github link: <a href="https://github.com/hermanmaleiane/microservicos_spring_boot_vuejs">https://github.com/hermanmaleiane/microservicos_spring_boot_vuejs</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7968cee47cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Test Driven Development + Spring Boot]]></title>
            <link>https://medium.com/@hermanmaleiane/test-driven-development-spring-boot-845cc346c31a?source=rss-417121f70746------2</link>
            <guid isPermaLink="false">https://medium.com/p/845cc346c31a</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[mockito]]></category>
            <category><![CDATA[junit]]></category>
            <dc:creator><![CDATA[Herman Milton Maleiane]]></dc:creator>
            <pubDate>Thu, 21 May 2020 19:33:55 GMT</pubDate>
            <atom:updated>2020-05-22T06:19:00.884Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello malta, hoje trago um artigo que tem o objectivo de criar um simples serviço RESTful usando Spring Boot e seguindo a prática do TDD. A grande motivação que tive para escrever este artigo é o facto de nós developers não fazermos testes (Unitários) das nossas aplicações, limitamo-nos a fazer testes funcionais e ficamos a rezar para que em produção nada de errado aconteça heheh. Funny but true. Posso arriscar e comparar está pratica a actividade fisica, requer muita disciplina e definição de objetivos. Digo isso porque muita das vezes não fazemos os testes porque eles interferem directamente com o tempo de entrega do software. Para quem trabalha com Scrum, alguns sprints tem ciclos reduzidos e a pressão é ainda maior. É necessário que seja uma cultura primeiramente das organizações, penso que gestores de projectos e desenvolvimento tenham grande participação neste ponto e não se limitar apenas em “Já entrou em produção?”. Posso arriscar também a dizer que alguns de nós (developers) não fazemos testes porque não temos a informação, não sabemos que devemos fazer testes.</p><blockquote>Test Driven Development (TDD), em português, Desenvolvimento guiado por testes é uma técnica de desenvolvimento de software que se relaciona <br>com o conceito de verificação e validação. Wikipedia</blockquote><blockquote>Foi desenvolvido por Kent Beck no final dos anos 90 como parte do Extreme Programming.</blockquote><blockquote>O TDD é baseado em um curto ciclo de repetições :</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PwZSOdOS1TLvv9WzOFPgeQ.png" /></figure><p>É necessário que tenha algum conhecimento de <strong>Java</strong>, <strong>MVC </strong>e <strong>REST</strong>.</p><p><strong>Junit </strong>: JUnit é um framework open-source, criado por Erich Gamma e Kent Beck, com suporte à criação de testes automatizados na linguagem de programação Java. Esse framework facilita a criação e manutenção do código para a automação de testes com apresentação dos resultados.</p><p><strong>Mockito </strong>é um framework que pode ser usado em conjunto com o JUnit, permite criar e configurar objectos <a href="https://www.sinonimos.com.br/ficticio/">fictício</a>s. O uso do Mockito simplifica o desenvolvimento de testes para classes com dependências externas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*RjhqjrWHh1HWaCTBdw7hag.png" /><figcaption>Arquitectura/Camadas</figcaption></figure><p>O cliente envia um request que passa pelas camadas acima. O controller interage com a camada de Serviço, que possui a lógica de negócios.<br>A camada de serviço precisa interagir com a base de dados e para isso usamos o JPA.</p><p><strong>Let’s Code!!!!</strong></p><p>Primeiro aceda ao link <a href="https://start.spring.io/">https://start.spring.io/</a> para criar uma estrutura de um projecto spring boot. Escolha Maven project e adicione como dependências <strong>Web</strong>, <strong>JPA</strong>, <strong>MySQL</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3jZC0BGoPT76Ya0g6k-Vaw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*PMVFuR3gd_pGTQps2vXyDw.png" /><figcaption>Estrutura do Projecto</figcaption></figure><p>Na classe JunitApplication e no metódo setup ao correr a app ele persiste os dados na BD.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8940977d4b89dbdb5add444048ba17ee/href">https://medium.com/media/8940977d4b89dbdb5add444048ba17ee/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*9mndEi3sp3sH8xGPW7IvAQ.png" /><figcaption>Resultado da inserção</figcaption></figure><p>Primeiramente iremos criar um cenário de um implementação que ira falhar no teste. Em seguida iremos refactorar a implementação para que passe.</p><p>Na classe UserService deixaremos o metódo <strong>getUsers </strong>a retornar uma lista vazia.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff43d48efa7a31fb05858d752eb6fb94/href">https://medium.com/media/ff43d48efa7a31fb05858d752eb6fb94/href</a></iframe><ol><li>Teste que falha</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*gT3byslwBlU-3mOfGrTHMw.png" /></figure><blockquote>Na imagem acima temos um cenário de um teste que não passou porque no metódo <strong><em>assertEquals </em></strong><em>era esperado como resultado </em><strong><em>3</em></strong><em> e trouxe</em><strong><em> 0</em></strong><em> porque no metódo </em><strong>getUsers </strong>retornamos uma lista vazia.</blockquote><p>Foi necessário alterar o metodo <strong>getUsers </strong>para que retornasse efectivamente os resultados que existem na base de dados. E este é no caso o cenário do teste que passa visto que retorna <strong>3</strong> resultados da base de dados.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/befddc7721b372c42766f741cf29f66c/href">https://medium.com/media/befddc7721b372c42766f741cf29f66c/href</a></iframe><p>Em seguida é ilustrado um conjunto de testes unitários usando Mockito e Junit.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d7d38c45fc35a20a665e027e0cd3332d/href">https://medium.com/media/d7d38c45fc35a20a665e027e0cd3332d/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*N2IfyQ9YJ0J7JRWMCYQF3A.png" /><figcaption>Todos testes</figcaption></figure><p>Spring boot ja vem com tomcat server. Na classe JunitApplication.java coloque a correr e <a href="http://localhost:8080/getUsers">http://localhost:8080/getUsers</a> para testar o Serviço Rest.</p><p>Link do repositório: <a href="https://github.com/hermanmaleiane/spring_boot_tdd">https://github.com/hermanmaleiane/spring_boot_tdd</a></p><p>Muito Obrigado e espero que tenhas gostado!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=845cc346c31a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring Boot+Thymeleaf+ Leaflet Js Mapping Corona Virus]]></title>
            <link>https://medium.com/@hermanmaleiane/spring-boot-thymeleaf-leaflet-js-mapping-corona-virus-a8309c5a0b6d?source=rss-417121f70746------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8309c5a0b6d</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[leaflet]]></category>
            <category><![CDATA[thymeleaf]]></category>
            <category><![CDATA[coronavirus]]></category>
            <dc:creator><![CDATA[Herman Milton Maleiane]]></dc:creator>
            <pubDate>Sun, 22 Mar 2020 11:24:29 GMT</pubDate>
            <atom:updated>2020-05-22T06:30:10.381Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*izuPPx8XvWLflKePnNI19Q.png" /></figure><p>Sup Guys. Due to the repercussion of the Coronavirus in the world, it is necessary that each one does his part in order to alleviate this disease and prevent its spread. Just to put it in context, I think it’s important to say that the Corona virus is a family of viruses that cause respiratory infections. The new Coronavirus agent was discovered on 12/31/19 after cases registered in China and causes the disease called Coronavirus (COVID-19).</p><p>On 03/20/2020 our president announced that all educational institutions must be closed, and each one of us should remain in our homes, I think it is appropriate to dedicate this time at home to learn new things (Read some books, new frameworks , programming languages, practice physical exercises, etc.).</p><p>Yesterday 03/21/2020 I decided to create an application where people could view information related to the Corona virus through alphanumeric and spatial data using Spring boot to create services in Java, Thymeleaf for the alphanumeric data visualization layer and the Leaflet to render the maps (Spatial information).<br>The purpose of this article is to share step by step to design this solution and who knows if it is useful for one of you!!!!!!!!! Lets code&lt;/&gt;.</p><p>The first thing to do was to have an updated case file that can be obtained from the link <a href="https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv.">https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv.</a> This file is a csv that contains information regarding the state, country, cases per day, their quantification and spatial information (Longitude and Latitude).<br>The second step was to create a Spring Boot project through the link <a href="https://start.spring.io/">https://start.spring.io/</a> where it is possible to initialize the project structure with all necessary dependencies, in which case it was necessary to define the dependencies for the project, Thymeleaf and Spring Web .<br>Then it was necessary to create a POJO based on the fields in the CSV file and create the service that performs an HTTP request to the specified URL where the data is updated daily.</p><pre>//POM</pre><pre>&lt;dependencies&gt;<br>   &lt;dependency&gt;<br>      &lt;groupId&gt;nz.net.ultraq.thymeleaf&lt;/groupId&gt;<br>      &lt;artifactId&gt;thymeleaf-layout-dialect&lt;/artifactId&gt;<br>      &lt;version&gt;2.3.0&lt;/version&gt;<br>   &lt;/dependency&gt;<br>   &lt;dependency&gt;<br>      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>      &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt;<br>   &lt;/dependency&gt;<br>   &lt;dependency&gt;<br>      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>      &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;<br>   &lt;/dependency&gt;<br>   &lt;dependency&gt;<br>      &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;<br>      &lt;artifactId&gt;commons-csv&lt;/artifactId&gt;<br>      &lt;version&gt;1.8&lt;/version&gt;<br>   &lt;/dependency&gt;<br><br>   &lt;dependency&gt;<br>      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>      &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;<br>      &lt;scope&gt;runtime&lt;/scope&gt;<br>      &lt;optional&gt;true&lt;/optional&gt;<br>   &lt;/dependency&gt;<br>   &lt;dependency&gt;<br>      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>      &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;<br>      &lt;scope&gt;test&lt;/scope&gt;<br>      &lt;exclusions&gt;<br>         &lt;exclusion&gt;<br>            &lt;groupId&gt;org.junit.vintage&lt;/groupId&gt;<br>            &lt;artifactId&gt;junit-vintage-engine&lt;/artifactId&gt;<br>         &lt;/exclusion&gt;<br>      &lt;/exclusions&gt;<br>   &lt;/dependency&gt;<br>&lt;/dependencies&gt;</pre><pre>//Service</pre><pre>List&lt;LocationStats&gt; newStats = new ArrayList&lt;&gt;();<br>HttpClient client = HttpClient.<em>newHttpClient</em>();<br>HttpRequest request = HttpRequest.<em>newBuilder</em>().uri(URI.<em>create</em>(<em>VIRUS_DATA_URL</em>)).build();<br>HttpResponse&lt;String&gt; httpResponse = client.send(request, HttpResponse.BodyHandlers.<em>ofString</em>());<br>StringReader csvBodyReader = new StringReader(httpResponse.body());<br>Iterable&lt;CSVRecord&gt; records = CSVFormat.<em>DEFAULT</em>.withFirstRecordAsHeader().parse(csvBodyReader);<br>for (CSVRecord record : records) {<br>    LocationStats location = new LocationStats();<br>    location.setState(record.get(&quot;Province/State&quot;));<br>    location.setCountry(record.get(&quot;Country/Region&quot;));<br>    location.setLatitude(Double.<em>parseDouble</em>(record.get(&quot;Lat&quot;)));<br>    location.setLongitude(Double.<em>parseDouble</em>(record.get(&quot;Long&quot;)));<br>    int latestCases = Integer.<em>parseInt</em>(record.get(record.size() - 1));<br>    location.setLatestTotalCases(latestCases);<br>    newStats.add(location);<br>}<br> /*allStats.forEach((LocationStats state) -&gt; {<br>    System.out.println(state);<br>});*/</pre><pre>//Controller</pre><pre>@Controller<br>public class HomeController {<br><br>    @Autowired<br>    CoronaVirusDataService coronaVirusDataService;<br><br>    @GetMapping(&quot;/home&quot;)<br>    public String home(Model model) {<br>        List&lt;LocationStats&gt; allStats = coronaVirusDataService.getAllStats();<br>        int totalReportedCases = allStats.stream().mapToInt(stat -&gt; stat.getLatestTotalCases()).sum();<br>        model.addAttribute(&quot;locationStats&quot;, allStats);<br>        model.addAttribute(&quot;totalReportedCases&quot;, totalReportedCases);<br>        return &quot;home&quot;;<br>    }<br><br><br>    @GetMapping(&quot;/maps&quot;)<br>    public String map(Model model) {<br>        List&lt;LocationStats&gt; allStats = coronaVirusDataService.getAllStats();<br>        int totalReportedCases = allStats.stream().mapToInt(stat -&gt; stat.getLatestTotalCases()).sum();<br>        model.addAttribute(&quot;locationStats&quot;, allStats);<br>        model.addAttribute(&quot;totalReportedCases&quot;, totalReportedCases);<br><br>        return &quot;maps&quot;;<br>    }<br>}</pre><pre>// Data Presentation Layer</pre><pre>&lt;div class=&quot;container&quot;&gt;<br>    &lt;h1&gt;Coronavirus&lt;/h1&gt;<br>    &lt;div class=&quot;jumbotron&quot;&gt;<br>        &lt;h3 class=&quot;display-4&quot; th:text=&quot;${totalReportedCases}&quot;&gt;&lt;/h3&gt;<br>        &lt;p class=&quot;lead&quot;&gt;Casos reportados&lt;/p&gt;<br>        &lt;hr class=&quot;my-4&quot;&gt;<br>    &lt;/div&gt;<br><br>    &lt;table class=&quot;table&quot;&gt;<br>        &lt;tr&gt;<br>            &lt;th&gt;Estado&lt;/th&gt;<br>            &lt;th&gt;Pais&lt;/th&gt;<br>            &lt;th&gt;Total de Casos  reportados &lt;/th&gt;<br>        &lt;/tr&gt;<br>        &lt;tr th:each=&quot;locationStat : ${locationStats}&quot;&gt;<br>            &lt;td th:text=&quot;${locationStat.state}&quot;&gt;&lt;/td&gt;<br>            &lt;td th:text=&quot;${locationStat.country}&quot;&gt;&lt;/td&gt;<br>            &lt;td th:text=&quot;${locationStat.latestTotalCases}&quot;&gt;0&lt;/td&gt;<br>        &lt;/tr&gt;<br>    &lt;/table&gt;<br>&lt;/div&gt;</pre><pre>//Map Behavior<br><br>&lt;div id=&quot;mapid&quot; style=&quot;width: 100%; height: 750px;&quot;&gt;&lt;/div&gt;<br><br>&lt;script th:inline=&quot;javascript&quot;&gt;<br><br>    var mymap = L.map(&#39;mapid&#39;).setView([0, 0], 4);     L.tileLayer(&#39;https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}&#39;, {<br>        attribution: &#39;Corona Virus&#39;<br>    }).addTo(mymap);<br><br>    var data = [[${locationStats}]] ;<br>    console.log(&quot;list: &quot;+ data.length);<br>    for(var i=0; i&lt; data.length;i++) {<br>        if(data[i].latitude !== null &amp;&amp; data[i].longitude !== &quot;&quot;) {<br>            L.marker([data[i].latitude, data[i].longitude]).addTo(mymap)<br>                .bindPopup(<br>                    &quot;Estado: &quot;+ data[i].state+&#39;&lt;br&gt;&lt;b&gt;&#39;<br>                    +&quot;Pais: &quot;+data[i].country+&#39;&lt;br&gt;&lt;b&gt;&#39;<br>                    +&quot;Casos reportados: &quot; +data[i].latestTotalCases+&#39;&lt;/b&gt;&#39;<br>                )<br>                .openPopup();<br>        }<br>    }<br>&lt;/script&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mhgXzs2qR6b7VzQQAsq9Hg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6DdStZtZqCQVgdU-i95hLQ.png" /></figure><p>Notice that i used Java 13 (First time), and makes life much easier, Issues like Http Client requirements require you to use dependencies like Apache HttpClient for java versions below 9.</p><p>Github Repository: <a href="https://github.com/hermanmaleiane/SpringBoot_CoronaVirus">https://github.com/hermanmaleiane/SpringBoot_CoronaVirus</a></p><p>Thanks for taking the time to read, I hope you enjoyed it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8309c5a0b6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>