Tuesday, July 19, 2016

Clickjacking


Clickjacking can be referred as an emerging threat on web. It is a malicious technique in which the Web user is tricked into clicking on something different from what the user perceives they are clicking, in turn reveals confidential information or taking control of their computer while clicking on web pages. It is an embedded code or a script that can execute without the user's knowledge, like clicking on a button that appears to perform another function.Clickjacking can cause severe damages, including compromising a user’s private webcam, email or other private data.The user views only the top level page but when they click, they actually trigger the functionality from another hidden layer. This causes some actions which the user never really intended.

The root cause of clickjacking is that an attacker application presents a sensitive UI element of a target application out of context to a user (such as hiding the UI by making it transparent), and hence the user is tricked to act out of context.

All modern browsers support the iframe HTML tag used to include content from another page in the current page. When the browser renders this tag, it fetches the page specified by the src attribute of the iframe tag and displays that page inside a region of the current page. For example:

<iframe src="http://www.microsoft.com/" height="300px" width="300px" />

Including this HTML tag on a web page will draw a 300×300 pixel frame displaying the home page of the Microsoft.com web site on that page. Users can interact with this frame just as if they had typed www.microsoft.com into the browser themselves; they can navigate hyperlinks, press buttons, submit forms, anything.
How to Prevent
In order to prevent this attack, we need to prevent others from framing our application. In ASP.NET application, we can simply add this to <system.webServer> in our Web.Config.

<System.Webserver>
<httpProtocol>
 <customHeaders>
        <add name="X-Frame-Options" value="DENY" />
      </customHeaders>
</httpProtocol>
</System.WebServer>


You can also add the below code to global.asax file

protected void Application_BeginRequest (object sender, EventArgs e)
{
HttpContext.Current.Response.AddHeader ("X-Frame-Options", "DENY");
}

Here we are adding X-FRAME-Options to response headers with value DENY.

There are 3 values possible to X-Frame-Options: 
i) DENY: do not allow any site to frame your application
ii) SAMEORIGIN: only allow same application site to frame
iii) ALLOW-FROM: only allow specific domain to frame your application

Saturday, July 9, 2016

Search for a Changeset


User can search for a changeset either to view the details or if they want to get a specific version of one or more files.

For finding a changeset user can perform the following:-
  • In Project Explorer, right-click, point to Team, and click Go to Changeset.The Go to Changeset dialog box appears.In Changeset, click Find.
User can search for changesets by any of the following 
  • In Containing file, user can type the file name.
  • User can also click the Browse button to search for the file.
  • In By user, user can type the name of the team member whose changesets to be viewed.
  • Under Range, user can specify in which changesets to search for the file, the user, or both:
  • All changes Searches the details of all changesets.
  • Changeset number searches for a changeset whose number is in a specific range. Click Changeset number, and then type the range of changeset numbers to search.
  • Created date searches for changesets that were created during a specific period. Under Created date, user can specify a starting and ending date and then click Find.
  • To display the details of a changeset, in the Results list, click a changeset and then click Details. User can also change to the selected changeset details and then click Save.

Changesets in TFS


Changesets in TFS


Note:- To perform this operation, the Read permission on at least one file must be set to Allow.

Changesets in TFS allows the user to store and find information about a single check-in operation. When a user check in the pending changes, a changeset is created which stores the information about file and folder revisions, links to related work items, check-in notes, a comment, policy compliance, and system metadata (owner name and date/time of check in).

Detailed Information of a changeset

User can get the historical information about one or more changeset:-
  • work items are associated with the changeset
  • what are the check-in comments
  • what are the files changed
  • what are the changes made
  • who changed the files
  • which policy warnings appeared

To view details of a changeset

  • In Project Explorer, right-click, point to Team, and click Go to Changeset.
  • The Go to Changeset dialog box appears.
Perform any of the following tasks:
  • In Changeset, type the changeset number and click OK.The details for the specified changeset appears.
  • Click Find to search for a changeset and view its details. 

Finding a Shelveset


Note:-To perform these operations, you must have the Read permission on at least one item to Allow.

To find a shelveset


  1. In Team Explorer, select the applicable project.
  2. On the File menu, click Source Control, and then click Unshelve Pending Changes. The Unshelve dialog box appears.
  3. The user can enter the name or alias of a team member in the Owner name box, and then click Find.
  4. From the Results list, click the shelveset for which you are searching.
  5. In the Unshelve dialog box, you can view shelveset details, delete a shelveset, or perform an unshelve operation. 
  6. Click Close.

Note:-User can also use * to perform wildcard search if user name is not known.

Sunday, March 6, 2016

Shelve and Unshelve Pending Changes

Shelve and Unshelve Pending Changes


Shelving enables you to keep the pending changes in your workspace or to share your code with other user for code review.

Steps to be followed:-

  1. You need to perform a Get Latest operation to synchronize your workspace with the latest versions of the files on the server.
  2. Build your application to make sure that it compiles before you shelve it or check it in. 

These steps needs to be followed in order to incorporate changes to versioned files that have been made outside your workspace.

To shelve folders and files from Source Control Explorer:-


In Source Control Explorer, right-click the file or folder, and then click Shelve Pending Changes.

In the Shelve - Source Files dialog box, type the shelveset name (for example, testshelve) in the Shelveset name box.

The Shelve - Source Files dialog box has two options:

  1. Preserve pending change locally.
  2. Evaluate Policies and check-in notes before shelving.
By default, first option is selected. When this option is selected, the changes you made to the files or folders in your local workspace are preserved.

When second option is selected, all check-in policies are evaluated before the shelveset is created. 

In the Comment box, type Testing shelveset, and then click Shelve.

All the files and folders are copied to the version control server and are available for other team members to unshelve.

To shelve folders and files from Solution Explorer:-


In Solution Explorer, right-click, and then click Shelve Pending Changes.

In the Shelve - Source Files dialog box, type the shelveset name (for example, testshelve) in the Shelveset name box.

The Shelve - Source Files dialog box includes two options:
  1. Preserve pending change locally.
  2. Evaluate Policies and check-in notes before shelving.

By default, first option is selected. When this option is selected, the changes you made to the files or folders in your local workspace are preserved.

When second option is selected, all check-in policies are evaluated before the shelveset is created.

In the Comment box, type Testing shelveset, and then click Shelve.

All the files and folders are copied to the version control server and are available for other team members to unshelve.

Unshelving


When you unshelve a shelveset, Team Foundation restores shelved revision to the destination workspace as a pending change.

To unshelve a set of pending changes:-

In Team Explorer, click File, point to Source Control, and then click Unshelve Pending Changes.
The Unshelve dialog box appears.

In the Owner name box, type the alias of the person who created the shelveset (for example, Shalu), and then click Find.

In the Results pane, select the shelveset you want to unshelve into your workspace, and then click Details.

In the Shelveset Details dialog box, if you want to delete the shelveset from the Team Foundation version control server, clear the Preserve shelveset on server box.

Select option, clear the Restore work items and check-in notes option if you do not want to restore the work items and check-in notes that are associated with the shelveset.

Select the shelveset or shelveset items that you want to unshelve into your workspace, and then click Unshelve.



Monday, January 4, 2016

Setting up an Outlook Appointment through C#



This example shows how to set up an outlook appointment through c#.

First add a reference to the Outlook COM object for your project.
1.In VS.NET right click on References and choose Add Reference.
2.Select the COM tab.
3.Choose "Microsoft Outlook 15.0 Object Library" (this is for MS Office 2013 ) and click Select.
4.Click OK.

using Microsoft.Office.Interop.Outlook;

Microsoft.Office.Interop.Outlook.Application app = null;
app = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.AppointmentItem appt = (Microsoft.Office.Interop.Outlook.AppointmentItem)app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);

try
   {
            appt.Subject = "Team Meeting";
            appt.Location = "Jupiter Room";
            appt.Sensitivity = Microsoft.Office.Interop.Outlook.OlSensitivity.olPrivate;
            appt.Start = DateTime.Parse("01/04/2016 02:00 PM");
            appt.End = DateTime.Parse("01/04/2016 02:30 PM");
            appt.ReminderSet = true;
            appt.ReminderMinutesBeforeStart = 10;
            appt.Save();
     }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                Console.WriteLine(ex.ToString());
            }

            finally
            {
                app = null;
                appt = null;
            }

You can also add sound file for a reminder by setting the ReminderPlaySound property as true.

  appt.ReminderPlaySound = true;