Skip to content

Commit f7d864b

Browse files
feat: order YAML output fields for Profile, RuleType, DataSource
1 parent 5e95a7e commit f7d864b

9 files changed

Lines changed: 710 additions & 348 deletions

File tree

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
profileStatus:
2-
lastUpdated: "2024-01-01T00:00:00Z"
3-
profileId: 11111111-1111-1111-1111-111111111111
4-
profileName: mock-profile
5-
profileStatus: success
6-
ruleEvaluationStatus:
7-
- details: Mock rule evaluation succeeded.
8-
entity: repository
9-
entityInfo:
10-
entity_type: repository
11-
name: acme-corp/mock-repo
12-
provider: github-app-mock-provider
13-
repo_name: mock-repo
14-
repo_owner: acme-corp
15-
repository_id: 22222222-2222-2222-2222-222222222222
16-
lastUpdated: "2024-01-01T00:00:00Z"
17-
profileId: 11111111-1111-1111-1111-111111111111
18-
ruleDisplayName: Enable secret scanning to detect hardcoded secrets
19-
ruleId: mock-rule-123
20-
ruleName: secret_scanning
21-
ruleTypeName: secret_scanning
22-
status: success
23-
- details: Mock rule evaluation failed.
24-
entity: repository
25-
entityInfo:
26-
entity_type: repository
27-
name: acme-corp/mock-repo
28-
provider: github-app-mock-provider
29-
repo_name: mock-repo
30-
repo_owner: acme-corp
31-
repository_id: 22222222-2222-2222-2222-222222222222
322
lastUpdated: "2024-01-01T00:00:00Z"
333
profileId: 11111111-1111-1111-1111-111111111111
34-
ruleDisplayName: Enable CodeQL for vulnerability scanning
35-
ruleId: mock-rule-456
36-
ruleName: codeql_enabled
37-
ruleTypeName: codeql_enabled
38-
status: failure
4+
profileName: mock-profile
5+
profileStatus: success
6+
ruleEvaluationStatus:
7+
- details: Mock rule evaluation succeeded.
8+
entity: repository
9+
entityInfo:
10+
entity_type: repository
11+
name: acme-corp/mock-repo
12+
provider: github-app-mock-provider
13+
repo_name: mock-repo
14+
repo_owner: acme-corp
15+
repository_id: 22222222-2222-2222-2222-222222222222
16+
lastUpdated: "2024-01-01T00:00:00Z"
17+
profileId: 11111111-1111-1111-1111-111111111111
18+
ruleDisplayName: Enable secret scanning to detect hardcoded secrets
19+
ruleId: mock-rule-123
20+
ruleName: secret_scanning
21+
ruleTypeName: secret_scanning
22+
status: success
23+
- details: Mock rule evaluation failed.
24+
entity: repository
25+
entityInfo:
26+
entity_type: repository
27+
name: acme-corp/mock-repo
28+
provider: github-app-mock-provider
29+
repo_name: mock-repo
30+
repo_owner: acme-corp
31+
repository_id: 22222222-2222-2222-2222-222222222222
32+
lastUpdated: "2024-01-01T00:00:00Z"
33+
profileId: 11111111-1111-1111-1111-111111111111
34+
ruleDisplayName: Enable CodeQL for vulnerability scanning
35+
ruleId: mock-rule-456
36+
ruleName: codeql_enabled
37+
ruleTypeName: codeql_enabled
38+
status: failure
3939

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
profileStatus:
2-
lastUpdated: "2024-01-01T00:00:00Z"
3-
profileId: 11111111-1111-1111-1111-111111111111
4-
profileName: mock-profile
5-
profileStatus: success
6-
ruleEvaluationStatus:
7-
- details: Mock rule evaluation succeeded.
8-
entity: repository
9-
entityInfo:
10-
entity_type: repository
11-
name: acme-corp/mock-repo
12-
provider: github-app-mock-provider
13-
repo_name: mock-repo
14-
repo_owner: acme-corp
15-
repository_id: 22222222-2222-2222-2222-222222222222
16-
lastUpdated: "2024-01-01T00:00:00Z"
17-
profileId: 11111111-1111-1111-1111-111111111111
18-
ruleDisplayName: Enable secret scanning to detect hardcoded secrets
19-
ruleId: mock-rule-123
20-
ruleName: secret_scanning
21-
ruleTypeName: secret_scanning
22-
status: success
23-
- details: Mock rule evaluation failed.
24-
entity: repository
25-
entityInfo:
26-
entity_type: repository
27-
name: acme-corp/mock-repo
28-
provider: github-app-mock-provider
29-
repo_name: mock-repo
30-
repo_owner: acme-corp
31-
repository_id: 22222222-2222-2222-2222-222222222222
322
lastUpdated: "2024-01-01T00:00:00Z"
333
profileId: 11111111-1111-1111-1111-111111111111
34-
ruleDisplayName: Enable CodeQL for vulnerability scanning
35-
ruleId: mock-rule-456
36-
ruleName: codeql_enabled
37-
ruleTypeName: codeql_enabled
38-
status: failure
4+
profileName: mock-profile
5+
profileStatus: success
6+
ruleEvaluationStatus:
7+
- details: Mock rule evaluation succeeded.
8+
entity: repository
9+
entityInfo:
10+
entity_type: repository
11+
name: acme-corp/mock-repo
12+
provider: github-app-mock-provider
13+
repo_name: mock-repo
14+
repo_owner: acme-corp
15+
repository_id: 22222222-2222-2222-2222-222222222222
16+
lastUpdated: "2024-01-01T00:00:00Z"
17+
profileId: 11111111-1111-1111-1111-111111111111
18+
ruleDisplayName: Enable secret scanning to detect hardcoded secrets
19+
ruleId: mock-rule-123
20+
ruleName: secret_scanning
21+
ruleTypeName: secret_scanning
22+
status: success
23+
- details: Mock rule evaluation failed.
24+
entity: repository
25+
entityInfo:
26+
entity_type: repository
27+
name: acme-corp/mock-repo
28+
provider: github-app-mock-provider
29+
repo_name: mock-repo
30+
repo_owner: acme-corp
31+
repository_id: 22222222-2222-2222-2222-222222222222
32+
lastUpdated: "2024-01-01T00:00:00Z"
33+
profileId: 11111111-1111-1111-1111-111111111111
34+
ruleDisplayName: Enable CodeQL for vulnerability scanning
35+
ruleId: mock-rule-456
36+
ruleName: codeql_enabled
37+
ruleTypeName: codeql_enabled
38+
status: failure
3939

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
---
2-
alert: "on"
3-
artifact:
4-
- def:
5-
is_signed: true
6-
is_verified: true
7-
name: Mock ensure artifacts are signed
8-
params:
9-
name: mock-artifact
10-
tags:
11-
- latest
12-
type: artifact_signature
2+
name: mock-artifact-profile
133
context:
14-
project: 00000000-0000-0000-0000-000000000000
15-
displayName: Mock Artifact Signature Profile
4+
project: 00000000-0000-0000-0000-000000000000
165
id: 11111111-1111-1111-1111-111111111111
17-
name: mock-artifact-profile
6+
displayName: Mock Artifact Signature Profile
187
remediate: "off"
8+
alert: "on"
9+
artifact:
10+
- def:
11+
is_signed: true
12+
is_verified: true
13+
name: Mock ensure artifacts are signed
14+
params:
15+
name: mock-artifact
16+
tags:
17+
- latest
18+
type: artifact_signature
1919

2020
---
21-
alert: "off"
21+
name: mock-branch-protection
2222
context:
23-
project: 00000000-0000-0000-0000-000000000000
24-
displayName: Mock Branch Protection Profile
23+
project: 00000000-0000-0000-0000-000000000000
2524
id: 22222222-2222-2222-2222-222222222222
26-
name: mock-branch-protection
25+
displayName: Mock Branch Protection Profile
2726
remediate: "on"
27+
alert: "off"
2828
repository:
29-
- def: {}
30-
name: Mock enable branch protection
31-
params:
32-
branch: main
33-
type: branch_protection_enabled
34-
- def:
35-
required_approving_review_count: 2
36-
name: Mock require 2 reviews
37-
params:
38-
branch: main
39-
type: branch_protection_require_pull_request_approving_review_count
29+
- def: {}
30+
name: Mock enable branch protection
31+
params:
32+
branch: main
33+
type: branch_protection_enabled
34+
- def:
35+
required_approving_review_count: 2
36+
name: Mock require 2 reviews
37+
params:
38+
branch: main
39+
type: branch_protection_require_pull_request_approving_review_count
4040

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,72 @@
1+
name: secret_push_protection
12
context:
2-
project: 00000000-0000-0000-0000-000000000000
3-
provider: ""
4-
def:
5-
alert:
6-
securityAdvisory: {}
7-
type: security_advisory
8-
eval:
9-
rego:
10-
def: |
11-
package minder
3+
project: 00000000-0000-0000-0000-000000000000
4+
provider: ""
5+
id: 00000000-0000-0000-0000-000000000001
6+
displayName: Enable secret push protection to avoid pushing hardcoded secrets
7+
shortFailureMessage: Secret push protection is not enabled
8+
description: |
9+
Verifies that secret push protection is enabled for a given repository.
10+
Note that this will will not work as expected for private repositories
11+
unless you have GitHub Advanced Security enabled. If you still want to use
12+
this rule because you have a mixture of private and public repositories,
13+
enable the `skip_private_repos` flag.
14+
guidance: |
15+
Ensure that secret scanning push protection is enabled for the
16+
repository.
1217

13-
import future.keywords.if
18+
You can use secret scanning to prevent supported secrets from being
19+
pushed into your repository by enabling secret scanning push
20+
protection.
1421

15-
default allow := false
16-
default skip := false
17-
default message := "Secret push protection is disabled"
22+
For more information, see [GitHub's
23+
documentation](https://docs.github.com/en/code-security/secret-scanning/push-protection-for-repositories-and-organizations#enabling-secret-scanning-as-a-push-protection-for-a-repository).
24+
severity:
25+
value: VALUE_HIGH
26+
releasePhase: RULE_TYPE_RELEASE_PHASE_BETA
27+
def:
28+
alert:
29+
securityAdvisory: {}
30+
type: security_advisory
31+
eval:
32+
rego:
33+
def: |
34+
package minder
1835

19-
allow if {
20-
input.ingested.security_and_analysis.secret_scanning_push_protection.status == "enabled"
21-
}
36+
import future.keywords.if
2237

23-
skip if {
24-
input.profile.skip_private_repos == true
25-
input.ingested.private == true
26-
}
27-
type: deny-by-default
28-
type: rego
29-
inEntity: repository
30-
ingest:
31-
rest:
32-
endpoint: /repos/{{.Entity.Owner}}/{{.Entity.Name}}
33-
parse: json
34-
type: rest
35-
remediate:
36-
rest:
37-
body: |
38-
{ "security_and_analysis": {"secret_scanning_push_protection": { "status": "enabled" } } }
39-
endpoint: /repos/{{.Entity.Owner}}/{{.Entity.Name}}
40-
method: PATCH
41-
type: rest
42-
ruleSchema:
43-
properties:
44-
skip_private_repos:
45-
default: true
46-
description: |
47-
If true, this rule will be marked as skipped for private repositories
48-
type: boolean
49-
description: |
50-
Verifies that secret push protection is enabled for a given repository.
51-
Note that this will will not work as expected for private repositories
52-
unless you have GitHub Advanced Security enabled. If you still want to use
53-
this rule because you have a mixture of private and public repositories,
54-
enable the `skip_private_repos` flag.
55-
displayName: Enable secret push protection to avoid pushing hardcoded secrets
56-
guidance: |
57-
Ensure that secret scanning push protection is enabled for the
58-
repository.
38+
default allow := false
39+
default skip := false
40+
default message := "Secret push protection is disabled"
5941

60-
You can use secret scanning to prevent supported secrets from being
61-
pushed into your repository by enabling secret scanning push
62-
protection.
42+
allow if {
43+
input.ingested.security_and_analysis.secret_scanning_push_protection.status == "enabled"
44+
}
6345

64-
For more information, see [GitHub's
65-
documentation](https://docs.github.com/en/code-security/secret-scanning/push-protection-for-repositories-and-organizations#enabling-secret-scanning-as-a-push-protection-for-a-repository).
66-
id: 00000000-0000-0000-0000-000000000001
67-
name: secret_push_protection
68-
releasePhase: RULE_TYPE_RELEASE_PHASE_BETA
69-
severity:
70-
value: VALUE_HIGH
71-
shortFailureMessage: Secret push protection is not enabled
46+
skip if {
47+
input.profile.skip_private_repos == true
48+
input.ingested.private == true
49+
}
50+
type: deny-by-default
51+
type: rego
52+
inEntity: repository
53+
ingest:
54+
rest:
55+
endpoint: /repos/{{.Entity.Owner}}/{{.Entity.Name}}
56+
parse: json
57+
type: rest
58+
remediate:
59+
rest:
60+
body: |
61+
{ "security_and_analysis": {"secret_scanning_push_protection": { "status": "enabled" } } }
62+
endpoint: /repos/{{.Entity.Owner}}/{{.Entity.Name}}
63+
method: PATCH
64+
type: rest
65+
ruleSchema:
66+
properties:
67+
skip_private_repos:
68+
default: true
69+
description: |
70+
If true, this rule will be marked as skipped for private repositories
71+
type: boolean
7272

0 commit comments

Comments
 (0)