-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add more policies for better compliance posture for SOC2 #9
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
Open
gusfcarvalho
wants to merge
12
commits into
main
Choose a base branch
from
gc-feat-more-policies
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
998c5af
feat: add more policies for better compliance posture for SOC2
gusfcarvalho e9553d8
fix: copilot issues
gusfcarvalho 02a0a27
fix: copilot issues
gusfcarvalho 77ff171
fix: copilot issues
gusfcarvalho 516afcf
fix: copilot issues
gusfcarvalho d0f0558
fix: copilot issues
gusfcarvalho 24e7f82
fix: copilot issues
gusfcarvalho e672510
fix: copilot issues
gusfcarvalho 09e2bd8
fix: copilot issues
gusfcarvalho 709fbb1
fix: forgot to add files after rename
gusfcarvalho 50cff28
fix: copilot issues
gusfcarvalho 9906b7d
fix: copilot issues
gusfcarvalho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,57 @@ | ||
| package compliance_framework.default_repo_permission | ||
|
|
||
| risk_templates := [ | ||
| { | ||
| "name": "Default repository permission is too permissive", | ||
| "title": "Overly Permissive Default Repository Access Grants Excessive Privileges to All Members", | ||
| "statement": "The default repository permission setting determines the base access level automatically granted to every organization member on all repositories. Setting this to 'write' or 'admin' means that all organization members, including newly onboarded employees and contractors, receive write or administrative access to every repository by default. This violates the principle of least privilege and can lead to unauthorized modifications, accidental data loss, or privilege escalation if any member account is compromised. The default should be 'read' or 'none', with elevated access granted explicitly via team membership.", | ||
| "likelihood_hint": "moderate", | ||
| "impact_hint": "high", | ||
| "violation_ids": ["default_permission_too_permissive"], | ||
| "threat_refs": [ | ||
| { | ||
| "system": "https://cwe.mitre.org", | ||
| "external_id": "CWE-269", | ||
| "title": "Improper Privilege Management", | ||
| "url": "https://cwe.mitre.org/data/definitions/269.html" | ||
| }, | ||
| { | ||
| "system": "https://cwe.mitre.org", | ||
| "external_id": "CWE-284", | ||
| "title": "Improper Access Control", | ||
| "url": "https://cwe.mitre.org/data/definitions/284.html" | ||
| }, | ||
| { | ||
| "system": "https://cwe.mitre.org", | ||
| "external_id": "CWE-732", | ||
| "title": "Incorrect Permission Assignment for Critical Resource", | ||
| "url": "https://cwe.mitre.org/data/definitions/732.html" | ||
| } | ||
| ], | ||
| "remediation": { | ||
| "title": "Set the default repository permission to 'read' or 'none'", | ||
| "description": "Configure the organization's default repository permission to 'read' or 'none'. Grant write and admin access explicitly via team membership to specific repositories, following the principle of least privilege.", | ||
| "tasks": [ | ||
| { "title": "Navigate to Organization Settings > Member privileges > Base permissions" }, | ||
| { "title": "Change the base permission to 'Read' or 'No permission'" }, | ||
| { "title": "Review all repositories to ensure teams have explicit access grants where write access is required" }, | ||
| { "title": "Communicate the change to all members and update onboarding documentation" }, | ||
| { "title": "Audit existing repositories for any direct-user write grants that should be team-based" } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
|
|
||
| _settings := object.get(input, "settings", {}) | ||
|
|
||
| _default_repository_permission := object.get(_settings, "default_repository_permission", "") | ||
|
|
||
| _allowed_permissions := {"read", "none"} | ||
|
|
||
| violation[{"id": "default_permission_too_permissive"}] if { | ||
| not _allowed_permissions[_default_repository_permission] | ||
| } | ||
|
|
||
| title := "Default repository permission is set to 'read' or 'none'" | ||
| description := "The organization's default repository permission must not grant write or admin access to all members by default. Elevated access should be granted explicitly via team membership to follow the principle of least privilege." | ||
| remarks := "More information: https://docs.github.com/en/organizations/managing-user-access-to-your-organizations-repositories/managing-repository-roles/setting-base-permissions-for-an-organization" |
This file contains hidden or 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 @@ | ||
| package compliance_framework.default_repo_permission | ||
|
|
||
| test_default_permission_read if { | ||
| count(violation) == 0 with input as { | ||
| "settings": { | ||
| "default_repository_permission": "read" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| test_default_permission_none if { | ||
| count(violation) == 0 with input as { | ||
| "settings": { | ||
| "default_repository_permission": "none" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| test_default_permission_write if { | ||
| count(violation) > 0 with input as { | ||
| "settings": { | ||
| "default_repository_permission": "write" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| test_default_permission_admin if { | ||
| count(violation) > 0 with input as { | ||
| "settings": { | ||
| "default_repository_permission": "admin" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| test_default_permission_missing if { | ||
| count(violation) > 0 with input as {} | ||
| } |
This file contains hidden or 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,53 @@ | ||
| package compliance_framework.ip_allowlist_enabled | ||
|
|
||
| risk_templates := [ | ||
| { | ||
| "name": "No IP allow-list configured for the organization", | ||
| "title": "Absence of IP Allow-List Exposes GitHub Resources to Access from Untrusted Networks", | ||
| "statement": "Without an IP allow-list, the GitHub organization's resources (repositories, API, settings) are accessible from any IP address on the internet, subject only to authentication. This means that even valid credentials used from untrusted networks (e.g., compromised endpoints, attacker infrastructure) can interact with the organization's assets. Configuring an IP allow-list restricts access to approved network ranges, adding a network-layer control that limits the blast radius of credential compromise.", | ||
| "likelihood_hint": "moderate", | ||
| "impact_hint": "high", | ||
| "violation_ids": ["ip_allowlist_not_configured"], | ||
| "threat_refs": [ | ||
| { | ||
| "system": "https://cwe.mitre.org", | ||
| "external_id": "CWE-284", | ||
| "title": "Improper Access Control", | ||
| "url": "https://cwe.mitre.org/data/definitions/284.html" | ||
| }, | ||
| { | ||
| "system": "https://cwe.mitre.org", | ||
| "external_id": "CWE-923", | ||
| "title": "Improper Restriction of Communication Channel to Intended Endpoints", | ||
| "url": "https://cwe.mitre.org/data/definitions/923.html" | ||
| } | ||
| ], | ||
| "remediation": { | ||
| "title": "Configure an IP allow-list for the GitHub organization", | ||
| "description": "Enable the IP allow-list feature for the organization and add the approved IP ranges from which members are permitted to access GitHub. This restricts access to known, trusted networks and reduces the risk of credential-based attacks from untrusted locations.", | ||
| "tasks": [ | ||
| { "title": "Navigate to Organization Settings > Security > IP allow list" }, | ||
| { "title": "Enable 'IP allow list'" }, | ||
| { "title": "Add approved IP ranges for corporate offices, VPNs, and CI/CD infrastructure" }, | ||
| { "title": "Test that members can still access GitHub from approved networks before fully enforcing" }, | ||
| { "title": "Document the process for requesting additions to the IP allow-list" }, | ||
| { "title": "Schedule periodic review of the IP allow-list to remove stale entries" } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
|
|
||
| _ip_allow_list := object.get(input, "ip_allow_list", []) | ||
|
|
||
| _has_active_entry if { | ||
| some entry in _ip_allow_list | ||
| entry.is_active == true | ||
| } | ||
|
|
||
| violation[{"id": "ip_allowlist_not_configured"}] if { | ||
| not _has_active_entry | ||
| } | ||
|
|
||
| title := "Organization has an active IP allow-list configured" | ||
| description := "The GitHub organization must have at least one active IP allow-list entry to restrict access to approved network ranges and reduce the risk of access from untrusted locations." | ||
| remarks := "More information: https://docs.github.com/en/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/managing-allowed-ip-addresses-for-your-organization" |
This file contains hidden or 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,29 @@ | ||
| package compliance_framework.ip_allowlist_enabled | ||
|
|
||
| test_ip_allowlist_configured if { | ||
| count(violation) == 0 with input as { | ||
| "ip_allow_list": [ | ||
| {"allow_list_value": "203.0.113.0/24", "is_active": true, "name": "Office"}, | ||
| {"allow_list_value": "198.51.100.0/24", "is_active": false, "name": "Old VPN"} | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| test_ip_allowlist_all_inactive if { | ||
| count(violation) > 0 with input as { | ||
| "ip_allow_list": [ | ||
| {"allow_list_value": "203.0.113.0/24", "is_active": false, "name": "Disabled"}, | ||
| {"allow_list_value": "198.51.100.0/24", "is_active": false, "name": "Also Disabled"} | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| test_ip_allowlist_empty if { | ||
| count(violation) > 0 with input as { | ||
| "ip_allow_list": [] | ||
| } | ||
| } | ||
|
gusfcarvalho marked this conversation as resolved.
|
||
|
|
||
| test_ip_allowlist_missing if { | ||
| count(violation) > 0 with input as {} | ||
| } | ||
This file contains hidden or 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 @@ | ||
| package compliance_framework.members_can_create_repos | ||
|
|
||
| risk_templates := [ | ||
| { | ||
| "name": "Organization members can create repositories without restriction", | ||
| "title": "Unrestricted Repository Creation Undermines Access Governance", | ||
| "statement": "When all organization members are permitted to create repositories, the organization loses control over its asset inventory. Members may inadvertently expose internal code via public repositories, create repositories that bypass security baselines, or accumulate ungoverned codebases. Restricting repository creation to administrators ensures that new repositories are intentional, properly configured, and subject to security review before use.", | ||
| "likelihood_hint": "moderate", | ||
| "impact_hint": "high", | ||
| "violation_ids": ["members_can_create_repos"], | ||
| "threat_refs": [ | ||
| { | ||
| "system": "https://cwe.mitre.org", | ||
| "external_id": "CWE-284", | ||
| "title": "Improper Access Control", | ||
| "url": "https://cwe.mitre.org/data/definitions/284.html" | ||
| }, | ||
| { | ||
| "system": "https://cwe.mitre.org", | ||
| "external_id": "CWE-200", | ||
| "title": "Exposure of Sensitive Information to an Unauthorized Actor", | ||
| "url": "https://cwe.mitre.org/data/definitions/200.html" | ||
| } | ||
| ], | ||
| "remediation": { | ||
| "title": "Restrict repository creation to organization administrators", | ||
| "description": "Disable the ability for regular organization members to create new repositories. Only administrators should be permitted to create repositories, ensuring each new repository is intentionally provisioned and subject to organizational security baselines.", | ||
| "tasks": [ | ||
| { "title": "Navigate to Organization Settings > Member privileges" }, | ||
| { "title": "Review the Repository creation section for member repository creation settings" }, | ||
| { "title": "Disable 'Allow members to create repositories' or restrict repository creation to administrators" }, | ||
| { "title": "Review and archive any repositories created without administrative approval" }, | ||
| { "title": "Document a repository provisioning process that routes requests through an administrator" } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
|
|
||
| _settings := object.get(input, "settings", {}) | ||
|
|
||
| _members_can_create_repositories := object.get(_settings, "members_can_create_repositories", true) | ||
|
|
||
| violation[{"id": "members_can_create_repos"}] if { | ||
| _members_can_create_repositories | ||
| } | ||
|
|
||
| title := "Organization members cannot create repositories" | ||
| description := "Repository creation should be restricted to administrators to maintain control over the organization's code asset inventory and prevent ungoverned or accidentally public repositories." | ||
| remarks := "More information: https://docs.github.com/en/organizations/managing-organization-settings/restricting-repository-creation-in-your-organization" |
This file contains hidden or 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,21 @@ | ||
| package compliance_framework.members_can_create_repos | ||
|
|
||
| test_members_cannot_create_repos if { | ||
| count(violation) == 0 with input as { | ||
| "settings": { | ||
| "members_can_create_repositories": false | ||
| } | ||
| } | ||
| } | ||
|
|
||
| test_members_can_create_repos if { | ||
| count(violation) > 0 with input as { | ||
| "settings": { | ||
| "members_can_create_repositories": true | ||
| } | ||
| } | ||
| } | ||
|
|
||
| test_members_create_repos_missing if { | ||
| count(violation) > 0 with input as {} | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.