diff --git a/Changelog.md b/Changelog.md index 0971c687..a09f0f5e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.96] - 2026-08-01 +### Added +- Added HTML analysis and suppression support for `.html` and `.htm` files, including VS Code integration. + ## [1.0.95] - 2026-07-31 ### Pipeline - Added `.github/dependabot.yml` so Dependabot consolidates npm, NuGet, and GitHub Actions version updates into a single weekly pull request via a multi-ecosystem group, groups security updates per ecosystem into one pull request each, and labels its pull requests `no changelog` so the changelog gate passes. diff --git a/DevSkim-DotNet/Microsoft.DevSkim.Tests/DefaultRulesTests.cs b/DevSkim-DotNet/Microsoft.DevSkim.Tests/DefaultRulesTests.cs index 58d29280..c478ae9c 100644 --- a/DevSkim-DotNet/Microsoft.DevSkim.Tests/DefaultRulesTests.cs +++ b/DevSkim-DotNet/Microsoft.DevSkim.Tests/DefaultRulesTests.cs @@ -118,6 +118,44 @@ public void DenamespacedRule() Assert.AreEqual(1, analysis.Count()); } + [TestMethod] + [DataRow("html")] + [DataRow("htm")] + public void HtmlRulesApplyToHtmlFiles(string extension) + { + const string content = "Unsafe Link"; + const string rule = """ + [{ + "name": "HTML target blank without noopener", + "id": "HTML000001", + "description": "Detects target blank links without noopener", + "applies_to": [ + "html" + ], + "tags": [ + "security" + ], + "severity": "bestpractice", + "confidence": "high", + "patterns": [ + { + "pattern": "target\\s*=\\s*[\\\"']_blank[\\\"']", + "type": "regex" + } + ] + }] + """; + DevSkimRuleSet devSkimRuleSet = new DevSkimRuleSet(); + devSkimRuleSet.AddString(rule, "testRules"); + DevSkimRuleProcessor analyzer = new DevSkimRuleProcessor(devSkimRuleSet, new DevSkimRuleProcessorOptions()); + + IEnumerable analysis = analyzer.Analyze(content, $"thing.{extension}"); + + Assert.HasCount(1, analysis); + string suppression = DevSkimRuleProcessor.GenerateSuppressionByFileName($"thing.{extension}", "HTML000001"); + Assert.AreEqual("", suppression); + } + public static IEnumerable DefaultRules { get diff --git a/DevSkim-DotNet/Microsoft.DevSkim/resources/comments.json b/DevSkim-DotNet/Microsoft.DevSkim/resources/comments.json index e892c1dd..058a98a4 100644 --- a/DevSkim-DotNet/Microsoft.DevSkim/resources/comments.json +++ b/DevSkim-DotNet/Microsoft.DevSkim/resources/comments.json @@ -74,5 +74,12 @@ "inline": "::", "prefix": "Rem", "suffix": "\n" + }, + { + "language": [ + "html" + ], + "prefix": "" } ] \ No newline at end of file diff --git a/DevSkim-DotNet/Microsoft.DevSkim/resources/languages.json b/DevSkim-DotNet/Microsoft.DevSkim/resources/languages.json index b4665a5c..bbb02bd8 100644 --- a/DevSkim-DotNet/Microsoft.DevSkim/resources/languages.json +++ b/DevSkim-DotNet/Microsoft.DevSkim/resources/languages.json @@ -143,6 +143,10 @@ "name": "json", "extensions": [ ".json" ] }, + { + "name": "html", + "extensions": [ ".html", ".htm" ] + }, { "name": "xml", "extensions": [ ".xml" ] diff --git a/DevSkim-VSCode-Plugin/client/common/selectors.ts b/DevSkim-VSCode-Plugin/client/common/selectors.ts index ca6b03d9..ae36e185 100644 --- a/DevSkim-VSCode-Plugin/client/common/selectors.ts +++ b/DevSkim-VSCode-Plugin/client/common/selectors.ts @@ -7,6 +7,7 @@ export const selectors = [{ scheme: 'file', language: 'c' }, { scheme: 'file', language: 'fsharp' }, { scheme: 'file', language: 'go' }, { scheme: 'file', language: 'groovy' }, +{ scheme: 'file', language: 'html' }, { scheme: 'file', language: 'jade' }, { scheme: 'file', language: 'java' }, { scheme: 'file', language: 'javascript' }, diff --git a/DevSkim-VSCode-Plugin/package.json b/DevSkim-VSCode-Plugin/package.json index 7aa7eb62..bcc0cd2c 100644 --- a/DevSkim-VSCode-Plugin/package.json +++ b/DevSkim-VSCode-Plugin/package.json @@ -50,6 +50,7 @@ "onLanguage:sql", "onLanguage:rust", "onLanguage:groovy", + "onLanguage:html", "onLanguage:typescript", "onLanguage:typescriptreact", "onLanguage:jade",