DevSkim: Custom DevSkim rules (on yaml files) not showing in VSCode custom tab

Describe the bug I don’t manage to get DevSkim custom rules to show up in the Problems Tab in VSCode. I wrote a json file containing:

To Reproduce

[{
    "id": "TestRule",
    "name": "Basic Test Rule",
    "description": "A simple test rule.",
    "applies_to": ["yaml"],
    "tags": ["test"],
    "patterns": [{
        "pattern": "redirects",
        "type": "regex",
        "message": "Detected redirects."
    }]
}]

When I run:

devskim analyze -I "C:\pathToTestFolder" -r "C:\pathToCustomDevSkimRules"

The output shows a match on my custom rule. However when I simply open the yaml file in VSCode nothing is shown in the Problems tab.

I also added this:

    "MS-CST-E.vscode-devskim.rules.customRulesPaths": [
        "C:\\pathToCustomDevSkimRules"
    ],
    "MS-CST-E.vscode-devskim.logging.level": "debug",

Inside C:\Users\username\AppData\Roaming\VSCodium\User\settings.json. Other DevSkim rules do show up in the Problems tab.

Expected behavior My custom rules to show up in the Problems tab in VSCode.

Versions(please complete the following information):

  • OS: Windows 11
  • Devskim Version: devskim 1.0.44+10b85ce690

Other

I saw https://github.com/microsoft/DevSkim/issues/300 and my file extensions are actually yaml.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

I opened #674 to track the feature request to auto-rescan on settinngs change/add a new command to manually scan.

Thanks for the references. I believe we are using the language client library mentioned in 76405, I’ll try to take a look and see how this could fit in. The simplest solution might be to add an action to the command palate in vscode to trigger a reload.

The VsCode extension uses a Language Server model, so the VsCode front end launches and then talks to a C# language server that is running the C# DevSkim engine. I think what you may be encountering with it working after a reload is that when the language server relaunches it will load the specified rules from disc with your options - but while VsCode is already running any changes to those files will be reflected on disc but are not hot reloaded into the language server.

Probably this. I just experienced that despite reloading the window, a previous rule kept working and the new one did not yet. I need to find a way to either manually reload that language server, and then preferably get the extension to do hot reloading at some point.

Possibly related:

I can confirm that one works indeed.

FWIW, the example rule I shared in the other thread does seem to be working in VS Code. Resharing here:


[{
    "name": "YamlPathValidate",
    "id": "YmlPath",
    "tags": ["test"],
    "description": "values under a key named test that start with XX",
    "severity": "critical",
    "patterns": [
      {
        "pattern":"XX\\w*",
        "ymlpaths" : ["/**/test/*"],
        "type": "regex",
        "scopes": [
          "code"
        ],
        "modifiers": [
          "i"
        ],
        "confidence": "high"
      }
    ]
  }]

Image