Audit Logs, Security Policies, Compliance Evidence, Repository Governance, and Enterprise Controls: Configuration, Design Choices, and Tradeoffs
Choose between GitHub-native and external evidence retention, repository and organization policy, preventive and detective controls, and human-readable versus machine-enforced governance.
Learning objectives
- Choose between GitHub-native retention and external archive/streaming based on investigation and compliance needs.
- Place controls at repository, organization, or enterprise scope deliberately.
- Distinguish preventive enforcement from detective audit evidence.
- Pair human-readable policy with machine-enforced rules instead of substituting one for the other.
- Explain current plan/deployment boundaries without making paid features mandatory.
1. From evidence mechanics to governance design
Lesson 2 proved that evidence has a lifecycle: collect → preserve → normalize → verify → retain → review. Production design adds a second dimension: where should the control live? A repository file is close to code and reviewable through Git. An organization ruleset can prevent drift across many repositories. An enterprise policy can constrain organizations. An external archive can outlive GitHub's native retention. These choices trade local autonomy against consistency and operational cost.
2. GitHub-native retention versus external archive/streaming
Native audit search is excellent for recent interactive investigations because it is already indexed around GitHub actors/resources. Current documentation describes organization/enterprise audit activity within 180 days and only seven days for Git events. Exports are suitable for bounded snapshots. Enterprise streaming is designed for continuous off-platform retention and large-scale correlation, but it requires Enterprise ownership, external storage/operations, duplicate handling, and currently remains public preview.
| Choice | Strength | Failure mode | Use when |
|---|---|---|---|
| Native UI/API | Low operational overhead; GitHub-aware fields/search | Time-bounded; account access can be part of incident | Recent investigation and operational review |
| Periodic export | Simple external snapshot | Gaps between exports; manual provenance/retention burden | Small organizations with bounded evidence needs |
| Enterprise stream | Continuous SIEM/archive copy; long retention | Receiver outages, duplicate events, external storage/security cost | Enterprise incident response and compliance correlation |
“External” should not mean “copy to an engineer's laptop.” Use write-restricted/object-locked storage where policy requires immutability, and record collection provenance.
3. Repository policy versus organization/enterprise policy
Repository policy gives teams autonomy and makes local intent easy to review. It also scales poorly when hundreds of repositories must stay aligned. Organization-wide rulesets centralize ref policy for Team/Enterprise organizations; enterprise policies can limit organization choices on Enterprise Cloud. The further up the hierarchy a control moves, the larger the blast radius of a mistake and the more important staged rollout, exception handling, and delegated administration become.
| Scope | Good fit | Governance caution |
|---|---|---|
| Repository | Service-specific CODEOWNERS, SECURITY.md, public Free ruleset | Drift across repositories |
| Organization | Team access model, security configuration, org-wide ruleset | Requires owners/delegated roles and plan-dependent features |
| Enterprise | Cross-organization policy, audit aggregation/streaming, identity policy | Enterprise-owner blast radius; local admins may be unable to override |
4. Preventive control versus detective audit
A preventive control tries to stop an undesired state transition: for example, a ruleset can require pull-request review before updating a protected branch. A detective control tells you that an event occurred or a state deviated: for example, an audit event can show a team permission changed. Audit evidence is not a substitute for prevention, and prevention is not a substitute for observability. Reliable governance normally combines both.
Do not create a rule so restrictive that operators bypass it constantly. Frequent bypass turns the exception path into the normal path and destroys signal quality. A preventive control should make the safe path easier than the exception path.
5. Human-readable policy versus machine-enforced rule
SECURITY.md is optimized for people reporting
vulnerabilities. CODEOWNERS expresses code stewardship.
A ruleset or branch protection is optimized for GitHub enforcement.
A security configuration expresses security-feature enablement at
scale. These artifacts should reference the same control objective
but remain independently testable.
A useful design sentence is: “The policy states what and why; the GitHub control states what the platform will enforce; the evidence plan states how we will prove operation; the exception record states when and why we intentionally deviated.”
6. Current availability boundaries
| Feature | Current GitHub.com boundary relevant here | Mandatory path? |
|---|---|---|
| SECURITY.md | Core repository security-policy feature; no Advanced Security purchase required | Yes |
| CODEOWNERS | Public repositories on GitHub Free/Free orgs; public+private on Pro/Team/Enterprise | Yes, public repo |
| Repository rulesets | Public repositories on GitHub Free; public+private on Pro/Team/Enterprise | Read-only state in mandatory lab |
| Organization-wide rulesets | GitHub Team or Enterprise organization capability | No; fixture/policy design |
| Org audit-log UI | Organization-owner surface; event availability differs by plan/deployment | No; optional if you own a disposable org |
| Org audit-log REST | Documented for GitHub Enterprise Cloud; organization owner; versioned REST | No |
| Enterprise audit streaming | Enterprise owner; currently public preview; external destination | No |
| Code security configurations | Organization/enterprise management surface; controlled security features can have separate plan/product eligibility | Fixture/read-only concept |
GitHub Enterprise Server must be evaluated against the exact installed version. Never copy a GitHub.com entitlement table into GHES policy without checking that release's documentation.
7. Security configurations are policy bundles, not security guarantees
A security configuration can establish consistent settings for dependency graph, Dependabot, code scanning, secret scanning, push protection, and related controls. That makes configuration drift easier to manage. It does not guarantee alerts were triaged, developers responded correctly, or every repository is eligible for every paid feature. Evidence should therefore include attachment/coverage state and operational outcomes separately.
# Read-only repository association, when your role/plan allows it.
REPO="OWNER/REPOSITORY"
gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2026-03-10" "repos/$REPO/code-security-configuration" --jq '{status,configuration:(.configuration | {id,name,enforcement})}'
A 204 can mean no configuration is attached; 403/404 may be authorization/availability/resource-scope signals. Diagnose before changing policy.
8. Exceptions are governed objects, not comments
Every exception should carry a control ID, affected repository/resource, rationale, risk owner, approver, start/expiry time, compensating control, and closure evidence. “Temporary” without an expiry is permanent by default. A bypass that leaves no durable ticket/reference cannot be reliably distinguished from unauthorized policy erosion.
Exception ID: EX-2026-0042
Control: SCM-PR-REVIEW-01
Scope: service-api / refs/heads/release-hotfix
Reason: emergency rollback of a verified prior artifact
Owner: release-manager-role
Approver: security-duty-role
Starts: 2026-08-19T18:00:00Z
Expires: 2026-08-20T00:00:00Z
Compensating control: two-person out-of-band review + post-change diff
Closure evidence: PR / audit event / deployment record references
9. Worked scenario and decision table
A 40-repository organization needs consistent review policy, an incident-ready evidence trail, and low cost. The team currently has no Enterprise subscription. The practical choice is layered: repository-level public rulesets where applicable, shared policy templates/CODEOWNERS conventions, periodic state inventory, and hashed evidence exports/fixtures. If the organization later adopts Enterprise Cloud for compliance, add enterprise audit streaming rather than rewriting every repository workflow.
| Option | Maintainability | Security | Governance | Reliability | Compatibility | Cost |
|---|---|---|---|---|---|---|
| Per-repo docs only | Low at scale | Weak prevention | High drift risk | Depends on humans | Broad | Low |
| Repo rulesets + docs | Medium | Strong public-repo prevention | Good local evidence | Good if tested | Free public path | Low |
| Org-wide policy | High consistency | Strong when well designed | Centralized | Larger blast radius | Team/Enterprise feature | Plan cost |
| Enterprise + external stream | High once operated | Best evidence resilience | Cross-org | Requires stream/SIEM operations | Enterprise Cloud | Highest |
Knowledge check
Why combine preventive rules with detective audit rather than choosing one?
Prevention reduces unsafe state transitions; audit provides visibility, investigation evidence, and accountability for changes/bypasses. Each covers failure modes the other cannot.
When does repository-local policy become a scaling problem?
When many repositories must share the same control and local copies drift or are reviewed inconsistently. At that point an organization/enterprise control may improve consistency, subject to plan and blast-radius tradeoffs.
What is the main reliability implication of at-least-once enterprise audit streaming?
The receiver must tolerate duplicate events and process them idempotently while preserving enough event identity to deduplicate safely.
Does attaching a security configuration prove vulnerabilities are remediated?
No. It proves configuration/coverage state for eligible settings. Alert response, false negatives, and remediation outcomes need separate operational evidence.
Why should an exception have an expiry even if the risk owner approved it?
Approval explains intent; expiry prevents temporary deviation from silently becoming permanent policy drift and creates a mandatory re-review point.
Summary
Choose scope and evidence intentionally: human policy for intent, machine enforcement for prevention, audit/log state for detection, external retention for resilience, and expiring exceptions for controlled deviation. Lesson 4 stress-tests this design against missing events, bad filters, weak evidence storage, and unenforced policy.
Further reading — current primary sources
Keep the academy open
Support free, practical DevOps education.
Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0
Send only Ethereum/ERC-20 compatible assets to this
address.