Posts

Showing posts from April, 2021

Secure Coding in Java

Injection Attacks: Interpreted code User input formed maliciously System interprets input as a part of normal operation Unanticipated behavior Common Types SQL LDAP (Lightweight Directory Access Protocol) XSS/CSS (Cross site scripting) CRLF (Carriage Return and Line Feed) XPath SMTP/IMAP Code injection OS Command injection Host header injection SQL Injection: SQL Injection Situation SQL statement formed with variables String concatenation Malicious input repurposes SQL statement Example: foo ' or '1' = ' 1 SQL Injection Prevention Use the concept of PreparedStatement SQL statements accept variable as "?" placeholder Bind variable attached to statements, not query LDAP Injection: Caused by lack of sanitizing input (&(sn=<USERSN>(userpassword=<USERPASSWORD>)) Consider f* for USERSN with * for USERPASSWORD XPath Injection: Caused by lack of sanitizing input Vey similar to SQL injection in function Can be dangerous in injecting and manipulating dat...

Data Structure in Java

Image
Types of Data Structures: A data structure is way of collecting and organizing data Choosing the right data structure impacts efficiency Data comes from many sources e.g. Database, Files etc. Many data structures are implemented using as Linked list (Stack, queue etc.) Array List: Stores objects and can grow or shrink Linked List: Uses pointers to keep track of elements Vector: Can grow or shrink, It provides synchronization Stack: Operates on Last In , First Out (LIFO) Queue: Operates on First In, First Out (FIFO) Array List and Vectors: Advantages: Provide fast access using indexing  Memory Coherence Provide an initial size (optional) User internal array for storage, which makes random access fast Disadvantages: Can be time consuming to add elements in the middle Waste space if array is not full Need to be resized when they reach capacity Slower when deleting elements from the middle Linked List: Advantages: Insertion and deletion operations are easily implemented Elements are ef...