microsoft / psrule.rules.github Goto Github PK
View Code? Open in Web Editor NEWA suite of rules to validate GitHub repositories using PSRule.
License: MIT License
A suite of rules to validate GitHub repositories using PSRule.
License: MIT License
Description of the issue
Export of repository data crashes out if permission is not provided. Some restricted repository information may not be accessible with the default GitHub Actions token or with the provided token.
Expected behaviour
Attempts to export data that is not authorized should not crash the process.
Error output
Capture any error messages and or verbose messages with -Verbose
.
ForbiddenException: Resource not accessible by integration
AggregateException: One or more errors occurred. (Resource not accessible by integration)
Use a CODEOWNERS
file to automatically route reviewer for pull requests.
Add support for exporting the following branch protection data.
Description of the issue
I know it is still a 0.2.0, but would be great if some things already work.
Can't wait till you get this working!
To Reproduce
Steps to reproduce the issue:
Install-Module -Name 'PSRule.Rules.GitHub' -Scope CurrentUser;
Export-GitHubRuleData -Repository dylanprins93/
Assert-PSRule -Module 'PSRule.Rules.GitHub' -InputPath .\*.json -Format File;
Expected behaviour
Well, something...
Error output
Capture any error messages and or verbose messages with -Verbose
.
VERBOSE: [PSRule][D] -- Discovering rules in: C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\Baseline.Rule.yaml
VERBOSE: [PSRule][D] -- Discovering rules in: C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\Config.Rule.yaml
VERBOSE: [PSRule][D] -- Discovering rules in: C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\Convention.Rule.ps1
VERBOSE: [PSRule][D] -- Found PSRule.Rules.GitHub\GitHub.ExpandRepository in C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\Convention.Rule.ps1
VERBOSE: [PSRule][D] -- Discovering rules in: C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\GitHub.Branch.Rule.ps1
VERBOSE: [PSRule][D] -- Found PSRule.Rules.GitHub\GitHub.Branch.Name in C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\GitHub.Branch.Rule.ps1
VERBOSE: [PSRule][D] -- Discovering rules in: C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\GitHub.Common.Rule.ps1
VERBOSE: [PSRule][D] -- Discovering rules in: C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\GitHub.Repo.Rule.ps1
VERBOSE: [PSRule][D] -- Found PSRule.Rules.GitHub\GitHub.Repo.Protected in C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\GitHub.Repo.Rule.ps1
VERBOSE: [PSRule][D] -- Found PSRule.Rules.GitHub\GitHub.Repo.CodeOfConduct in C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\GitHub.Repo.Rule.ps1
VERBOSE: [PSRule][D] -- Found PSRule.Rules.GitHub\GitHub.Repo.Contributing in C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\GitHub.Repo.Rule.ps1
VERBOSE: [PSRule][D] -- Found PSRule.Rules.GitHub\GitHub.Repo.Readme in C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\GitHub.Repo.Rule.ps1
VERBOSE: [PSRule][D] -- Found PSRule.Rules.GitHub\GitHub.Repo.CodeOwners in C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\GitHub.Repo.Rule.ps1
VERBOSE: [PSRule][D] -- Found PSRule.Rules.GitHub\GitHub.Repo.License in C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\GitHub.Repo.Rule.ps1
VERBOSE: [PSRule][D] -- Found PSRule.Rules.GitHub\GitHub.Repo.Description in C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\GitHub.Repo.Rule.ps1
VERBOSE: [PSRule][D] -- Found PSRule.Rules.GitHub\GitHub.Repo.IssueTempate in C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\GitHub.Repo.Rule.ps1
VERBOSE: [PSRule][D] -- Found PSRule.Rules.GitHub\GitHub.Repo.PRTemplate in C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\GitHub.Repo.Rule.ps1
VERBOSE: [PSRule][D] -- Discovering rules in: C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\Baseline.Rule.yaml
VERBOSE: [PSRule][D] -- Discovering rules in: C:\Users\DylanPrins\OneDrive - InSpark\Documenten\PowerShell\Modules\PSRule.Rules.GitHub\0.2.0\rules\Config.Rule.yaml
VERBOSE: [PSRule][R][0][PSRule.Rules.GitHub\GitHub.Branch.Name] :: github-22a87384.json
VERBOSE: [PSRule][R][0][PSRule.Rules.GitHub\GitHub.Repo.Protected] :: github-22a87384.json
VERBOSE: [PSRule][R][0][PSRule.Rules.GitHub\GitHub.Repo.CodeOfConduct] :: github-22a87384.json
VERBOSE: [PSRule][R][0][PSRule.Rules.GitHub\GitHub.Repo.Contributing] :: github-22a87384.json
VERBOSE: [PSRule][R][0][PSRule.Rules.GitHub\GitHub.Repo.Readme] :: github-22a87384.json
VERBOSE: [PSRule][R][0][PSRule.Rules.GitHub\GitHub.Repo.CodeOwners] :: github-22a87384.json
VERBOSE: [PSRule][R][0][PSRule.Rules.GitHub\GitHub.Repo.License] :: github-22a87384.json
VERBOSE: [PSRule][R][0][PSRule.Rules.GitHub\GitHub.Repo.Description] :: github-22a87384.json
VERBOSE: [PSRule][R][0][PSRule.Rules.GitHub\GitHub.Repo.IssueTempate] :: github-22a87384.json
VERBOSE: [PSRule][R][0][PSRule.Rules.GitHub\GitHub.Repo.PRTemplate] :: github-22a87384.json
WARN Target object 'github-22a87384.json' has not been processed because no matching rules were found.
Module in use and version:
Captured output from $PSVersionTable
:
Name Value
---- -----
PSVersion 7.2.5
PSEdition Core
GitCommitId 7.2.5
OS Microsoft Windows 10.0.22000
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Additional context
Add any other context about the problem here.
github-22a87384.json.txt
Add metadata and configure for publishing via NuGet in addition to PowerShell gallery.
Update PSRule module dependency to v1.1.0.
PSRule conventions can be used to export repository data automatically instead of having to call Export-GitHubRuleData
directly.
From PSRule v1.2.0 onward apiVersion
should be set on YAML resources such as Baseline
and ModuleConfig
. When not set a warning is generated.
Each resource needs to be updated to the apiVersion
property.
Add code signing and SBOM metadata for module.
Avoid using branch names such as master
.
Currently PSRule tries to export all data related to a repository however some may not be accessible. We should provide a configuration option to allow this to be configured.
Update and publish documentation on usage.
To perform analysis repository configuration data needs to be exported from GitHub APIs.
Add support for exporting the following repository data.
Move this repository under the Microsoft org.
When repository data can not be exported due to authorization a warning or error should be reported but analysis should continue based on any data exported.
Include milestones for validation in repository object graph.
Description of the issue
Thanks for the solution earlier, that works great. I have the same thing with the GitHub actions. It is like its scanning the repository files instead of the GitHub export
To Reproduce
Steps to reproduce the issue:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# Analyze Azure resources using PSRule for Azure
- name: Analyze Azure template files
uses: microsoft/[email protected]
with:
modules: 'PSRule.Rules.GitHub'
Expected behaviour
A clear and concise description of what you expected to happen.
Error output
Capture any error messages and or verbose messages with -Verbose
.
---
____ _____ ____ __
/ __ \/ ___// __ \__ __/ /__
/ /_/ /\__ \/ /_/ / / / / / _ \
/ ____/___/ / _, _/ /_/ / / __/
/_/ /____/_/ |_|\__,_/_/\___/
Using PSRule v2.2.0+f3d21795d42759a906633118a58cdc088281b9dc
Using PSRule.Rules.GitHub v0.2.0
----------------------------
Explore documentation: https://aka.ms/ps-rule
Contribute and find source: https://github.com/microsoft/PSRule
Report issues: https://github.com/microsoft/PSRule/issues
PSRule.Rules.GitHub: https://github.com/Microsoft/PSRule.Rules.GitHub
----------------------------
From repository: https://github.com/dylanprins93/test
on : refs/pull/4/merge
at : a2d[41](https://github.com/dylanprins93/test/runs/7376898849?check_suite_focus=true#step:3:43)897310b1de1fcf17d[49](https://github.com/dylanprins93/test/runs/7376898849?check_suite_focus=true#step:3:51)021ebec63195cd6b
Warning: Using invariant culture may cause rule infomation to be displayed incorrectly. Consider using -Culture or set the Output.Culture option.
Warning: Target object 'test.md' has not been processed because no matching rules were found.
Warning: Target object 'refs/pull/4/merge' has not been processed because no matching rules were found.
Warning: Target object '.github/workflows/psrule.yml' has not been processed because no matching rules were found.
Rules processed: 0, failed: 0, errored: 0
Run dylanprins93/test/268[51](https://github.com/dylanprins93/test/runs/7376898849?check_suite_focus=true#step:3:53)20764 completed in 00:00:00.17682[61](https://github.com/dylanprins93/test/runs/7376898849?check_suite_focus=true#step:3:63)
---
Module in use and version:
Captured output from $PSVersionTable
:
Additional context
Add any other context about the problem here.
Bump PSRule dependency to v1.7.0.
Use the GITHUB_REPOSITORY
environment variable when -Repository
is not specified.
Update PSRule module dependency to v1.2.0.
Update PSRule module dependency to v1.3.0.
Public repositories should use recommended community files.
Add example for using with GitHub Actions.
Is your feature request related to a problem? Please describe.
To support Github Enterprise Server
Describe the solution you'd like
Octokit.GithubClient supports both Github and Github Enterprise Server. In theory we should be able to expand with a few more parameters.
The repository default branch should be protected.
Read and export issue labels and add to the repository object so that rules that query labels can be built.
Add help for Export-GitHubRuleData
cmdlet.
Description of the issue
Data exported for repository community profile is always null.
Expected behaviour
Community profile should be populated when valid.
Module in use and version:
Captured output from $PSVersionTable
:
Name Value
---- -----
PSVersion 7.1.3
PSEdition Core
GitCommitId 7.1.3
OS Microsoft Windows 10.0.19042
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.