{"id":13598847,"url":"https://github.com/microsoft/ps-rule","last_synced_at":"2025-04-05T14:06:13.965Z","repository":{"id":40397081,"uuid":"205811333","full_name":"microsoft/ps-rule","owner":"microsoft","description":"Validate infrastructure as code (IaC) and DevOps repositories using GitHub Actions.","archived":false,"fork":false,"pushed_at":"2025-03-25T05:14:06.000Z","size":237,"stargazers_count":78,"open_issues_count":4,"forks_count":14,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-03-29T13:07:40.655Z","etag":null,"topics":["devops-tools","github","github-action","iac","infrastructure-as-code","powershell","psrule","rule"],"latest_commit_sha":null,"homepage":"https://github.com/marketplace/actions/psrule","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microsoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":"SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-02T08:28:38.000Z","updated_at":"2025-03-25T05:14:08.000Z","dependencies_parsed_at":"2024-06-18T16:55:31.525Z","dependency_job_id":"3bd89706-49d3-48ec-8890-0e3f41630e33","html_url":"https://github.com/microsoft/ps-rule","commit_stats":null,"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fps-rule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fps-rule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fps-rule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fps-rule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoft","download_url":"https://codeload.github.com/microsoft/ps-rule/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345852,"owners_count":20924102,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["devops-tools","github","github-action","iac","infrastructure-as-code","powershell","psrule","rule"],"created_at":"2024-08-01T17:00:57.417Z","updated_at":"2025-04-05T14:06:13.944Z","avatar_url":"https://github.com/microsoft.png","language":"PowerShell","readme":"# PSRule\n\nValidate infrastructure as code (IaC) and DevOps repositories using rules.\nPSRule allows you to analyze a repository with pre-built rules or create your own.\nAnalysis can be performed from input files or the repository structure.\n\nTo learn about PSRule and how to write your own rules see [Getting started][1].\n\n  [1]: https://microsoft.github.io/PSRule/v2/quickstart/standalone-rule/\n\n## Usage\n\nTo get the latest stable release use:\n\n```yaml\n- name: Run PSRule analysis\n  uses: microsoft/ps-rule@latest\n```\n\nTo get the latest stable release by major version use:\n\n```yaml\n- name: Run PSRule analysis\n  uses: microsoft/ps-rule@v2\n```\n\nTo get a specific release use **(recommended)**:\n\n```yaml\n- name: Run PSRule analysis\n  uses: microsoft/ps-rule@v2.9.0\n```\n\n---\n\n\u003e [!TIP]\n\u003e The recommended approach is to pin to the latest specific release for example `microsoft/ps-rule@v2.9.0`.\n\u003e Pinning to a specific release reduces the risk of new releases breaking your pipeline.\n\u003e\n\u003e You can easily update to the latest release by changing the version number or using version updates with Dependabot.\n\u003e To configure version updates of `github-actions` with Dependabot see [Configuring version updates][5].\n\u003e\n\u003e When the next release is available, bumping the version allows you to test in a feature branch before merging to main.\n\n---\n\nTo get the latest bits use **(not recommended for general use or production)**:\n\n```yaml\n- name: Run PSRule analysis\n  uses: microsoft/ps-rule@main\n```\n\n---\n\n\u003e [!CAUTION]\n\u003e Using `microsoft/ps-rule@main` is **not recommended** for general use or production workflows.\n\u003e The `main` branch is under **active development and may be unstable** or include breaking changes.\n\u003e Use `microsoft/ps-rule@main` to try latest updates before the next stable release and provide feedback.\n\n---\n\nTo use the latest action with an older version of PSRule, you can use the `version` parameter.\nFor example:\n\n```yaml\n- name: Run PSRule analysis\n  uses: microsoft/ps-rule@v2.9.0\n  with:\n    version: '1.11.1'\n```\n\nFor a list of changes please see the [change log][2].\n\n  [2]: CHANGELOG.md\n  [5]: https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuring-dependabot-version-updates#enabling-dependabot-version-updates\n\n## Inputs\n\n```yaml\n- name: Run PSRule analysis\n  uses: microsoft/ps-rule@main\n  with:\n    inputType: repository, inputPath                             # Optional. Determines the type of input to use for PSRule.\n    inputPath: string                                            # Optional. The path PSRule will look for files to validate.\n    modules: string                                              # Optional. A comma separated list of modules to use for analysis.\n    source: string                                               # Optional. A path containing rules to use for analysis.\n    baseline: string                                             # Optional. The name of a PSRule baseline to use.\n    conventions: string                                          # Optional. A comma separated list of conventions to use.\n    option: string                                               # Optional. The path to an options file.\n    outcome: Fail, Pass, Error, Processed, Problem, All          # Optional. Filters output to include results with the specified outcome.\n    outputFormat: None, Yaml, Json, NUnit3, Csv, Markdown, Sarif # Optional. The format to use when writing results to disk.\n    outputPath: string                                           # Optional. The file path to write results to.\n    path: string                                                 # Optional. The working directory PSRule is run from.\n    prerelease: boolean                                          # Optional. Determine if a pre-release module version is installed.\n    repository: string                                           # Optional. The name of the PowerShell repository where PSRule modules are installed from.\n    summary: boolean                                             # Optional. Determines if a job summary is written.\n    version: string                                              # Optional. The specific version of PSRule to use.\n```\n\n### `inputType`\n\nDetermines the type of input to use for PSRule either `repository` or `inputPath`.\nDefaults to `repository`.\n\nWhen set to:\n\n- `repository` - The structure of the repository within `inputPath` will be analyzed.\n- `inputPath` - Supported file formats within `inputPath` will be read as objects.\n\n### `inputPath`\n\nThe path PSRule will look for input files.\nYou can still use this parameter even when `inputType` is set to `repository`.\n\nThis must be a relative path from the `path` input parameter.\nDefaults to repository root.\n\n**Note:** Avoid using a relative path starting with `/`, as a leading slash indicates _root_ on Linux.\n\n### `modules`\n\nA comma separated list of modules to use for analysis.\n\nModules are additional packages that can be installed from the PowerShell Gallery.\nPSRule will install the latest **stable** version from the PowerShell Gallery automatically by default.\n[Available modules][3].\n\nTo install pre-release module versions, use `prerelease: true`.\n\n  [3]: https://www.powershellgallery.com/packages?q=Tags%3A%22PSRule-rules%22\n\n### `source`\n\nAn path containing rules to use for analysis.\nDefaults to `.ps-rule/`.\n\nUse this option to include rules that have not been packaged as a module.\n\n### `baseline`\n\nThe name of a PSRule baseline to use.\nBaselines can be used from modules or specified in a separate file.\n\n- To use a baseline included in a module use `modules:` with `baseline:`.\n- To use a baseline specified in a separate file use `source:` with `baseline:`.\n\n### `conventions`\n\nA comma separated list of conventions to use.\nConventions can be used from modules or specified in a separate file.\n\n- To use a convention included in a module use `modules:` with `conventions:`.\n- To use a convention specified in a separate file use `source:` with `conventions:`.\n\nFor example: `conventions: Monitor.LogAnalytics.Import`\n\n### `option`\n\nThe path to an options file.\nBy default, `ps-rule.yaml` will be used if it exists.\nConfigure this parameter to use a different file.\n\n### `outcome`\n\nFilters output to include results with the specified outcome.\nSupported outcomes are `Fail`, `Pass`, `Error`, `Processed`, `Problem`, `All`.\nDefaults to `Processed`.\n\n### `outputFormat`\n\nThe output format to write result to disk.\nSupported formats are `Yaml`, `Json`, `NUnit3`, `Csv`, `Markdown`, `Sarif`.\nDefaults to `None`.\n\n### `outputPath`\n\nThe file path to write results to when `outputFormat` is configured.\n\n### `path`\n\nThe working directory PSRule is run from.\nDefaults to repository root.\n\nOptions specified in `ps-rule.yaml` from this directory will be used unless overridden by inputs.\n\n### `prerelease`\n\nDetermine if a pre-release module versions are installed.\nWhen set to `true` the latest pre-release or stable module version is installed.\n\nIf this input is not configured, invalid, or set to `false` only stable module versions will be installed.\n\n### `repository`\n\nThe name of the PowerShell repository where PSRule modules are installed from.\nBy default this is the PowerShell Gallery.\n\nWhen configured, PowerShell modules are installed from this repository.\nBefore calling the `ps-rule` action, register and authenticate to the repository if required.\n\nFor example, to register a local repository use:\n\n```powershell\nRegister-PSRepository -SourceLocation \\\\server\\share -Name Local -InstallationPolicy Trusted;\n```\n\nFor details PowerShell repositories see [Working with Private PowerShellGet Repositories][4].\n\n  [4]: https://docs.microsoft.com/powershell/scripting/gallery/how-to/working-with-local-psrepositories\n\n### `summary`\n\nDetermines if a job summary is written.\nBy default, a job summary is generated and attached to the workflow run.\nWhen set to `false` the job summary is skipped.\n\n### `version`\n\nThe specific version of PSRule to use.\nBy default, the latest stable version of PSRule will be used.\nWhen set:\n\n- The specific version of PSRule will be installed and imported for use.\n- If a pre-release version is specified, `prerelease: true` must also be specified.\n- If the version is not found, an error will be thrown.\n\n## Using the action\n\nTo use PSRule:\n\n1. See [Creating a workflow file](https://help.github.com/articles/configuring-a-workflow#creating-a-workflow-file).\n2. Reference `microsoft/ps-rule@v2.9.0`.\nFor example:\n\n```yaml\nname: CI\non: [push]\njobs:\n  analyze:\n    name: Analyze repository\n    runs-on: ubuntu-latest\n    steps:\n\n    - name: Checkout\n      uses: actions/checkout@v3\n\n    - name: Run PSRule analysis\n      uses: microsoft/ps-rule@v2.9.0\n```\n\n3. Create rules within the `.ps-rule/` directory.\nFor example:\n\n```powershell\n# Example .ps-rule/GitHub.Community.Rule.ps1\n\n# Synopsis: Check for recommended community files\nRule 'GitHub.Community' -Type 'PSRule.Data.RepositoryInfo' {\n    $Assert.FilePath($TargetObject, 'FullName', @('LICENSE'));\n    $Assert.FilePath($TargetObject, 'FullName', @('CODE_OF_CONDUCT.md'));\n    $Assert.FilePath($TargetObject, 'FullName', @('CONTRIBUTING.md'));\n    $Assert.FilePath($TargetObject, 'FullName', @('README.md'));\n    $Assert.FilePath($TargetObject, 'FullName', @('.github/CODEOWNERS'));\n    $Assert.FilePath($TargetObject, 'FullName', @('.github/PULL_REQUEST_TEMPLATE.md'));\n}\n```\n\n4. Run the workflow.\n\n## Support\n\nThis project uses GitHub Issues to track bugs and feature requests.\nPlease search the existing issues before filing new issues to avoid duplicates.\n\n- For new issues, file your bug or feature request as a new [issue].\n- For help, discussion, and support questions about using this project, join or start a [discussion].\n\nSupport for this project/ product is limited to the resources listed above.\n\n[issue]: https://github.com/microsoft/ps-rule/issues\n[discussion]: https://github.com/microsoft/ps-rule/discussions\n\n## Contributing\n\nThis project welcomes contributions and suggestions. Most contributions require you to\nagree to a Contributor License Agreement (CLA) declaring that you have the right to,\nand actually do, grant us the rights to use your contribution. For details, visit\n\u003chttps://cla.microsoft.com\u003e.\n\nWhen you submit a pull request, a CLA-bot will automatically determine whether you need\nto provide a CLA and decorate the PR appropriately (e.g., label, comment).\nSimply follow the instructions provided by the bot.\nYou will only need to do this once across all repositories using our CLA.\n\n## Code of Conduct\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).\nFor more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)\nor contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n\n## Maintainers\n\n- [Bernie White](https://github.com/BernieWhite)\n\n## License\n\nThis project is [licensed under the MIT License](LICENSE).\n\n## Trademarks\n\nThis project may contain trademarks or logos for projects, products, or services.\nAuthorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft's Trademark \u0026 Brand Guidelines](https://www.microsoft.com/legal/intellectualproperty/trademarks).\nUse of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.\nAny use of third-party trademarks or logos are subject to those third-party's policies.\n","funding_links":[],"categories":["PowerShell"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fps-rule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoft%2Fps-rule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fps-rule/lists"}