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 osps-qa-02 rule #275

Merged
merged 4 commits into from
Jan 21, 2025
Merged
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
4 changes: 4 additions & 0 deletions security-baseline/profiles/security-baseline-level-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ repository:
- name: osps-qa-01
type: osps-qa-01
def: {}
# OSPS-QA-02: Maintain publicly readable change history
- name: osps-qa-02
type: osps-qa-02
def: {}
47 changes: 47 additions & 0 deletions security-baseline/rule-types/github/osps-qa-02.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: v1
release_phase: alpha
type: rule-type
name: osps-qa-02
display_name: Maintain publicly readable change history
short_failure_message: Repository must be public and prevent force pushes
severity:
value: info
context:
provider: github
description: |
Ensure that the project's change history is publicly readable and
cannot be overwritten, maintaining transparency and trust in the
development process. This helps maintain a complete and accurate history of all
changes made to the codebase.
guidance: |
1. Make sure the repository is public via the
[Repository Settings](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/setting-repository-visibility) page.
2. Ensure force pushes are disabled in branch protection rules via the
[Branch protection settings](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/managing-a-branch-protection-rule).
def:
in_entity: repository
rule_schema: {}
ingest:
type: rest
rest:
endpoint: '/repos/{{.Entity.Owner}}/{{.Entity.Name}}/branches/{{.Entity.DefaultBranch}}/protection'
parse: json
fallback:
- http_code: 404
body: |
{"http_status": 404, "message": "Not Protected"}
eval:
type: rego
rego:
type: deny-by-default
def: |
package minder

import rego.v1

default allow := false

allow if {
not input.properties["is_private"]
not input.ingested.allow_force_pushes.enabled
}
Loading