Add file_disallow policy to detect sensitive files in repositories#26
Merged
Add file_disallow policy to detect sensitive files in repositories#26
Conversation
Co-authored-by: david3107 <20040740+david3107@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add policy to identify sensitive files in repository
Add file_disallow policy to detect sensitive files in repositories
Oct 10, 2025
david3107
approved these changes
Oct 10, 2025
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.
Overview
Implements a new
file_disallowsecurity policy that identifies sensitive files (like.env, configuration files with credentials) that should not be present in GitHub repositories. This helps prevent accidental commits of API tokens, passwords, and other sensitive information.Problem
Files containing plain text credentials (
.env,config.xml,credentials.json, etc.) are sometimes pushed to repositories by mistake, leaking API tokens, passwords, and other sensitive data. While these files should be added to.gitignore, developers can accidentally commit them before proper gitignore rules are in place.Solution
This PR introduces a
file_disallowpolicy that:.gitignore.env*), and directory patterns.gitignoreUsage
Add the
file_disallowconfiguration to yourpolicies/repository.yml:Example Output
When sensitive files are detected, the check fails with detailed information:
{ "name": "Files Disallow Check", "pass": false, "data": { "foundDisallowedFiles": [".env", "credentials.json"], "gitignoreExists": true, "missingInGitignore": ["credentials.json"] } }This tells you:
.envandcredentials.jsonexist in the repository.gitignorefile existscredentials.jsonis NOT in.gitignore(action required!)Implementation Details
FilesDisallowChecksclass insrc/evaluators/multipurpose/RepoPolicyEvaluatorfile_disallowfield toRepoPolicyinterfacerepository.readme.mdand threat model inrepository.threats.mdSecurity Benefits
Testing
Closes #[issue_number]
Original prompt
Fixes #19
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.