feat(org): add support for code security configurations#640
Open
gdams wants to merge 1 commit into
Open
Conversation
Adds a new org-level resource `OrganizationCodeSecurityConfiguration`
that wraps GitHub's Code Security Configurations API
(/orgs/{org}/code-security/configurations).
This is the successor to the deprecated per-feature
'*_enabled_for_new_repositories' organization settings and lets users
manage named code security configurations with fields:
- advanced_security
- dependency_graph (+ autosubmit action)
- dependabot_alerts
- dependabot_security_updates
- code_scanning_default_setup
- secret_scanning (+ push_protection, delegated_bypass,
validity_checks, non_provider_patterns)
- private_vulnerability_reporting
- enforcement
Changes:
- new model otterdog/models/organization_code_security_configuration.py
- wired into otterdog/models/github_organization.py (field,
accessors, get_model_objects, from_model_data, validate, to_jsonnet,
generate_live_patch, parallel load from provider)
- new provider methods on GitHubProvider and OrgClient covering
list/add/update/delete
- JsonnetConfig: new function name + default config cached property
- default libsonnet template: newOrgCodeSecurityConfiguration() +
code_security_configurations array on newOrg + export
- JSON schema: org-code-security-configuration.json +
reference in organization.json
- tests and resource fixtures
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a new org-level resource
OrganizationCodeSecurityConfigurationthat wraps GitHub's Code Security Configurations API (/orgs/{org}/code-security/configurations).This is the successor to the deprecated per-feature
*_enabled_for_new_repositoriesorganization settings, letting users manage named code security configurations directly from otterdog.New resource
Each
code_security_configurationentry supports:name,description,enforcementadvanced_securitydependency_graph+dependency_graph_autosubmit_actiondependabot_alerts,dependabot_security_updatescode_scanning_default_setupsecret_scanning+secret_scanning_push_protection,secret_scanning_delegated_bypass,secret_scanning_validity_checks,secret_scanning_non_provider_patternsprivate_vulnerability_reportingFeature fields accept
enabled/disabled/not_set;enforcementacceptsenforced/unenforced.Example
Changes
otterdog/models/organization_code_security_configuration.py(new) —ModelObjectwith validate and full live-patch ADD/REMOVE/CHANGE support.otterdog/models/github_organization.py— new field, accessors, wiring intoget_model_objects,from_model_data,validate,to_jsonnet,generate_live_patch, and parallel loading from provider.otterdog/providers/github/__init__.py+otterdog/providers/github/rest/org_client.py— list/add/update/delete methods for the new endpoints (global/predefined configs are filtered out on read).otterdog/jsonnet.py—create_org_code_security_configurationfunction name anddefault_org_code_security_configuration_configcached property.examples/template/otterdog-defaults.libsonnet—newOrgCodeSecurityConfiguration()helper, newcode_security_configurationsarray onnewOrg, and export.otterdog/resources/schemas/org-code-security-configuration.json(new) +organization.jsonreference.tests/models/test_org_code_security_configuration.py+ fixture JSON files.Testing
poetry run pytest tests/models/test_org_code_security_configuration.py→ 4 passedpoetry run pytest tests/→ 247 passed, 2 skipped, 0 failurespoetry run mypy otterdog→ cleanpoetry run ruff check/ruff format→ clean