Ensure a CODEOWNERS file exists in the repository
Framework Reference: A.8.25 (Secure Development Lifecycle) Integration: GitHub – Repository Configuration
Why this matters
A CODEOWNERS
file defines who is responsible for specific files, directories, or components in a repository.
It enforces clear ownership and accountability by automatically requesting reviews from the designated owners when relevant files are modified.
- Having a CODEOWNERS file ensures that:
- Changes to sensitive or business-critical components are reviewed by the appropriate team members
- Code reviews are consistent and traceable
- Secure development and segregation of duties principles are upheld
Without it, ownership of files becomes ambiguous, and important changes may be merged without the necessary oversight.
What this check does
This check verifies that a valid CODEOWNERS
file exists in one of the supported locations within the repository:
- The root directory (
/CODEOWNERS
) - The
.github/
directory (/.github/CODEOWNERS
) - The
docs/
directory (/docs/CODEOWNERS
) - The check passes if a CODEOWNERS file is found in any of these paths and is properly readable by GitHub.
How to fix it
From the GitHub Web Console or via Git
- Create a file named
CODEOWNERS
in one of the following directories:- The root directory of the repository
.github/
directorydocs/
directory
- Define ownership rules using the format:
*.js @frontend-team
/infra/ @devops-leads
*.py @backend-team - Commit and push the
CODEOWNERS
file to the default branch. - Ensure that the file syntax follows GitHub’s pattern-matching rules and that all mentioned users or teams have access to the repository.
Once the file is committed, GitHub will automatically request reviews from the specified code owners whenever matching files are changed in a pull request.
Exceptions
- A CODEOWNERS file only takes effect if it is located in one of the three supported directories.
- Invalid patterns, typos in usernames, or teams without access to the repository will prevent GitHub from applying ownership rules.
- Organizations using branch protection with “Require review from Code Owners” depend on this file being valid and present.