Showing posts with label aniruddha. Show all posts
Showing posts with label aniruddha. Show all posts

Wednesday, April 2, 2025

Analyzing Your Maven POM Files with POM Analyzer

Report View



 

When working with Maven projects, managing dependencies effectively is crucial to ensuring the stability, security, and up-to-dateness of your applications. POM files (Project Object Model) are at the heart of Maven builds, defining the dependencies, plugins, and other configurations. However, keeping track of dependency versions and identifying vulnerabilities manually can be a daunting task.

This is where POM Analyzer comes into play. POM Analyzer automates the process of analyzing your Maven build file, POM, to find the current versions of dependencies versus the latest versions available. Additionally, it scans for known vulnerabilities, providing a comprehensive HTML report that is both easy to read and insightful.

What Does POM Analyzer Do?

POM Analyzer performs the following tasks:

  1. Version Comparison: It compares the current version of each dependency listed in the POM file with the latest version available from search.maven.org/solrsearch.
  2. Vulnerability Check: It scans each dependency against ossindex.sonatype.org to detect known vulnerabilities.
  3. HTML Report Generation: Using Apache FreeMarker, it generates a well-structured HTML report. This report includes the following sections:
    • Project Name and Description
    • Total Libraries
    • Vulnerable Libraries (with direct vulnerabilities)
    • Unique Vulnerabilities (listed based on their CVSS scores)
  4. Direct Links for Verification: Each vulnerability reported includes links to credible sites for further investigation.

How Does It Work?

The POM Analyzer follows these steps:

  1. Pre-check: It first ensures that Maven is installed on your machine.
  2. POM File Validation: It checks whether the provided POM file is valid.
  3. Dependency Tree Generation: The tool generates a dependency tree, parsing each artifact for version analysis and vulnerability checks.
  4. Report Generation: After collecting the necessary data, it utilizes Apache FreeMarker to craft a detailed HTML report.

Why Choose POM Analyzer?

One of the biggest challenges in maintaining a Maven project is keeping dependencies updated while also monitoring for security issues. POM Analyzer addresses this by automating the entire process, saving time and reducing the risk of missing critical updates or vulnerabilities.

A Word of Caution

Since the tool continuously queries the OSS Index API to check for vulnerabilities, generating the report may take a little time. Additionally, repeated requests may temporarily block the machine from accessing data. Therefore, patience is key while using the tool.

Final Thoughts

The POM Analyzer is an invaluable tool for Maven project maintainers. It not only streamlines the process of dependency management but also integrates vulnerability analysis to enhance project security. Whether you are looking to keep your dependencies up to date or proactively secure your project from known vulnerabilities, POM Analyzer has got you covered.

For more details and to explore the project, visit the GitHub repository (https://github.com/adchowdhury/pomAnalyzer).

Friday, May 8, 2015

Solution to Reverse Words

This is one solution to "Reverse Words" problem in google codejam hosted at https://code.google.com/codejam/contest/351101/dashboard#s=p1

import java.io.BufferedReader;
import java.io.FileReader;

/**
 * @author: Aniruddha Dutta Chowdhury (adchowdhury@gmail.com)
 * @since: May 8, 2015
 */

public class ReverseWords {

    public static void main(String[] args) {
        String filePath = "input.txt";
       
        try {
            BufferedReader br = new BufferedReader(new FileReader(filePath));
            String sCurrentLine;
            StringBuffer sb = new StringBuffer();
            int insertIndex = 0;
            char currentChar = '\b';
            while ((sCurrentLine = br.readLine()) != null) {
                //System.out.println(sCurrentLine);
                for(int iCharCounter = 0; iCharCounter < sCurrentLine.length(); iCharCounter++) {
                    currentChar = sCurrentLine.charAt(iCharCounter);
                    if(currentChar == ' ') {
                        insertIndex = 0;
                        sb.insert(insertIndex, currentChar);
                    }else {
                        sb.insert(insertIndex++, currentChar);
                    }
                }
                System.out.println(sb);
                sb = new StringBuffer();
                insertIndex = 0;
            }
        } catch (Throwable a_th) {
            a_th.printStackTrace();
        }
    }
}

Thursday, April 2, 2015

Hack to KUKU-KUBE

Hi

Its long since my last blog. Was caught up into many things and also was looking for something interesting to post.

This is hack to the game available in below link as of the date of publishing this blog. The idea is borrowed from "Imitation Game" & "Independence Day" movie.

http://www.kuku-kube.com/


Steps to make the game simpler are as follows:
1) Open the link in browser
2) Use firebug or other javascript debug tool. That can be invoked by pressing F12 on windows machines.
3) Copy the below whole code
4) Paste in the console area and execute
5) Now play the game. All tiles should be black & white. Which gives probability of scoring around 70 per minute.

function getScript(url, success) { 
 var script = document.createElement('script');
 script.src = url;
  
 var head = document.getElementsByTagName('head')[0],
 done = false;
  
 // Attach handlers for all browsers
 script.onload = script.onreadystatechange = function() {
  
   if (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete'){    
    // callback function provided as param
    success();    
    script.onload = script.onreadystatechange = null;
    head.removeChild(script);    
   };  
  };
}

getScript('http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js',function(){
console.log(jQuery("span").size())
});
setInterval(changeColor, 100);
function changeColor(){
var previousColor = null;
jQuery("#box").find("span").each(function(index, element){
  if(index == 0){
    previousColor = null;
  }
 // console.log(index + " : " + previousColor + " : " + jQuery(this).css("background-color"))
  if(previousColor == null){
    previousColor = jQuery(this).css("background-color");
    jQuery(this).css("background-color", 'black')    
  }else  if(jQuery(this).css("background-color") == previousColor){
    jQuery(this).css("background-color", 'black')
  }else{
    jQuery(this).css("background-color", 'white')
  }
})
}

Friday, June 28, 2013

Solution to Store Credit

This is a probable solution to CODE JAM's Store Credit.


import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;


public class StoreCredit {
   
    public static void main(String[] args) {
        try {
            Scanner scanner = new Scanner(ReverseWords.class.getClassLoader().getResourceAsStream("A-large-practice.in"));
            int problemCount = Integer.parseInt(scanner.nextLine());
            int caseCounter = 1;
            for(int iProblemCounter = 0; iProblemCounter < problemCount; iProblemCounter++) {
                Set completedIndexes = new HashSet();
               
                int creditAmount = Integer.parseInt(scanner.nextLine());
                int numberOfItems = Integer.parseInt(scanner.nextLine());
                String itemsLine = scanner.nextLine();
                String[] intArray = itemsLine.split(" ");
                String output = "";
                itemLoop:{
                    for (int iArrayCounter = 0; iArrayCounter < numberOfItems; iArrayCounter++) {
                        completedIndexes.add(iArrayCounter);
                        for (int iArrayInnerCounter = 0; iArrayInnerCounter < numberOfItems; iArrayInnerCounter++) {
                            if(completedIndexes.contains(iArrayInnerCounter)) {
                                continue;
                            }
                            int sum = (Integer.parseInt(intArray[iArrayCounter]) + Integer.parseInt(intArray[iArrayInnerCounter]));
                            output = (iArrayCounter + 1) + " " + (iArrayInnerCounter + 1);
                            if(sum == creditAmount) {
                                break itemLoop;
                            }
                        }
                    }
                }
                System.out.println("Case #" + (caseCounter++) + ": " + output);
            }
        } catch (Throwable a_th) {
            a_th.printStackTrace();
        }
    }
}
See you later friends.

Thursday, March 14, 2013

Windows Service Monitor and starting

Hi friends,

It's been long since my last post. Again I am here with some solution. Specifically for windows. The problem statement was, few windows service was getting stopped all of a sudden due to some error. What we needed is one small utility which monitors the specific service and start that if that is stopped.

There was many suggestion and solution, many monitoring softwares. But I liked the solution mentioned below. Took quite some time to collect all the information and build it.

First copy paste the below code in a file named as "serviceMonitor.vbs" or you can choose any other name as well.


Set sh = CreateObject("Shell.Application")
set shellLogger = CreateObject("WScript.Shell")

If sh.IsServiceRunning("SERVICE_TO_MONITOR") Then
    shellLogger.LogEvent 4, "
SERVICE_TO_MONITOR is running"
Else
    shellLogger.LogEvent 4, "
SERVICE_TO_MONITOR is not running"
    if sh.ServiceStart("
SERVICE_TO_MONITOR", true) Then
        shellLogger.LogEvent 4, "
SERVICE_TO_MONITOR automatically started"
    Else
        shellLogger.LogEvent 4, "
SERVICE_TO_MONITOR could not be started"
    End If
End If   

Replace the word SERVICE_TO_MONITOR with name of your service.
Then open scheduler and create a task. Choose the trigger you want, I kept it at every 1 min.

wolla...  your windows service will never be down. If it is down, It will be up within next one min. :)

Saturday, June 23, 2012

DiamondPattern

Hi friends,

This is a simple program which generates a diamond kind of pattern with the passed character which is 'e' in this case.




public class DiamondPattern {
    public static void main(String[] args) {
        printPattern('e');
    }
   
    private static final int BASE_CHAR = (int)'a';
   
    private static void printPattern(char a_endChar) {
        int charCounter = BASE_CHAR;
        boolean isIncreasing = true;
        do {
            System.out.print(getPadding(a_endChar - charCounter + 1));
           
            for(int iHCounter = BASE_CHAR; iHCounter < charCounter; iHCounter++) {
                System.out.print((char)iHCounter);
            }
           
            for(int iHCounter = charCounter - 2; iHCounter >= BASE_CHAR; iHCounter--) {
                System.out.print((char)iHCounter);
            }
           
            if(isIncreasing) {
                charCounter++;
            }else {
                charCounter--;
            }
           
            if(charCounter > a_endChar) {
                isIncreasing = false;
            }
            System.out.println();
        }while(charCounter >= BASE_CHAR);
    }
   
    public static String getPadding(int a_padCount) {
        StringBuffer strPadding = new StringBuffer();
        for (int iCounter = 0; iCounter < a_padCount; iCounter++) {
            strPadding.append(' ');
        }
        return strPadding.toString();
    }
}

Saturday, November 12, 2011

Java Hibernate Multiple Map into One Table

Hi Friends,

Recently I was trying to do something different. I could not find exact solution what I was looking for. Thus sharing here. Some one else might be benefited by this.

Now I will get straight to the point. First the problem statement:

I have a Java class like this


import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

/**
 * @author: Aniruddha Dutta Chowdhury

 *
 */
public class HibernateDemo implements Serializable {
    private static Logger        logger            = Logger.getLogger(HibernateDemo.class);

    private Map    requestData        = new HashMap();
    private Map    contextData        = new HashMap();
    private Map    responsetData    = new HashMap();
    private Date                timeOfAction    = null;
    private Long                id                = null;
   
    public Map getResponsetData() {
        return responsetData;
    }
   
    public void setResponsetData(Map responsetData) {
        this.responsetData = responsetData;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getTimeOfAction() {
        return timeOfAction;
    }

    public void setTimeOfAction(Date timeOfAction) {
        this.timeOfAction = timeOfAction;
    }

    public Map getRequestData() {
        return requestData;
    }

    public void setRequestData(Map requestData) {
        this.requestData = requestData;
    }

    public Map getContextData() {
        return contextData;
    }

    public void setContextData(Map contextData) {
        this.contextData = contextData;
    }

    public Map getResponseData() {
        return responseData;
    }

    public void setResponseData(Map responseData) {
        this.responseData = responseData;
    }

    private Map    responseData    = new HashMap();
}


And I wanted only two tables for this whole class. One for the main class and another one for all the map members.

Desired tables are as follows:


MAIN_TABLE
ID PK
ACTION_TIME


AND the child table would be


CHILD_TABLE
PARENT_ID FK
KEY
VALUE
DISCRIMINATOR

Now this is not a big deal for hibernate. Using the where clause. But the question comes that how to fill the value for discriminator. Then after going through hibernate api I came up with this. The SQL-INSERT is really very handy in this case.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping
    PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
    <class name="HibernateDemo" table="MAIN_TABLE">
        <id name="id">
            <generator class="native" />
        </id>
        <property name="timeOfAction" />
        <map name="requestData" table="CHILD_TABLE" where="DISCRIMENATOR='REQUEST'">       
            <key column="PARENT_ID" />
            <index column="KEY" type="string" />
            <element column="VALUE" type="string" />
            <sql-insert>insert into CHILD_TABLE (PARENT_ID, KEY, VALUE, DISCRIMENATOR) values (?, ?, ?, 'REQUEST')</sql-insert>
        </map>
       
        <map name="contextData" table="CHILD_TABLE" where="DISCRIMENATOR='CONTEXT'">       
            <key column="PARENT_ID" />
            <index column="KEY" type="string" />
            <element column="VALUE" type="string" />
            <sql-insert>insert into CHILD_TABLE (PARENT_ID, KEY, VALUE, DISCRIMENATOR) values (?, ?, ?, 'CONTEXT')</sql-insert>
        </map>
       
        <map name="responsetData" table="CHILD_TABLE" where="DISCRIMENATOR='RESPONSE'">       
            <key column="PARENT_ID" />
            <index column="KEY" type="string" />
            <element column="VALUE" type="string" />
            <sql-insert>insert into CHILD_TABLE (PARENT_ID, KEY, VALUE, DISCRIMENATOR) values (?, ?, ?, 'RESPONSE')</sql-insert>
        </map>
    </class>
</hibernate-mapping>



Hope this will help you. Till next time, BYE.

Sunday, September 25, 2011

Start command prompt from context menu in windows

Hi folks,

Again another techie blog.

 This is to solve a simple problem we all face quite often in our daily life. Mainly QA person and developers face this. For getting Command prompt from any opened folder we have to open command prompt then copy the path then paste and ...... long process... Huh..

So here is a simple solution, copy the following text in a .reg file and save that. Now run it once, In some secured system it may ask for admin rights, as it will update the registry. But no worry, just allow it. After that on any right click of any folder will give u an option to open command prompt from there.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\startCmd]
@="Start Command Prompt From Here"
"@author"="Aniruddha Dutta Chowdhury"

[HKEY_CLASSES_ROOT\Directory\shell\startCmd\command]
@="cmd /k pushd \"%1\""