<?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 Bhanu Shukla on Medium]]></title>
        <description><![CDATA[Stories by Bhanu Shukla on Medium]]></description>
        <link>https://medium.com/@bhanushukla?source=rss-88fec0c70a40------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*XdalcNU5hftRM8Mg.</url>
            <title>Stories by Bhanu Shukla on Medium</title>
            <link>https://medium.com/@bhanushukla?source=rss-88fec0c70a40------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 13:31:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bhanushukla/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[Configuring Apache to avoid common vulnerabilities in web applications]]></title>
            <link>https://medium.com/prod-io/configuring-apache-to-avoid-common-vulnerabilities-in-web-applications-65a213c07fd3?source=rss-88fec0c70a40------2</link>
            <guid isPermaLink="false">https://medium.com/p/65a213c07fd3</guid>
            <category><![CDATA[security-vulnerabilities]]></category>
            <category><![CDATA[configuration]]></category>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Bhanu Shukla]]></dc:creator>
            <pubDate>Fri, 06 Jul 2018 05:42:20 GMT</pubDate>
            <atom:updated>2018-07-07T06:10:25.490Z</atom:updated>
            <content:encoded><![CDATA[<p>Apache is a web server consisting of several patches (as goes the pun, a patchy) which provides us a flexible, customisable and highly scalable way of serving the content over internet. It’s basically a set of modules (patches) ranging from security, authentication, authorisation up to very basics of logging and configuration. The following article is a take on configuring apache for the trivial loopholes of the server which may lead to severe vulnerabilities. As apache is highly customisable to the needs, it requires a very few lines of configuration to close the vulnerabilities and safeguard the application for possible attacks. So let’s dive in to what are the vulnerabilities and how the apache configuration can be used to plug them.</p><p><strong>Click Jacking: </strong>Also known as UI redress attack, through which a web user is baited into clicking something different from what user perceives they are clicking on. A simple way to achieve this is by embedding a simple script into a page that opens a iFrame with exact same layout as the original user login page. Or more simply, by putting an invisible button over the visible original button. Once user clicks on the invisible button, the username and password can easily be stolen. A simple solution would be to accept request from verifiable sources only.</p><blockquote>X-Frame-Options: ALLOW-FROM <a href="https://example.com/">https://example.com/</a></blockquote><p>OR</p><blockquote>&lt;IfModule mod_headers.c&gt;</blockquote><blockquote>Header always set X-Frame-Options SAMEORIGIN</blockquote><blockquote>&lt;/IfModule&gt;</blockquote><p><strong>Cross Site Request Forgery (CSRF): </strong>CSRF is a method by which attacker uses a malicious website causing user’s web browser to perform unwanted action on a trusted site for which the user is currently authenticated. Though the solution to this problem lies with using CSRF tokens verification and checking headers to verify the request is from same origin. At the apache level, we can set server signature off and server tokens to product only by editing the httpd.conf file or apache.conf file:</p><blockquote>ServerSignature Off<br>ServerTokens Prod</blockquote><p>AND</p><blockquote>&lt;IfModule mod_headers.c&gt;</blockquote><blockquote>Header unset Server<br> Header always unset X-Powered-By<br> Header unset X-Powered-By<br> Header unset X-CF-Powered-By<br> Header unset X-Mod-Pagespeed<br> Header unset X-Pingback</blockquote><blockquote>&lt;/IfModule&gt;</blockquote><p><strong>Host Header Injection: </strong>A host header is used when several web applications are deployed on the same IP address. Host header specifies which web application will process incoming HTTP request. The host header is set on the user end, hence the server needs either a strict whitelist of the hosts or we unset the host header from apache configuration. A simple example of host header injection could be, is I’m using _SERVER[‘HOST’] in my code to fetch the relative file path.</p><blockquote>&lt;script src=”http://&lt;?php echo _SERVER[‘HOST’] ?&gt;/script.js”&gt;</blockquote><p>To fix the host header injection we can unset the host header as follows:</p><blockquote>&lt;IfModule mod_headers.c&gt;</blockquote><blockquote>Header unset X-Forwarded-Host</blockquote><blockquote>&lt;/IfModule&gt;</blockquote><p>For a complete list of vulnerabilities please visit <a href="https://www.cvedetails.com/product/66/Apache-Http-Server.html?vendor_id=45">this</a> link. It presents us with a detailed view of year wise distribution of vulnerabilities specific to apache version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d_BpACmvu93wGM3MvAW9zQ.png" /><figcaption>CVE Details for Apache vulnerabilities</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65a213c07fd3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/prod-io/configuring-apache-to-avoid-common-vulnerabilities-in-web-applications-65a213c07fd3">Configuring Apache to avoid common vulnerabilities in web applications</a> was originally published in <a href="https://medium.com/prod-io">Prod.IO</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOLID Principles in PHP]]></title>
            <link>https://medium.com/prod-io/solid-principles-takeaways-ec0825a07247?source=rss-88fec0c70a40------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec0825a07247</guid>
            <category><![CDATA[solid-principles]]></category>
            <category><![CDATA[solid]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Bhanu Shukla]]></dc:creator>
            <pubDate>Thu, 26 Oct 2017 11:28:47 GMT</pubDate>
            <atom:updated>2017-12-27T06:23:32.840Z</atom:updated>
            <content:encoded><![CDATA[<p>This post is to provide an easy to understand idea about the implementation of one of the most “talked about” principles of Object Oriented Programming - SOLID principles. As a programmer, there might come a time when we are so consumed in finishing the task at hand that we forget the world around us. And in the very same world, somewhere lost are the programming principles that we read about and planned to use next time. So let’s try to look at the SOLID principles in one of the simplest way possible so that we can practice them while coding.</p><p>So let’s dig in to the SOLID principles at a glance.</p><ol><li><strong>Single Responsibility:</strong> A Class should be responsible for a single task.</li><li><strong>Open-Close Principle: </strong>A Class should be open to extension and close to modification.</li><li><strong>Liskov Substitution: </strong>A derived Class can be substituted at places where base Class is used.</li><li><strong>Interface Segregation: </strong>Don’t make FAT Interfaces. i.e. Classes don’t have to override extra agreements that are not needed for that Class simply because it is there in interface.</li><li><strong>Dependency Inversion: </strong>Depend on abstractions, not on concretions. Not only high level Classes but low level Classes also depend on the abstractions in order to decouple the code.</li></ol><p>It’s totally fine to be a little puzzled with some of the above explanations which are not the exact definitions (because the exact definitions are far more perplexing). As once tweeted by Jeffrey Way of Laracasts;</p><blockquote>Dependency Inversion, Inversion of Control, Dependency Injection, IoC Container. It’s no wonder why people get so confused. So much jargon!</blockquote><p>Let’s try to look into each of these principles in detail, so that we can convert these jargon into slangs.</p><h3><strong>Single Responsibility</strong></h3><p>The easiest one to follow and put into practice. It’s very straight forward. e.g. I need to make an API end point in back-end which receives a request, does authentication, validates the received data, does query on database, makes a formatted response and finally, send back the response. All these tasks look trivial. So, the Single Responsibility Principle (SRP) just asks us to <strong>do these tasks in separate Classes</strong>, instead of, making functions in a single Class and doing everything at one place. If we keep all the things in one file, it will be like a kid who’s playing and messing up things and enjoying his life. Lets not be lazy to create the Classes. They take a little extra effort but it will make life easier for you and the coders who will read your code later.</p><p>For example, suppose you got a bug and you figure out that the line of code that you did might be the source of problem. Now you will have to look for a single line in a huge file. And still you are not sure if you fix this issue at one place, some other functionality using this piece of code might break! So here is a sample code to show the SRP violation in PHP:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*wZcW9l9yt2ZQ0__tRtyf_w.png" /></figure><h3><strong>Open-Close Principle</strong></h3><p>It ensures that the code is open for extension but closed for modification. It reduces the chances of code rot i.e. editing the same piece of code again and again. It is very helpful in cases when the requirements may keep getting added in the future.</p><p>For example, an authentication module which requires users with just username and password on your website to login. You code a login module and perform login for that user.</p><p>However, you may now want the users to be able to login using Google, Facebook or other platforms, where they have already logged in and they bring with them a custom access token with which they can login. Now you have to put checks on what kind of user is that and based on that, you proceed to write the login logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*G0FEyn1b_G6tr3Q9HO12NQ.png" /></figure><p>But this clearly will make a code rot if tomorrow there is another set of users to be logged in, using another mechanism. Nobody would want to modify the code that is already written for a crucial functionality like login.</p><p>Let’s see how it will go if we follow the open-close principle while writing this code. Separate the login behaviour behind an interface and create separate Classes for normal login and third party login to flip the dependencies. Any new person who wants to write a whole different login module functionality for a different set of users will create their own login module’s Class and implement the login interface (the functions that Login interface has as agreements).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*F6KliDBQMPZdycmc0CIgdg.png" /></figure><p>To sum up the open-close principle, if a code can be extended, then write in such a way that it doesn’t needs to be modified if extra and similar requirements come up. Easily detected when we write conditions for instance types of a Class.</p><h3><strong>Liskov Substitution</strong></h3><p>It states that any implementation of an abstraction (interface) should be substitutable in any place that the abstraction is accepted. Basically it takes care that while coding using interfaces in our code, we not only have a contract of input that the interface receives but also the output returned by different Classes implementing that interface; they should be of same type.</p><p>e.g. Two different Classes implementing an interface return different type of values(array, collection, list). Now we will be forced to put conditional statements to check what kind of value is returned from the method we called. If its an array do this, else, if its a collection do that and so on. This kind of checks won’t be necessary if we follow Liskov substitution principle and make sure that returned exception types(if any) and the values have uniform return types.</p><p>A code snippet to show the LSP voilation :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*DgZUcLFZksqu982KCo4JBQ.png" /></figure><p>Doc blocks can very helpful to make sure that LSP is not violated and made easy to understand what is the type of value returned from function.</p><h3><strong>Interface Segregation Principle</strong></h3><p>It states that a client must not be forced to implement an interface that it doesn’t use. It will make sure that Classes are sharing only the knowledge that is required and not just bloating themselves, just because we committed to code to interface.</p><p>At this point, I would like to name one more jargon,<strong><em> Fat Interface</em></strong>. So what is Fat Interface, basically, and interface becomes fat when it’s handling too many contracts. A fat interface violates Single Responsibility Principle too as it’s handling more than one responsibilities at a time.</p><p>Let’s take an example, suppose we have a Class Driver who has the responsibility to manage a Car.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*W6L6pvsXlbmJ-ShjW3WxJQ.png" /></figure><p>Now the Driver Class can have a operate method which will get an instance of Car and we can call the getFuel, shiftGear and and steer methods of Car Class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*M8OBuCALq7wNg7qvs95clQ.png" /></figure><p>Since we are committed to code to an interface, we make the CarInterface and make the Car Class implement CarInterface to override getFuel, shiftGear and steer methods.</p><p>Now, the driver gets an electric car e.g. Tesla Model S. You make a Class ElectricCar and implement the CarInterface. Since you have a contractual binding, you have to override the methods. But an electric car doesn’t require to get fuel. Yet we will have to override this getFuel method and do nothing in that for electric cars.</p><p>This violates Interface Segregation principle. This is exactly where we need to make our fat interface, CarInterface, thin and move out the fuelling part out of CarInterface to a more appropriate interface, like CarFuelInterface and change our CarInterface to CarOperationInterface. Now, a DieselCar can implement CarOperationInterface and CarFuelInterface whereas and ElectricCar Class can implement only CarOperationInterface. An now, since Electric car requires charging, ElectricCar Class can additionally implement an CarChargeInterface with methods like plugElectricity, doCharging, unplugElectricity etc. which means that we are open to extension but closed to modification, hence adhering to open-close principle too. This example also shows that SOLID principles are interlinked to each other. Bottom line is that a Class should not have the extra knowledge that is not required.</p><h3><strong>Dependency Inversion</strong> P<strong>rinciple</strong></h3><p>It states that High level modules should never depend on Low level modules, instead the High level module can depend upon an abstraction and the Low level module depends on that same abstraction. It’s not the simplest statement that we have come across. In very simple words… nope, a statement this complex can’t be simplified.</p><p>So let’s take a simple example, suppose there is a PasswordReminder Class which can be a high level module(a module that doesn’t focus on detailed implementation) requires access to dbConnection property. Now how about we just inject the MySQLConnection Class to the constructor of PasswordReminder Class(dependency injection) and give it access to dbConnection property. But this will make the High level module(PasswordReminder) depend on low level module(MySQLConnection). But does the PasswordReminder need the knowledge on connection type? Nope. It doesn’t. So lets code to an interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*e11g0TRcxn-8S9V16Yet7A.png" /></figure><p>Make a ConnectionInterface(an abstraction) and inject that to PasswordReminder Class’ constructor to access the dbConnection property.</p><p>Now, our MySQLConnection Class becomes DBConnection Class and it can implement the ConnectionInterface to override methods like connect. Here we just decoupled the PasswordReminder Class from MySQLConnection Class using an abstraction (ConnectionInterface) and the dependency on MySQLConnection Class is inverted using the abstraction ConnectionInterface. I’m still looking for better examples for this in real scenarios. If you can suggest any, please provide them in Comments section.</p><p>Here are the definitions of these principles as provided by Wiki:</p><p><strong>Single Responsibility Principle: </strong>A<strong> C</strong>lass should have only a single responsibility</p><p><strong>Open/Closed Principle: </strong>Software entities … should be open for extension, but closed for modification.</p><p><strong>Liskov Substitution Principle: </strong>Objects in a program should be replaceable with instances of their sub-types without altering the correctness of that program.</p><p><strong>Interface Segregation Principle: </strong>Many client-specific interfaces are better than one general-purpose interface.</p><p><strong>Dependency Inversion Principle: </strong>One should “depend upon abstractions, [not] concretions.”</p><p>All these principles are something to keep in mind while coding and doesn’t necessarily mean that we have to put each of them in practice at all times. Just keep it in mind that we have to keep an idea of what we are doing in a Class. Does it need the the knowledge that I am passing to it? While trying to answer this we might get to code to an interface and put necessary abstractions in place which will make our code adhere to the SOLID principles.</p><p>Resources: <a href="https://laracasts.com/series/solid-principles-in-php">https://laracasts.com/series/solid-principles-in-php</a>, <a href="https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)">https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec0825a07247" width="1" height="1" alt=""><hr><p><a href="https://medium.com/prod-io/solid-principles-takeaways-ec0825a07247">SOLID Principles in PHP</a> was originally published in <a href="https://medium.com/prod-io">Prod.IO</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ChangeQuest: My first live simulation run]]></title>
            <link>https://medium.com/prod-io/changequest-my-first-live-simulation-run-a529ebfdacc9?source=rss-88fec0c70a40------2</link>
            <guid isPermaLink="false">https://medium.com/p/a529ebfdacc9</guid>
            <category><![CDATA[changequest]]></category>
            <category><![CDATA[leadership-skills]]></category>
            <category><![CDATA[simulation]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[experience]]></category>
            <dc:creator><![CDATA[Bhanu Shukla]]></dc:creator>
            <pubDate>Mon, 24 Apr 2017 10:03:11 GMT</pubDate>
            <atom:updated>2017-04-25T13:44:40.288Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RwwECrWZNsCp2SUGeA5pZQ.jpeg" /></figure><p>Ever wondered how our simulations are changing the landscape of learning? Visiting a live simulation run helped me witness it’s impact first hand. The products that we develop, cater to a specific audience and many of us are not the target audience so we might find it difficult to realize their impact.</p><p>Recently, Varun and I got the opportunity to attend the run of ChangeQuest of a Fortune 500 company. It comprised of Sales Executives from freshers to division heads. The session was divided into three phases, briefing, simulation play, and debriefing. The session starts with a talk on leadership and how the hierarchy in organisations affect the adoptions of change initiatives that are needed for the growth of an organisation. The simulation itself is a part of leadership talk and the way our facilitators deliver it is amazing, especially the way they link the challenges that people face in real life to what they are going to experience in the simulation in a very subtle fashion. The discussions among people while briefing the simulation was of key importance. People were learning among themselves while answering the questions posed by the facilitator and looked eager to put their experience<br>forward.</p><p>The level of engagement was really high. It’s like everybody knows the answer, which is, in fact, the reality, just that everyone has their own perspective. Varun was assisting a separate group of 30 people, and when we met after the session, he exclaimed, “Dude! People went crazy while playing the simulation. Now it will be more fun to code”.</p><p><strong>Post Simulation: </strong>People were easily relating to the strategies and philosophy that ChangeQuest is built on, directly to their field of sales. Among them, ten people replied to the question, “What you learned from simulation?”, without even thinking for a second (three to four people waiting with their hands raised to reply next). Even I was puzzled how they came to these conclusions(maybe I was not the target audience :P).</p><p><strong>Conclusion: </strong>In the end, it felt like everyone in the industry needs to experience this simulation. Everybody at <a href="http://www.knolskape.com/">Knolskape</a> must attend at least one run of our simulations. It gives a lot of perspective about the big picture and how we are solving the industry problems in our domain. If we create a simulation storyline for <a href="http://www.knolskape.com/">Knolskape</a>, “Send people on live run” will be an<br>action with superb outcomes on morale and confidence.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a529ebfdacc9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/prod-io/changequest-my-first-live-simulation-run-a529ebfdacc9">ChangeQuest: My first live simulation run</a> was originally published in <a href="https://medium.com/prod-io">Prod.IO</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>