Skip to content

Commit 98d1363

Browse files
teodor-yanevblkt
andauthored
Add osps-qa-02 rule (#275)
* Add OSPS Baseline Level 1 rules. This change adds all currently implemented rule types for OSPS Baseline Level 1. Some rules were copy-pasted from rules like e.g. `branch_protection_allow_deletions` in order to (a) be able to change them independently and (b) change the name to something descriptive in the scope of Security Baseline. We generally do not foster this, but in this case we deemed simplicity was preferable to avoiding duplication. Along the rules themselves, tests were added to new, existing ones, and their copies. Fixes stacklok/minder-stories#198 * add: osps-qa-02 rule * update: use rest --------- Co-authored-by: Michelangelo Mori <[email protected]>
1 parent 90cf5e1 commit 98d1363

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

security-baseline/profiles/security-baseline-level-1.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,7 @@ repository:
3535
- name: osps-qa-01
3636
type: osps-qa-01
3737
def: {}
38+
# OSPS-QA-02: Maintain publicly readable change history
39+
- name: osps-qa-02
40+
type: osps-qa-02
41+
def: {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
version: v1
2+
release_phase: alpha
3+
type: rule-type
4+
name: osps-qa-02
5+
display_name: Maintain publicly readable change history
6+
short_failure_message: Repository must be public and prevent force pushes
7+
severity:
8+
value: info
9+
context:
10+
provider: github
11+
description: |
12+
Ensure that the project's change history is publicly readable and
13+
cannot be overwritten, maintaining transparency and trust in the
14+
development process. This helps maintain a complete and accurate history of all
15+
changes made to the codebase.
16+
guidance: |
17+
1. Make sure the repository is public via the
18+
[Repository Settings](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/setting-repository-visibility) page.
19+
2. Ensure force pushes are disabled in branch protection rules via the
20+
[Branch protection settings](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/managing-a-branch-protection-rule).
21+
def:
22+
in_entity: repository
23+
rule_schema: {}
24+
ingest:
25+
type: rest
26+
rest:
27+
endpoint: '/repos/{{.Entity.Owner}}/{{.Entity.Name}}/branches/{{.Entity.DefaultBranch}}/protection'
28+
parse: json
29+
fallback:
30+
- http_code: 404
31+
body: |
32+
{"http_status": 404, "message": "Not Protected"}
33+
eval:
34+
type: rego
35+
rego:
36+
type: deny-by-default
37+
def: |
38+
package minder
39+
40+
import rego.v1
41+
42+
default allow := false
43+
44+
allow if {
45+
not input.properties["is_private"]
46+
not input.ingested.allow_force_pushes.enabled
47+
}

0 commit comments

Comments
 (0)