Book Image

Visual Studio 2019 Tricks and Techniques

By : Paul Schroeder, Aaron Cure
Book Image

Visual Studio 2019 Tricks and Techniques

By: Paul Schroeder, Aaron Cure

Overview of this book

Visual Studio 2019 (VS 2019) and Visual Studio Code (VS Code) are powerful professional development tools that help you to develop applications for any platform with ease. Whether you want to create web, mobile, or desktop applications, Microsoft Visual Studio is your one-stop solution. This book demonstrates some of the most sophisticated capabilities of the tooling and shows you how to use the integrated development environment (IDE) more efficiently to be more productive. You’ll begin by gradually building on concepts, starting with the basics. The introductory chapters cover shortcuts, snippets, and numerous optimization tricks, along with debugging techniques, source control integration, and other important IDE features that will help you make your time more productive. With that groundwork in place, more advanced concepts such as the inner workings of project and item templates are covered. You will also learn how to write quality, secure code more efficiently as well as discover how certain Visual Studio features work 'under the hood'. By the end of this Visual Studio book, you’ll have learned how to write more secure code faster than ever using your knowledge of the extensions and processes that make developing successful solutions more enjoyable and repeatable.
Table of Contents (21 chapters)
1
Section 1: Visual Studio IDE Productivity Essentials
9
Section 2: Customizing Project Templates and Beyond
13
Section 3: Leveraging Extensions for the Win

Extending Puma Scan with custom sinks

Puma Scan traces data as it flows through the code, from its source (the origin of the data in the system, for example, an HTTP request) to the sink (the output or endpoint for the data, such as to an HTTP response or a database).

Let's modify our code to use a custom extension method, and then add a sink to the SQL injection rule so Puma Scan knows about it:

  1. Open the Controllers/WritingInstrumentController.cs file and comment out the line with FromSqlRaw in it. Also, uncomment the FromSqlWriting method. This method is a simple extension method that just calls FromSqlWriting. When you are done it should look like this:
    //var instrument = await context.Crayons.
        FromSqlRaw("SELECT * FROM Crayons WHERE HTMLColor 
        = '" + Color + "'").FirstOrDefaultAsync();
    var instrument = await context.Crayons.
        FromSqlWriting("SELECT * FROM Crayons...