-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
25 changed files
with
698 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
rule-types/github/branch_protection_allow_deletions.test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
tests: | ||
- name: "force push not allowed" | ||
def: {} | ||
params: {} | ||
entity: | ||
type: repository | ||
entity: | ||
owner: "mindersec" | ||
name: "minder" | ||
expect: "pass" | ||
http: | ||
status: 200 | ||
body: '{"allow_deletions": {"enabled": false}}' | ||
- name: "force push allowed" | ||
def: {} | ||
params: {} | ||
entity: | ||
type: repository | ||
entity: | ||
owner: "mindersec" | ||
name: "minder" | ||
expect: "fail" | ||
http: | ||
status: 200 | ||
body: '{"allow_deletions": {"enabled": true}}' | ||
- name: "not found" | ||
def: {} | ||
params: {} | ||
entity: | ||
type: repository | ||
entity: | ||
owner: "mindersec" | ||
name: "minder" | ||
expect: "fail" | ||
http: | ||
status: 404 | ||
body: '{"woot": "woot"}' | ||
- name: "internal error" | ||
def: {} | ||
params: {} | ||
entity: | ||
type: repository | ||
entity: | ||
owner: "mindersec" | ||
name: "minder" | ||
expect: "fail" | ||
http: | ||
status: 502 | ||
body: '{"woot": "woot"}' |
49 changes: 49 additions & 0 deletions
49
rule-types/github/branch_protection_allow_force_pushes.test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
tests: | ||
- name: "force push not allowed" | ||
def: {} | ||
params: {} | ||
entity: | ||
type: repository | ||
entity: | ||
owner: "mindersec" | ||
name: "minder" | ||
expect: "pass" | ||
http: | ||
status: 200 | ||
body: '{"allow_force_pushes": {"enabled": false}}' | ||
- name: "force push allowed" | ||
def: {} | ||
params: {} | ||
entity: | ||
type: repository | ||
entity: | ||
owner: "mindersec" | ||
name: "minder" | ||
expect: "fail" | ||
http: | ||
status: 200 | ||
body: '{"allow_force_pushes": {"enabled": true}}' | ||
- name: "not found" | ||
def: {} | ||
params: {} | ||
entity: | ||
type: repository | ||
entity: | ||
owner: "mindersec" | ||
name: "minder" | ||
expect: "fail" | ||
http: | ||
status: 404 | ||
body: '{"woot": "woot"}' | ||
- name: "internal error" | ||
def: {} | ||
params: {} | ||
entity: | ||
type: repository | ||
entity: | ||
owner: "mindersec" | ||
name: "minder" | ||
expect: "fail" | ||
http: | ||
status: 502 | ||
body: '{"woot": "woot"}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
data-sources/ghapi.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
tests: | ||
- name: "force push not allowed" | ||
def: {} | ||
params: {} | ||
entity: | ||
type: repository | ||
entity: | ||
owner: "mindersec" | ||
name: "minder" | ||
expect: "pass" | ||
http: | ||
status: 200 | ||
body: '{"allow_force_pushes": {"enabled": false}}' | ||
- name: "force push allowed" | ||
def: {} | ||
params: {} | ||
entity: | ||
type: repository | ||
entity: | ||
owner: "mindersec" | ||
name: "minder" | ||
expect: "fail" | ||
http: | ||
status: 200 | ||
body: '{"allow_force_pushes": {"enabled": true}}' | ||
- name: "not found" | ||
def: {} | ||
params: {} | ||
entity: | ||
type: repository | ||
entity: | ||
owner: "mindersec" | ||
name: "minder" | ||
expect: "fail" | ||
http: | ||
status: 404 | ||
body: '{"woot": "woot"}' | ||
- name: "internal error" | ||
def: {} | ||
params: {} | ||
entity: | ||
type: repository | ||
entity: | ||
owner: "mindersec" | ||
name: "minder" | ||
expect: "fail" | ||
http: | ||
status: 502 | ||
body: '{"woot": "woot"}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
version: v1 | ||
release_phase: alpha | ||
type: rule-type | ||
name: osps-ac-04 | ||
display_name: Prevent overwriting git history | ||
short_failure_message: Force pushes are allowed | ||
severity: | ||
value: info | ||
context: | ||
provider: github | ||
description: Disallow force pushes to the branch | ||
guidance: | | ||
Ensure that the appropriate setting is disabled for the branch | ||
protection rule. | ||
This setting prevents users with push access to force push to the | ||
branch. | ||
For more information, see [GitHub's | ||
documentation](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: jq | ||
jq: | ||
- ingested: | ||
def: ".allow_force_pushes.enabled" | ||
constant: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
tests: | ||
- name: "force push not allowed" | ||
def: {} | ||
params: {} | ||
entity: | ||
type: repository | ||
entity: | ||
owner: "mindersec" | ||
name: "minder" | ||
expect: "pass" | ||
http: | ||
status: 200 | ||
body: '{"allow_deletions": {"enabled": false}}' | ||
- name: "force push allowed" | ||
def: {} | ||
params: {} | ||
entity: | ||
type: repository | ||
entity: | ||
owner: "mindersec" | ||
name: "minder" | ||
expect: "fail" | ||
http: | ||
status: 200 | ||
body: '{"allow_deletions": {"enabled": true}}' | ||
- name: "not found" | ||
def: {} | ||
params: {} | ||
entity: | ||
type: repository | ||
entity: | ||
owner: "mindersec" | ||
name: "minder" | ||
expect: "fail" | ||
http: | ||
status: 404 | ||
body: '{"woot": "woot"}' | ||
- name: "internal error" | ||
def: {} | ||
params: {} | ||
entity: | ||
type: repository | ||
entity: | ||
owner: "mindersec" | ||
name: "minder" | ||
expect: "fail" | ||
http: | ||
status: 502 | ||
body: '{"woot": "woot"}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
version: v1 | ||
release_phase: alpha | ||
type: rule-type | ||
name: osps-ac-04 | ||
display_name: Prevent permanent branch deletion | ||
short_failure_message: Branch protection allows deletions | ||
severity: | ||
value: info | ||
context: | ||
provider: github | ||
description: Prevents the branch from being deleted | ||
guidance: | | ||
Ensure that the "Allow deletions" setting is disabled for the branch | ||
protection rule. | ||
Prevent users from deleting matching branches. | ||
For more information, see [GitHub's | ||
documentation](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: jq | ||
jq: | ||
- ingested: | ||
def: ".allow_deletions.enabled" | ||
constant: false |
Oops, something went wrong.