Code Monkey home page Code Monkey logo

psrule-vscode's Introduction

PSRule

Validate infrastructure as code (IaC) and DevOps repositories using the PSRule PowerShell module. PSRule is powerful, feature rich, and highly customizable to meet your needs.

module-version-badge

This extension is available in two release channels:

Channel Description Version/ downloads
Preview More frequent releases but more likely to contain bugs. Preview ext-preview-installs-badge
Stable Less frequent releases, with more user testing, experimental features are disabled. Stable ext-stable-installs-badge

Features

CodeLens

CodeLens showing link to create documentation

  • CodeLens shows links to create or edit markdown documentation from rules in YAML, JSON, or PowerShell.
    • Open documentation — Opens rule markdown documentation in the editor.
      • The location for storing documentation is configurable in the extension settings.
      • By default, a locale specific folder is created in the same directory as the rule file.
    • Create documentation — Creates a new markdown file for the rule based on a snippet.
      • New markdown documentation is created with the built-in Rule Doc snippet.
      • An alternative snippet can be specified by configuring extension settings.

IntelliSense

Options suggestion context menu

  • Adds IntelliSense and validation support for configuring options and resources.
    • Workspace options — use IntelliSense to configure options for the workspace.
      • Type or trigger IntelliSense with Ctrl+Space from ps-rule.yaml.
    • Create resources — define baselines and selectors by using pre-built snippets and IntelliSense.

Rule definition snippet

  • Adds snippets for defining new rules.
    • Define rules with snippets and IntelliSense support.
      • Trigger IntelliSense by typing rule in a .Rule.ps1, .Rule.yaml, or .Rule.jsonc file. IntelliSense can also be triggered by using the shortcut Ctrl+Space.

Rule markdown documentation snippet

  • Adds snippets for creating markdown documentation.
    • Quick documentation — create rule documentation to provide rule recommendations and examples.
      • Trigger IntelliSense by typing rule in a .md file. IntelliSense can also be triggered by using the shortcut Ctrl+Space.

Quick tasks

Built-in tasks shown in task list

  • Adds quick tasks for analysis directly from Visual Studio Code.
    • Run analysis — runs rules against files in the current workspace.
      • Input path, Baseline, Modules, and Outcome options can be configured per task.
      • Output as, and showing a Not processed warning options can be configured by workspace or user.
      • Rule stored in .ps-rule/ are automatically used by default.
      • Use the built-in analysis task by running or configuring the task from the Terminal menu.

Configuration

In addition to configuring the ps-rule.yaml options file, the following settings are available.

Name Description
PSRule.codeLens.ruleDocumentationLinks Enables Code Lens that displays links to rule documentation. This is an experimental feature that requires experimental features to be enabled.
PSRule.documentation.path The path to look for rule documentation. When not set, the path containing rules will be used.
PSRule.documentation.localePath The locale path to use for locating rule documentation. The VS Code locale will be used by default.
PSRule.documentation.customSnippetPath The path to a file containing a rule documentation snippet. When not set, built-in PSRule snippets will be used.
PSRule.documentation.snippet The name of a snippet to use when creating new rule documentation. By default, the built-in Rule Doc snippet will be used.
PSRule.execution.notProcessedWarning Warn when objects are not processed by any rule. This option is deprecated and replaced by PSRule.execution.unprocessedObject.
PSRule.execution.ruleExcluded Determines how to handle excluded rules. When set to None, PSRule will use the default (Ignore), unless set by PSRule options.
PSRule.execution.ruleSuppressed Determines how to handle suppressed rules. When set to None, PSRule will use the default (Warn), unless set by PSRule options.
PSRule.execution.unprocessedObject Determines how to report objects that are not processed by any rule. When set to None, PSRule will use the default (Warn), unless set by PSRule options.
PSRule.experimental.enabled Enables experimental features in the PSRule extension.
PSRule.notifications.showChannelUpgrade Determines if a notification to switch to the stable channel is shown on start up.
PSRule.notifications.showPowerShellExtension Determines if a notification to install the PowerShell extension is shown on start up.
PSRule.output.as Configures the output of analysis tasks, either summary or detailed.
PSRule.rule.baseline The name of the default baseline to use for executing rules. This setting can be overridden on individual PSRule tasks.

Support

This project uses GitHub Issues to track bugs and feature requests. Please search the existing issues before filing new issues to avoid duplicates.

  • For new issues, file your bug or feature request as a new issue.
  • For help, discussion, and support questions about using this project, join or start a discussion.

Support for this project/ product is limited to the resources listed above.

Installing PSRule module

PSRule is available from the PowerShell Gallery and is required for this extension to work.

To install the module use the following command from a PowerShell prompt.

Install-Module -Name PSRule -Scope CurrentUser;

Installing the extension

You can install the latest release of the extension by following the steps in the Visual Studio Code documentation. In the Extensions pane, search for PSRule extension and install it there. You will get notified automatically about any future extension updates.

code --install-extension bewhite.psrule-vscode-preview

NOTE: If you are using VS Code Insiders, the command will be code-insiders.

Contributing

This project welcomes contributions and suggestions. If you are ready to contribute, please visit the contribution guide.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Maintainers

License

This project is licensed under the MIT License.

psrule-vscode's People

Contributors

armaanmcleod avatar berniewhite avatar dependabot[bot] avatar github-actions[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

psrule-vscode's Issues

Add support for selectors

Update language schema to support selectors added in PSRule v1.2.0.

Additionally add snippet for selector resources.

Update extension channel display name and preview flag

Currently PSRule extension is called "PSRule" and is flagged as preview. Going forward we need to clearly differentiate between the two release channels stable and preview.

  • Stable will used the display name of "PSRule".
  • Preview will use the display name of "PSRule (Preview)" with the preview flag set.

Local builds will use the dev channel, with the display name "PSRule (Dev)" with the preview flag set.

Add snippet for moduleConfig resource

In PSRule v0.17.0 a module-wide configuration resource ModuleConfig was introduced.

A snipped should be added to make starting a module configuration easier.

CI badge not displaying in VSCode extension tab

Description of the issue

CI badge from *.visualstudio.com is not in safe exclusion list. Badge should be changed to originate from dev.azure.com domain instead.

To Reproduce

Steps to reproduce the issue:

  • Open PSRule extension details from VSCode. Where image should be, ci-bage placeholder is displayed instead of badge.

Expected behaviour

Badge should be displayed.

Extension version:

  • Version: 0.1.0

Add extension bundling

Extensions can be bundled to reduce the size and improve performance. Implement bunding for PSRule within the CI pipeline.

Add baseline YAML snippet

Add a snippet for adding a baseline object in YAML.

Defining a named baseline was introduced in PSRule v0.9.0.

Configure workspace trust

Configure workspace trust for the extension.

microsoft/vscode#120251

Ideally we would want to disable features that are not supported like tasks, however it may not be possible depending on the PowerShell extension.

Update highlighting for synopsis metadata in comments

Add grammar highlighting to support use of Synopsis: similar to Description: used in comment based metadata.

For example:

# Synopsis: Redis Cache should reject TLS versions older then 1.2
Rule 'redis.MinTLS' -If { ResourceType 'Microsoft.Cache/Redis' } {
    # Check that TLS is within range
    Within 'properties.minimumTlsVersion' '1.2'
}

This is related to BernieWhite/PSRule#164

Use of Description: is deprecated and will be removed in the future, but right now both are supported and should be highlighted correctly.

Create rule documentation

To further optimize a rule authoring workflow, adding the ability to create a markdown file for a rule would make this process faster.

Extension pipeline updates for v1

Currently a preview extension is provided. To go live with v1.0.0 some additional tasks need to be completed to update the CI pipeline for a GA release:

  • Update docs to differentiate on release cycle of GA and preview releases.
  • Improve CI so that updates hit preview faster.

Add apiVersion property to resources

PSRule v1.2.0 recommends using the apiVersion property for resources. Add support for this property in the language schema.

Additionally update snippets to add the new apiVersion.

Syntax highlighting includes keywords that are included in comments

Description of the issue

A comment within a Rule block may include words such as ensure or within. Currently these are highlighted as keywords.

Keywords used outside of a Rule block are not highlighted and treated as comments, which is correct.

To Reproduce

Steps to reproduce the issue:

Rule 'example' {
    # Check that within the block there is comments
}

In the example above, within is incorrectly highlighted as a keyword.

Expected behaviour

Keywords within comments should not be highlighted as a keyword.

Extension version:

  • Version: 0.1.0

Document features and how to use them

Currently the documentation on the features of the extension are minimal and may be unclear. In preparation for a GA release this needs to be expanded.

Update PSRule options schema to v0.7.0

Currently PSRule extension v0.3.0 ships with PSRule v0.5.0 options schema. In PSRule v0.7.0 additonal options for encoding and output formatting as CSV were added.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.