\n\n\u003Cfigcaption> Not real code. By the time I thought to take a screenshot, we’d already fixed everything. \u003C/figcaption>\n\n\u003C/figure>\n\u003C!-- /wp:image -->\n\n\u003C!-- wp:paragraph -->\nFar more interesting is all the open source \u003Cem>stuff\u003C/em> that made this possible:\u003Cbr>\u003Cbr>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:list -->\n\n\u003Cul>\u003Cli>In 2014, Microsoft open sourced Roslyn, their C# and VB.NET compiler.\u003C/li>\u003Cli>Visual Studio 2015 ships with support of Roslyn analyzers.\u003C/li>\u003Cli>\u003Ca href=\"https://github.com/security-code-scan/security-code-scan/graphs/contributors\">The authors\u003C/a> of Security Code Scan start work in 2016.\u003C/li>\u003Cli>I contribute \u003Ca href=\"https://github.com/security-code-scan/security-code-scan/pull/137\">some\u003C/a> \u003Ca href=\"https://github.com/security-code-scan/security-code-scan/pull/133\">minor\u003C/a> \u003Ca href=\"https://github.com/security-code-scan/security-code-scan/pull/127\">changes\u003C/a> to accommodate Stack Overflow peculiarities in 2019.\u003C/li>\u003C/ul>\n\n\u003C!-- /wp:list -->\n\n\u003C!-- wp:paragraph -->\nIf you’d told me six years ago that we’d be able to add any sort of code analysis to the Stack Overflow solution trivially, for free, and in a way that contributes back to the greater developer community, I wouldn’t have believed you. It’s great to see “the new Microsoft” behavior benefit us so directly, but it’s even greater to see what the OSS community has built because of it.\u003Cbr>\u003Cbr>We’ve only just shipped this, which begs the question...\u003Cbr>\u003Cbr>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:heading -->\n\n\u003Ch2>What’s next with static code analysis?\u003C/h2>\n\n\u003C!-- /wp:heading -->\n\n\u003C!-- wp:paragraph -->\n\u003Cstrong>Security is an ongoing process, not a bit you flip or a feature you add\u003C/strong>. Accordingly there will always be more to do and places we want to make improvements, and static code analysis is no different.\u003Cbr>\u003Cbr>As I alluded to at the start, we’re only analyzing \u003Cem>some\u003C/em> of the code behind Stack Overflow. More precisely we’re not analyzing views or tracing through interprocedural calls—analyzing both is an obvious next step.\u003Cbr>\u003Cbr>We’ll be able to start analyzing views once our migration to ASP.NET Core is complete. Pre-Core Razor view compilation doesn’t give us an easy way to add any analyzers, but that \u003Cem>should\u003C/em> be trivial once we’re upgraded. Razor's default behavior gives us some confidence around injection attacks, and views usually aren’t doing anything scary—but it will be nice to have stronger guarantees of correctness in the future.\u003Cbr>\u003Cbr>Not tracing through interprocedural calls is a bit more complicated. Technically, this is a limitation of Security Code Scan, as \u003Ca href=\"https://github.com/security-code-scan/security-code-scan/issues/110\">there’s an issue for it\u003C/a>. That we can’t analyze views reduces the value of interprocedural analysis today, as we almost always pass user-provided data into views. For now, we’re comfortable focusing on our controller action methods since basically all user-provided data passes through them before going onto views or other interprocedural calls.\u003Cbr>\u003Cbr>The beauty of open source is that when we do come back and do these next steps (and any other quality of life changes), we’ll be making them available to the community so everyone benefits. It’s a wonderful thing to be able to benefit ourselves, our customers, and .NET developers everywhere—all at the same time.\u003Cbr>\n\u003C!-- /wp:paragraph -->","html","2019-10-08T15:46:29.000Z",{"current":672},"adding-static-code-analysis-to-stack-overflow",[674,682,684,688,693,698,700,705],{"_createdAt":675,"_id":676,"_rev":677,"_type":678,"_updatedAt":675,"slug":679,"title":681},"2023-05-23T16:43:21Z","wp-tagcat-bulletin","9HpbCsT2tq0xwozQfkc4ih","blogTag",{"current":680},"bulletin","Bulletin",{"_createdAt":675,"_id":676,"_rev":677,"_type":678,"_updatedAt":675,"slug":683,"title":681},{"current":680},{"_createdAt":675,"_id":685,"_rev":677,"_type":678,"_updatedAt":675,"slug":686,"title":687},"wp-tagcat-code-analysis",{"current":687},"code-analysis",{"_createdAt":675,"_id":689,"_rev":677,"_type":678,"_updatedAt":675,"slug":690,"title":692},"wp-tagcat-company",{"current":691},"company","Company",{"_createdAt":675,"_id":694,"_rev":677,"_type":678,"_updatedAt":675,"slug":695,"title":697},"wp-tagcat-engineering",{"current":696},"engineering","Engineering",{"_createdAt":675,"_id":694,"_rev":677,"_type":678,"_updatedAt":675,"slug":699,"title":697},{"current":696},{"_createdAt":675,"_id":701,"_rev":677,"_type":678,"_updatedAt":675,"slug":702,"title":704},"wp-tagcat-stackoverflow",{"current":703},"stackoverflow","Stackoverflow",{"_createdAt":675,"_id":701,"_rev":677,"_type":678,"_updatedAt":675,"slug":706,"title":704},{"current":703},"Adding Static Code Analysis to Stack Overflow",[709,715,721,727],{"_id":710,"publishedAt":711,"slug":712,"sponsored":12,"title":714},"370eca08-3da8-4a13-b71e-5ab04e7d1f8b","2025-08-28T16:00:00.000Z",{"_type":10,"current":713},"moving-the-public-stack-overflow-sites-to-the-cloud-part-1","Moving the public Stack Overflow sites to the cloud: Part 1",{"_id":716,"publishedAt":717,"slug":718,"sponsored":662,"title":720},"e10457b6-a9f6-4aa9-90f2-d9e04eb77b7c","2025-08-27T04:40:00.000Z",{"_type":10,"current":719},"from-punch-cards-to-prompts-a-history-of-how-software-got-better","From punch cards to prompts: a history of how software got better",{"_id":722,"publishedAt":723,"slug":724,"sponsored":12,"title":726},"65472515-0b62-40d1-8b79-a62bdd2f508a","2025-08-25T16:00:00.000Z",{"_type":10,"current":725},"making-continuous-learning-work-at-work","Making continuous learning work at work",{"_id":728,"publishedAt":729,"slug":730,"sponsored":12,"title":732},"1b0bdf8c-5558-4631-80ca-40cb8e54b571","2025-08-21T14:00:25.054Z",{"_type":10,"current":731},"research-roadmap-update-august-2025","Research roadmap update, August 2025",{"count":734,"lastTimestamp":735},6,"2023-05-25T09:46:51Z",["Reactive",737],{"$sarticleModal":738},false,["Set"],["ShallowReactive",741],{"sanity-41lRn-xA_urjZ_48XE5VvOQycwaus2tptMGbb9i_m2Q":-1,"sanity-comment-wp-post-13376-1756387930422":-1},"/2019/10/08/adding-static-code-analysis-to-stack-overflow"]