SQLServerCentral Editorial

Securing Code Early

,

Last year I started to get alerts from Microsoft Repos that someone had put a piece of security information in their code that pertained to one of my Azure services. At first I was worried, but then I realized this was the public version of AdventureWorks we maintain in Azure. We've published the login so people can test code against this if they want, and I started ignoring the warnings. Well, not ignoring. I still glance over them to verify the issue, but I'm less concerned.

That doesn't mean that you shouldn't be concerned about sensitive information in repos. I saw this quote: " Bots are crawling all over GitHub seeking secret keys, a developer served with a $2,375 Bitcoin mining bill found." This follows a sentence that says "It once caused Uber to leak the contact details of 75m users". These are from an interesting look at a way to secure code that might leak API keys. The idea is that you secure code on local commits and prevent secrets from being stored in your VCS.

That's a great idea. Can we prevent passwords in SQL code or ASP.NET config files? Can we actually start to teach developers to use secrets and other run-time mechanisms and prevent them from hard coding anything into a VCS? Perhaps, but we have a lot way to go and certainly more tool chains need to be updated to prevent what is a simple, but common, mistake.

We need to get better at security, and we are. I see more Static Code Analysis tools being used in all sorts of companies, and I'm glad when they start to impact developers. While I get that changing your favorite method of writing a query or procedure is a pain, often we can reduce potential problems by enforcing some standards and avoiding poor coding practices. We do need to have exceptions since a rule for code might really be a general guideline 99% of the time with a few edge cases.

Catching issues early in development is one of the goals. Having things like inline SCA in SQL Prompt (live demo), or continuous testing in Visual Studio, scanning with Sonarqube, and other tools are improving our code, while allowing us to build applications faster. There is plenty of other work to be done, especially for database code, but we are improving as an industry.

If you haven't used any of these tools and you write code, start learning a bit about them. You'll likely appreciate their benefits once you get over the learning curve. You'll also start writing better code.

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating