Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rule to require pre-commit to be added to github actions #246

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion profiles/github/dependabot_ghactions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ context:
alert: "off"
remediate: "off"
repository:
- type: dependabot_configured
- type: pre_commit_github_action
def:
package_ecosystem: github-actions
schedule_interval: daily
13 changes: 13 additions & 0 deletions rule-types/github/pre_commit_github_action.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tests:
- name: "Should have pre-commit enabled"
def: {}
params: {}
expect: "pass"
git:
repo_base: good
- name: "Should not have pre-commit enabled"
def: {}
params: {}
expect: "fail"
git:
repo_base: bad
JAORMX marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: NodeJS with Gulp
'on':
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: package.json
- name: Build
run: |
npm install
gulp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: NodeJS with Gulp
'on':
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: package.json
- name: Build
run: |
npm install
gulp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: NodeJS with Gulp

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-versiodn: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v4
- uses: pre-commit/[email protected]

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version-file: "package.json"
node-versiosdn: ${{ matrix.node-version }}

- name: Build
run: |
npm install
gulp
41 changes: 41 additions & 0 deletions rule-types/github/pre_commit_github_action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
version: v1
release_phase: alpha
type: rule-type
name: pre_commit_github_action
display_name: Require running `pre-commit` using GitHub Actions
short_failure_message: "`https://github.com/pre-commit/action` action is not configured"
severity:
value: medium
context: {}
description: |
Verifies that `pre-commit` is configured via a GitHub action for the repository.
guidance: |
Run your `pre-commit` checks in GitHub Actions as well.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we point folks to documentation on how to do this?

def:
in_entity: repository
rule_schema:
type: object
properties: {}
ingest:
type: git
git: {}
eval:
type: rego
rego:
type: deny-by-default
def: |
package minder

import rego.v1
actions := github_workflow.ls_actions("./.github/workflows")
default message := "pre-commit GitHub action is not configured"
default allow := false
allow if {
print(actions)
"pre-commit/action" in actions
}
# Defines the configuration for alerting on the rule
alert:
type: security_advisory
security_advisory: {}
Loading