Skip to content
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
22 changes: 22 additions & 0 deletions github/respository_rules_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,28 @@ func flattenRules(rules []*github.RepositoryRule, org bool) []any {
rule["min_entries_to_merge_wait_minutes"] = params.MinEntriesToMergeWaitMinutes
rulesMap[v.Type] = []map[string]any{rule}

case "required_code_scanning":
var params github.RequiredCodeScanningRuleParameters

err := json.Unmarshal(*v.Parameters, &params)
if err != nil {
log.Printf("[INFO] Unexpected error unmarshalling rule %s with parameters: %v",
v.Type, v.Parameters)
}

requiredCodeScanningToolSlice := make([]map[string]any, 0)
for _, tool := range params.RequiredCodeScanningTools {
requiredCodeScanningToolSlice = append(requiredCodeScanningToolSlice, map[string]any{
"alerts_threshold": tool.AlertsThreshold,
"security_alerts_threshold": tool.SecurityAlertsThreshold,
"tool": tool.Tool,
})
}

rule := make(map[string]any)
rule["required_code_scanning_tool"] = requiredCodeScanningToolSlice
rulesMap[v.Type] = []map[string]any{rule}

case "file_path_restriction":
var params github.RuleFileParameters
err := json.Unmarshal(*v.Parameters, &params)
Expand Down
8 changes: 8 additions & 0 deletions website/docs/r/organization_ruleset.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ resource "github_organization_ruleset" "example" {
ref = "main"
}
}

required_code_scanning {
required_code_scanning_tool {
alerts_threshold = "errors"
security_alerts_threshold = "high_or_higher"
tool = "CodeQL"
}
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion website/docs/r/repository_ruleset.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ resource "github_repository_ruleset" "example" {
required_deployment_environments = ["test"]
}


required_code_scanning {
required_code_scanning_tool {
alerts_threshold = "errors"
security_alerts_threshold = "high_or_higher"
tool = "CodeQL"
}
}
}
}

Expand Down